Fix multiple timer notifications from all clearing when first timer to launch cancels all of them. Prevent setting negative durations for ProgressBar animator.
This commit is contained in:
parent
df19d6ec4b
commit
e3c78861c6
@ -36,12 +36,12 @@ public class TimerNotificationService extends Service {
|
|||||||
|
|
||||||
public static final String EXTRA_TIMER = "com.philliphsu.clock2.timers.extra.TIMER";
|
public static final String EXTRA_TIMER = "com.philliphsu.clock2.timers.extra.TIMER";
|
||||||
|
|
||||||
private Timer mTimer;
|
private Timer mTimer; // TODO: I think we may need a list of timers.
|
||||||
private TimerController mController;
|
private TimerController mController;
|
||||||
private NotificationCompat.Builder mNoteBuilder;
|
private NotificationCompat.Builder mNoteBuilder;
|
||||||
private NotificationManager mNotificationManager;
|
private NotificationManager mNotificationManager;
|
||||||
private final CountdownDelegate mCountdownDelegate = new CountdownDelegate();
|
private final CountdownDelegate mCountdownDelegate = new CountdownDelegate();
|
||||||
private MyHandlerThread mThread;
|
private MyHandlerThread mThread; // TODO: I think we may need a list of threads.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to start this Service for its default action: to show
|
* Helper method to start this Service for its default action: to show
|
||||||
@ -62,9 +62,9 @@ public class TimerNotificationService extends Service {
|
|||||||
* you want to cancel
|
* you want to cancel
|
||||||
*/
|
*/
|
||||||
public static void cancelNotification(Context context, long timerId) { // TODO: remove long param
|
public static void cancelNotification(Context context, long timerId) { // TODO: remove long param
|
||||||
// NotificationManager nm = (NotificationManager)
|
NotificationManager nm = (NotificationManager)
|
||||||
// context.getSystemService(Context.NOTIFICATION_SERVICE);
|
context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
// nm.cancel(TAG, (int) timerId);
|
nm.cancel(TAG, (int) timerId);
|
||||||
context.stopService(new Intent(context, TimerNotificationService.class));
|
context.stopService(new Intent(context, TimerNotificationService.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,6 @@ public class TimerNotificationService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
mNotificationManager.cancelAll();
|
|
||||||
quitThread();
|
quitThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package com.philliphsu.clock2.timers;
|
|||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
@ -23,8 +22,6 @@ public class TimesUpActivity extends RingtoneActivity<Timer> {
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
stopService(new Intent(this, TimerNotificationService.class));
|
|
||||||
// TODO: Consider calling this in the service's onDestroy()
|
|
||||||
TimerNotificationService.cancelNotification(this, getRingingObject().getId());
|
TimerNotificationService.cancelNotification(this, getRingingObject().getId());
|
||||||
mController = new TimerController(getRingingObject(),
|
mController = new TimerController(getRingingObject(),
|
||||||
new AsyncTimersTableUpdateHandler(this, null));
|
new AsyncTimersTableUpdateHandler(this, null));
|
||||||
|
|||||||
@ -37,7 +37,7 @@ public class ProgressBarUtils {
|
|||||||
// have hardcoded this animator to be a "countdown" progress bar. This is
|
// have hardcoded this animator to be a "countdown" progress bar. This is
|
||||||
// sufficient for our current needs.
|
// sufficient for our current needs.
|
||||||
progress, 0);
|
progress, 0);
|
||||||
animator.setDuration(duration);
|
animator.setDuration(duration < 0 ? 0 : duration);
|
||||||
// The algorithm that calculates intermediate values between keyframes. We use linear
|
// The algorithm that calculates intermediate values between keyframes. We use linear
|
||||||
// interpolation so that the animation runs at constant speed.
|
// interpolation so that the animation runs at constant speed.
|
||||||
animator.setInterpolator(null/*results in linear interpolation*/);
|
animator.setInterpolator(null/*results in linear interpolation*/);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user