Changed where and when we save alarms
This commit is contained in:
parent
b0cc8e3557
commit
55836799da
@ -68,9 +68,9 @@ public class AlarmViewHolder extends BaseViewHolder<Alarm> implements AlarmCount
|
|||||||
|
|
||||||
@OnClick(R.id.dismiss)
|
@OnClick(R.id.dismiss)
|
||||||
void dismiss() {
|
void dismiss() {
|
||||||
// TOneverDO: AlarmUtils.cancelAlarm() otherwise it will be called twice
|
|
||||||
mSwitch.setPressed(true); // needed so the OnCheckedChange event calls through
|
mSwitch.setPressed(true); // needed so the OnCheckedChange event calls through
|
||||||
bindSwitch(false); // fires OnCheckedChange to do the binding for you
|
bindSwitch(false); // fires OnCheckedChange to do the binding for you
|
||||||
|
// TOneverDO: AlarmUtils.cancelAlarm() otherwise it will be called twice
|
||||||
/*
|
/*
|
||||||
AlarmUtils.cancelAlarm(getContext(), getAlarm());
|
AlarmUtils.cancelAlarm(getContext(), getAlarm());
|
||||||
if (!getAlarm().isEnabled()) {
|
if (!getAlarm().isEnabled()) {
|
||||||
@ -123,11 +123,10 @@ public class AlarmViewHolder extends BaseViewHolder<Alarm> implements AlarmCount
|
|||||||
bindCountdown(true, alarm.ringsIn());
|
bindCountdown(true, alarm.ringsIn());
|
||||||
bindDismissButton(alarm);
|
bindDismissButton(alarm);
|
||||||
} else {
|
} else {
|
||||||
AlarmUtils.cancelAlarm(getContext(), alarm, true); // might save repo
|
AlarmUtils.cancelAlarm(getContext(), alarm, true); // saves repo
|
||||||
bindCountdown(false, -1);
|
bindCountdown(false, -1);
|
||||||
bindDismissButton(false, "");
|
bindDismissButton(false, "");
|
||||||
}
|
}
|
||||||
save(); // TODO: Problem! If cancelAlarm() saves the repo, this is a redundant call!
|
|
||||||
mSwitch.setPressed(false); // clear the pressed focus, esp. if setPressed(true) was called manually
|
mSwitch.setPressed(false); // clear the pressed focus, esp. if setPressed(true) was called manually
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,12 @@ public class AlarmsFragment extends Fragment implements BaseRepository.DataObser
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
AlarmsRepository.getInstance(getActivity()).saveItems();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
|
|||||||
@ -91,14 +91,14 @@ public final class AlarmUtils {
|
|||||||
|
|
||||||
if (a.isSnoozed()) {
|
if (a.isSnoozed()) {
|
||||||
a.stopSnoozing();
|
a.stopSnoozing();
|
||||||
save(c); // TODO: not necessary?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!a.hasRecurrence()) {
|
if (!a.hasRecurrence()) {
|
||||||
a.setEnabled(false);
|
a.setEnabled(false);
|
||||||
save(c); // TODO: not necessary?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
save(c); // Save any changes
|
||||||
|
|
||||||
// If service is not running, nothing happens
|
// If service is not running, nothing happens
|
||||||
// TODO: Since RingtoneService is a bound service, will this destroy the service after returning?
|
// TODO: Since RingtoneService is a bound service, will this destroy the service after returning?
|
||||||
// Note that if a stopped service still has ServiceConnection objects bound to it with the
|
// Note that if a stopped service still has ServiceConnection objects bound to it with the
|
||||||
@ -109,7 +109,7 @@ public final class AlarmUtils {
|
|||||||
public static void snoozeAlarm(Context c, Alarm a) {
|
public static void snoozeAlarm(Context c, Alarm a) {
|
||||||
a.snooze(AlarmUtils.snoozeDuration(c));
|
a.snooze(AlarmUtils.snoozeDuration(c));
|
||||||
AlarmUtils.scheduleAlarm(c, a);
|
AlarmUtils.scheduleAlarm(c, a);
|
||||||
save(c); // TODO: not necessary?
|
save(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeUpcomingAlarmNotification(Context c, Alarm a) {
|
public static void removeUpcomingAlarmNotification(Context c, Alarm a) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user