Collapse expanded ViewHolder when OK is clicked
This commit is contained in:
parent
f13897cc8e
commit
dc8b244369
@ -114,6 +114,8 @@ public class AlarmsFragment extends RecyclerViewFragment<
|
|||||||
|
|
||||||
// Does nothing If there is no expanded position.
|
// Does nothing If there is no expanded position.
|
||||||
getAdapter().expand(mExpandedPosition);
|
getAdapter().expand(mExpandedPosition);
|
||||||
|
// We shouldn't continue to keep a reference to this, so clear it.
|
||||||
|
mExpandedPosition = RecyclerView.NO_POSITION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -53,18 +53,19 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
|
|||||||
listener.onListItemDeleted(getAlarm());
|
listener.onListItemDeleted(getAlarm());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: We can now do method binding instead, because our superclass provides an API
|
|
||||||
// to retrieve the interaction listener.
|
|
||||||
mOk.setOnClickListener(new View.OnClickListener() {
|
mOk.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
// Since changes are persisted as soon as they are made, there's really
|
// Since changes are persisted as soon as they are made, there's really
|
||||||
// nothing we have to persist here. This just lets the listener know
|
// nothing we have to persist here. Let the listener know we should
|
||||||
// we should collapse this VH.
|
// collapse this VH.
|
||||||
// TODO: Verify that the VH is collapsed.
|
// While this works, it also makes an update to the DB and thus reschedules
|
||||||
// Alternatively, I think we can just performClick() on the itemView.
|
// the alarm, so the snackbar will show up as well. We want to avoid that..
|
||||||
listener.onListItemUpdate(getAlarm(), getAdapterPosition());
|
// listener.onListItemUpdate(getAlarm(), getAdapterPosition());
|
||||||
|
// TODO: This only works because we know what the implementation looks like..
|
||||||
|
// This is bad because we just made the proper function of this dependent
|
||||||
|
// on the implementation.
|
||||||
|
listener.onListItemClick(getAlarm(), getAdapterPosition());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -209,8 +210,6 @@ public class ExpandedAlarmViewHolder extends BaseAlarmViewHolder {
|
|||||||
private void createNewAlarmAndWriteToDb() {
|
private void createNewAlarmAndWriteToDb() {
|
||||||
final Alarm oldAlarm = getAlarm();
|
final Alarm oldAlarm = getAlarm();
|
||||||
Alarm newAlarm = Alarm.builder()
|
Alarm newAlarm = Alarm.builder()
|
||||||
.hour(oldAlarm.hour()/*TODO*/)
|
|
||||||
.minutes(oldAlarm.minutes()/*TODO*/)
|
|
||||||
.ringtone(""/*TODO*/)
|
.ringtone(""/*TODO*/)
|
||||||
.build();
|
.build();
|
||||||
oldAlarm.copyMutableFieldsTo(newAlarm);
|
oldAlarm.copyMutableFieldsTo(newAlarm);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user