Save label changes

This commit is contained in:
Phillip Hsu 2016-09-02 17:25:31 -07:00
parent 8b9b4258e2
commit 5ec512d268
2 changed files with 20 additions and 1 deletions

View File

@ -45,6 +45,14 @@ public abstract class Alarm extends ObjectWithId implements JsonSerializable, Pa
throw new UnsupportedOperationException();
}
public void copyMutableFieldsTo(Alarm target) {
target.setId(this.getId());
target.snoozingUntilMillis = this.snoozingUntilMillis;
target.enabled = this.enabled;
System.arraycopy(this.recurringDays, 0, target.recurringDays, 0, NUM_DAYS);
target.ignoreUpcomingRingTime = this.ignoreUpcomingRingTime;
}
public static Builder builder() {
// Unfortunately, default values must be provided for generated Builders.
// Fields that were not set when build() is called will throw an exception.

View File

@ -31,6 +31,7 @@ import butterknife.OnClick;
* Created by Phillip Hsu on 7/31/2016.
*/
public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
private static final String TAG = "ExpandedAlarmViewHolder";
@Bind(R.id.ok) Button mOk;
@Bind(R.id.delete) Button mDelete;
@ -55,7 +56,17 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
mOk.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onListItemUpdate(getAlarm(), getAdapterPosition());
final Alarm oldAlarm = getAlarm();
Alarm newAlarm = Alarm.builder()
.hour(oldAlarm.hour()/*TODO*/)
.minutes(oldAlarm.minutes()/*TODO*/)
.label(mLabel.getText().toString())
.ringtone(""/*TODO*/)
.vibrates(mVibrate.isChecked())
.build();
Log.d(TAG, "New alarm: " + newAlarm);
oldAlarm.copyMutableFieldsTo(newAlarm);
listener.onListItemUpdate(newAlarm, getAdapterPosition());
}
});