Skip to content

Commit 42eb969

Browse files
committed
bug fix
1 parent 8b7716e commit 42eb969

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

android/src/main/java/com/reactnativecustomtimernotification/CustomTimerNotificationModule.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
121121

122122
// notificationLayout.setTextViewText(R.id.timer,remainingTime)
123123
notificationLayout.setChronometerCountDown(R.id.simpleChronometer, true);
124-
notificationLayout.setChronometer(R.id.simpleChronometer, remainingTime, ("%sM:%sS"), true);
124+
notificationLayout.setChronometer(R.id.simpleChronometer, remainingTime, ("%tM:%tS"), true);
125125

126126

127127
// try {
@@ -152,7 +152,8 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
152152
.setWhen(endTime.getTimeInMillis());
153153
val handler = Handler()
154154
handler.postDelayed({
155-
notificationLayout.setChronometer(R.id.simpleChronometer, remainingTime, ("%sM:%sS"), false);
155+
notificationLayout.setChronometerCountDown(R.id.simpleChronometer, true);
156+
notificationLayout.setChronometer(R.id.simpleChronometer, remainingTime, ("%tM:%tS"), false);
156157
try {
157158
val remove =objectData.getBoolean("remove");
158159
val foreground =objectData.getBoolean("foreground");
@@ -162,7 +163,9 @@ class CustomTimerNotificationModule: ReactContextBaseJavaModule {
162163
notificationLayout.setViewVisibility (R.id.simpleChronometer,
163164
View.INVISIBLE)
164165
}
165-
} catch (e:Exception){}
166+
} catch (e:Exception){
167+
println(e)
168+
}
166169

167170
notificationBuilder.setCustomContentView(notificationLayout)
168171
notificationManager.notify(id,notificationBuilder.build())

src/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,34 @@ const CustomTimerNotification = NativeModules.CustomTimerNotification
1818
);
1919

2020
export function TimerNotification(a: object): any {
21-
const parseDate = (rawDate) => {
21+
const parseDate = (rawDate: any) => {
2222
let hours;
2323
let day;
2424
let month;
25-
25+
2626
if (rawDate.getHours().toString().length === 1) {
2727
hours = `0${rawDate.getHours()}`;
2828
} else {
2929
hours = `${rawDate.getHours()}`;
3030
}
31-
31+
3232
if (rawDate.getDate().toString().length === 1) {
3333
day = `0${rawDate.getDate()}`;
3434
} else {
3535
day = `${rawDate.getDate()}`;
3636
}
37-
37+
3838
if (rawDate.getMonth().toString().length === 1) {
3939
month = `0${rawDate.getMonth() + 1}`;
4040
} else {
4141
month = `${rawDate.getMonth() + 1}`;
4242
}
43-
43+
4444
return `${day}-${month}-${rawDate.getFullYear()} ${hours}:${rawDate.getMinutes()}:${rawDate.getSeconds()}`;
4545
};
46-
const data = a;
47-
data.date = parseDate(data.date)
48-
46+
const data: any = a;
47+
data.date = parseDate(data.date);
48+
4949
if (Platform.OS === 'android')
5050
return CustomTimerNotification.TimerNotification(data);
5151
return null;

0 commit comments

Comments
 (0)