Persist vibrate change as it is made

This commit is contained in:
Phillip Hsu 2016-09-03 17:41:12 -07:00
parent abc849c243
commit 554dd49f0a
2 changed files with 11 additions and 4 deletions

View File

@ -46,7 +46,9 @@ public abstract class BaseAlarmViewHolder extends BaseViewHolder<Alarm> {
private static final String TAG = "BaseAlarmViewHolder"; private static final String TAG = "BaseAlarmViewHolder";
private static final String TAG_ADD_LABEL_DIALOG = "add_label_dialog"; private static final String TAG_ADD_LABEL_DIALOG = "add_label_dialog";
private final AlarmController mAlarmController; // Visible for subclasses.
final AlarmController mAlarmController;
// TODO: Should we use VectorDrawable type? // TODO: Should we use VectorDrawable type?
private final Drawable mDismissNowDrawable; private final Drawable mDismissNowDrawable;
private final Drawable mCancelSnoozeDrawable; private final Drawable mCancelSnoozeDrawable;
@ -307,6 +309,7 @@ public abstract class BaseAlarmViewHolder extends BaseViewHolder<Alarm> {
}; };
} }
@Deprecated
protected final OnListItemInteractionListener<Alarm> getInteractionListener() { protected final OnListItemInteractionListener<Alarm> getInteractionListener() {
return mInteractionListener; return mInteractionListener;
} }

View File

@ -129,8 +129,13 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
// any changes until the user explicitly clicked save. We have to do this here now because // any changes until the user explicitly clicked save. We have to do this here now because
// we should commit changes as they are made. // we should commit changes as they are made.
@OnCheckedChanged(R.id.vibrate) @OnCheckedChanged(R.id.vibrate)
void onVibrateToggled() { void onVibrateToggled(boolean checked) {
// TODO final Alarm oldAlarm = getAlarm();
Alarm newAlarm = oldAlarm.toBuilder()
.vibrates(checked)
.build();
oldAlarm.copyMutableFieldsTo(newAlarm);
mAlarmController.save(newAlarm);
} }
@OnCheckedChanged({ R.id.day0, R.id.day1, R.id.day2, R.id.day3, R.id.day4, R.id.day5, R.id.day6 }) @OnCheckedChanged({ R.id.day0, R.id.day1, R.id.day2, R.id.day3, R.id.day4, R.id.day5, R.id.day6 })
@ -197,7 +202,6 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
Alarm newAlarm = Alarm.builder() Alarm newAlarm = Alarm.builder()
.hour(oldAlarm.hour()/*TODO*/) .hour(oldAlarm.hour()/*TODO*/)
.minutes(oldAlarm.minutes()/*TODO*/) .minutes(oldAlarm.minutes()/*TODO*/)
.label(mLabel.getText().toString())
.ringtone(""/*TODO*/) .ringtone(""/*TODO*/)
.vibrates(mVibrate.isChecked()) .vibrates(mVibrate.isChecked())
.build(); .build();