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:
Phillip Hsu 2016-09-08 23:07:24 -07:00
parent df19d6ec4b
commit e3c78861c6
3 changed files with 6 additions and 10 deletions

View File

@ -36,12 +36,12 @@ public class TimerNotificationService extends Service {
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 NotificationCompat.Builder mNoteBuilder;
private NotificationManager mNotificationManager;
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
@ -62,9 +62,9 @@ public class TimerNotificationService extends Service {
* you want to cancel
*/
public static void cancelNotification(Context context, long timerId) { // TODO: remove long param
// NotificationManager nm = (NotificationManager)
// context.getSystemService(Context.NOTIFICATION_SERVICE);
// nm.cancel(TAG, (int) timerId);
NotificationManager nm = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
nm.cancel(TAG, (int) timerId);
context.stopService(new Intent(context, TimerNotificationService.class));
}
@ -99,7 +99,6 @@ public class TimerNotificationService extends Service {
@Override
public void onDestroy() {
super.onDestroy();
mNotificationManager.cancelAll();
quitThread();
}

View File

@ -2,7 +2,6 @@ package com.philliphsu.clock2.timers;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
@ -23,8 +22,6 @@ public class TimesUpActivity extends RingtoneActivity<Timer> {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
stopService(new Intent(this, TimerNotificationService.class));
// TODO: Consider calling this in the service's onDestroy()
TimerNotificationService.cancelNotification(this, getRingingObject().getId());
mController = new TimerController(getRingingObject(),
new AsyncTimersTableUpdateHandler(this, null));

View File

@ -37,7 +37,7 @@ public class ProgressBarUtils {
// have hardcoded this animator to be a "countdown" progress bar. This is
// sufficient for our current needs.
progress, 0);
animator.setDuration(duration);
animator.setDuration(duration < 0 ? 0 : duration);
// The algorithm that calculates intermediate values between keyframes. We use linear
// interpolation so that the animation runs at constant speed.
animator.setInterpolator(null/*results in linear interpolation*/);