Current alarm cancelled and service unbinds when deleting it or saving changes to it
This commit is contained in:
parent
514bf41475
commit
b0cc8e3557
@ -75,7 +75,10 @@ public class EditAlarmPresenter implements EditAlarmContract.Presenter {
|
|||||||
.build();
|
.build();
|
||||||
a.setEnabled(mView.isEnabled());
|
a.setEnabled(mView.isEnabled());
|
||||||
if (mAlarm != null) {
|
if (mAlarm != null) {
|
||||||
|
if (mAlarm.isEnabled()) {
|
||||||
|
Log.d(TAG, "Cancelling old alarm first");
|
||||||
mAlarmUtilsHelper.cancelAlarm(mAlarm, false);
|
mAlarmUtilsHelper.cancelAlarm(mAlarm, false);
|
||||||
|
}
|
||||||
mRepository.updateItem(mAlarm, a);
|
mRepository.updateItem(mAlarm, a);
|
||||||
} else {
|
} else {
|
||||||
mRepository.addItem(a);
|
mRepository.addItem(a);
|
||||||
@ -92,9 +95,9 @@ public class EditAlarmPresenter implements EditAlarmContract.Presenter {
|
|||||||
public void delete() {
|
public void delete() {
|
||||||
if (mAlarm != null) {
|
if (mAlarm != null) {
|
||||||
if (mAlarm.isEnabled()) {
|
if (mAlarm.isEnabled()) {
|
||||||
mAlarmUtilsHelper.cancelAlarm(mAlarm, false); // (1)
|
mAlarmUtilsHelper.cancelAlarm(mAlarm, false);
|
||||||
}
|
}
|
||||||
mRepository.deleteItem(mAlarm); // TOneverDO: before (1)
|
mRepository.deleteItem(mAlarm);
|
||||||
}
|
}
|
||||||
mView.showEditorClosed();
|
mView.showEditorClosed();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ public class RingtoneService extends Service { // TODO: abstract this, make subc
|
|||||||
public void run() {
|
public void run() {
|
||||||
mAutoSilenced = true;
|
mAutoSilenced = true;
|
||||||
mRingtone.stop(); // don't wait for activity to finish and unbind
|
mRingtone.stop(); // don't wait for activity to finish and unbind
|
||||||
|
AlarmUtils.cancelAlarm(RingtoneService.this, mAlarm, false);
|
||||||
if (mRingtoneCallback != null) {
|
if (mRingtoneCallback != null) {
|
||||||
// Finish the activity, which fires onDestroy() and then unbinds itself from this service.
|
// Finish the activity, which fires onDestroy() and then unbinds itself from this service.
|
||||||
// All clients must be unbound before stopSelf() (and stopService()?) will succeed.
|
// All clients must be unbound before stopSelf() (and stopService()?) will succeed.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user