@@ -15,6 +15,7 @@ import android.icu.util.Calendar
15
15
import android.os.*
16
16
import android.view.View
17
17
import android.widget.RemoteViews;
18
+ import androidx.annotation.RequiresApi
18
19
import com.facebook.react.bridge.ReadableMap;
19
20
import java.util.*
20
21
@@ -30,6 +31,7 @@ class ForegroundService : Service() {
30
31
val payload = objectData.getString(" payload" );
31
32
val id = objectData.getInt(" id" );
32
33
val datetime = objectData.getString(" date" )
34
+ val isCountDown = objectData.getBoolean(" isCountDown" )
33
35
34
36
try {
35
37
val remove = objectData.getBoolean(" remove" );
@@ -41,6 +43,7 @@ class ForegroundService : Service() {
41
43
startIntent.putExtra(" title" , title)
42
44
startIntent.putExtra(" body" , body)
43
45
startIntent.putExtra(" payload" , payload)
46
+ startIntent.putExtra(" isCountDown" , isCountDown)
44
47
45
48
ContextCompat .startForegroundService(context, startIntent)
46
49
}
@@ -55,6 +58,9 @@ class ForegroundService : Service() {
55
58
val body = intent?.getStringExtra(" body" );
56
59
val payload = intent?.getStringExtra(" payload" );
57
60
val id: Int? = intent?.getIntExtra(" id" ,0 )
61
+ val isCountDown: Boolean? = intent?.getBooleanExtra(" isCountDown" ,false )
62
+
63
+
58
64
59
65
val intent = Intent (this , NotificationEventReceiver ::class .java)
60
66
intent.flags = Intent .FLAG_ACTIVITY_CLEAR_TOP or Intent .FLAG_ACTIVITY_NEW_TASK
@@ -74,10 +80,10 @@ class ForegroundService : Service() {
74
80
notificationLayout.setTextViewText(R .id.title,title)
75
81
notificationLayout.setTextViewText(R .id.text,body)
76
82
if (displayerTimer){
77
- notificationLayout.setChronometerCountDown(R .id.simpleChronometer, true );
83
+ notificationLayout.setChronometerCountDown(R .id.simpleChronometer, isCountDown !! );
78
84
notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), true );
79
85
} else {
80
- notificationLayout.setChronometerCountDown(R .id.simpleChronometer, false );
86
+ notificationLayout.setChronometerCountDown(R .id.simpleChronometer, isCountDown !! );
81
87
notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), false );
82
88
}
83
89
@@ -107,8 +113,10 @@ if(displayerTimer){
107
113
108
114
return notification
109
115
}
116
+ @RequiresApi(Build .VERSION_CODES .N )
110
117
override fun onStartCommand (intent : Intent ? , flags : Int , startId : Int ): Int {
111
118
val id: Int? = intent?.getIntExtra(" id" ,0 )
119
+ val isCountDown: Boolean = intent!! .getBooleanExtra(" isCountDown" ,false )
112
120
113
121
val datetime = intent?.getStringExtra(" date" )
114
122
val sdf = SimpleDateFormat (" dd-MM-yyyy HH:mm:ss" , Locale .ENGLISH )
@@ -122,6 +130,8 @@ if(displayerTimer){
122
130
val remainingTime = startTime - elapsed
123
131
124
132
val handler = Handler ()
133
+
134
+ if (isCountDown)
125
135
handler.postDelayed({
126
136
try {
127
137
val remove = intent?.getBooleanExtra(" remove" ,false );
0 commit comments