Implemented timer actions in ringtone activity

This commit is contained in:
Phillip Hsu 2016-08-06 03:40:29 -07:00
parent 6b7c9cedee
commit 07de78e8e7

View File

@ -8,6 +8,7 @@ import android.os.SystemClock;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.philliphsu.clock2.AsyncTimersTableUpdateHandler;
import com.philliphsu.clock2.R; import com.philliphsu.clock2.R;
import com.philliphsu.clock2.Timer; import com.philliphsu.clock2.Timer;
import com.philliphsu.clock2.ringtone.RingtoneActivity; import com.philliphsu.clock2.ringtone.RingtoneActivity;
@ -16,13 +17,17 @@ import com.philliphsu.clock2.ringtone.RingtoneService;
public class TimesUpActivity extends RingtoneActivity<Timer> { public class TimesUpActivity extends RingtoneActivity<Timer> {
private static final String TAG = "TimesUpActivity"; private static final String TAG = "TimesUpActivity";
private TimerController mController;
private NotificationManager mNotificationManager; private NotificationManager mNotificationManager;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
stopService(new Intent(this, TimerNotificationService.class)); 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(),
new AsyncTimersTableUpdateHandler(this, null));
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
} }
@ -91,12 +96,14 @@ public class TimesUpActivity extends RingtoneActivity<Timer> {
@Override @Override
protected void onLeftButtonClick() { protected void onLeftButtonClick() {
mController.addOneMinute();
stopAndFinish();
} }
@Override @Override
protected void onRightButtonClick() { protected void onRightButtonClick() {
mController.stop();
stopAndFinish();
} }
// TODO: Consider changing the return type to Notification, and move the actual // TODO: Consider changing the return type to Notification, and move the actual