@@ -15,6 +15,7 @@ import android.icu.util.Calendar
1515import android.os.*
1616import android.view.View
1717import android.widget.RemoteViews;
18+ import androidx.annotation.RequiresApi
1819import com.facebook.react.bridge.ReadableMap;
1920import java.util.*
2021
@@ -30,6 +31,7 @@ class ForegroundService : Service() {
3031 val payload = objectData.getString(" payload" );
3132 val id = objectData.getInt(" id" );
3233 val datetime = objectData.getString(" date" )
34+ val isCountDown = objectData.getBoolean(" isCountDown" )
3335
3436 try {
3537 val remove = objectData.getBoolean(" remove" );
@@ -41,6 +43,7 @@ class ForegroundService : Service() {
4143 startIntent.putExtra(" title" , title)
4244 startIntent.putExtra(" body" , body)
4345 startIntent.putExtra(" payload" , payload)
46+ startIntent.putExtra(" isCountDown" , isCountDown)
4447
4548 ContextCompat .startForegroundService(context, startIntent)
4649 }
@@ -55,6 +58,9 @@ class ForegroundService : Service() {
5558 val body = intent?.getStringExtra(" body" );
5659 val payload = intent?.getStringExtra(" payload" );
5760 val id: Int? = intent?.getIntExtra(" id" ,0 )
61+ val isCountDown: Boolean? = intent?.getBooleanExtra(" isCountDown" ,false )
62+
63+
5864
5965 val intent = Intent (this , NotificationEventReceiver ::class .java)
6066 intent.flags = Intent .FLAG_ACTIVITY_CLEAR_TOP or Intent .FLAG_ACTIVITY_NEW_TASK
@@ -74,10 +80,10 @@ class ForegroundService : Service() {
7480 notificationLayout.setTextViewText(R .id.title,title)
7581 notificationLayout.setTextViewText(R .id.text,body)
7682if (displayerTimer){
77- notificationLayout.setChronometerCountDown(R .id.simpleChronometer, true );
83+ notificationLayout.setChronometerCountDown(R .id.simpleChronometer, isCountDown !! );
7884 notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), true );
7985} else {
80- notificationLayout.setChronometerCountDown(R .id.simpleChronometer, false );
86+ notificationLayout.setChronometerCountDown(R .id.simpleChronometer, isCountDown !! );
8187 notificationLayout.setChronometer(R .id.simpleChronometer, remainingTime, (" %tM:%tS" ), false );
8288}
8389
@@ -107,8 +113,10 @@ if(displayerTimer){
107113
108114 return notification
109115 }
116+ @RequiresApi(Build .VERSION_CODES .N )
110117 override fun onStartCommand (intent : Intent ? , flags : Int , startId : Int ): Int {
111118 val id: Int? = intent?.getIntExtra(" id" ,0 )
119+ val isCountDown: Boolean = intent!! .getBooleanExtra(" isCountDown" ,false )
112120
113121 val datetime = intent?.getStringExtra(" date" )
114122 val sdf = SimpleDateFormat (" dd-MM-yyyy HH:mm:ss" , Locale .ENGLISH )
@@ -122,6 +130,8 @@ if(displayerTimer){
122130 val remainingTime = startTime - elapsed
123131
124132 val handler = Handler ()
133+
134+ if (isCountDown)
125135 handler.postDelayed({
126136 try {
127137 val remove = intent?.getBooleanExtra(" remove" ,false );
0 commit comments