Simple-Alarms icon indicating copy to clipboard operation
Simple-Alarms copied to clipboard

upon backpressing at addnewalarm fragment creating new record

Open shobhan1595 opened this issue 8 years ago • 6 comments

shobhan1595 avatar Mar 13 '18 11:03 shobhan1595

This is expected behaviour - pressing the "Add New Alarm" FAB creates a new Alarm and immediately takes you to its Edit page.

PPartisan avatar Jun 30 '18 19:06 PPartisan

Why is this happening btw?,.. Can you please tell me how to resolve it!

brittle123 avatar Feb 03 '21 12:02 brittle123

There's nothing to resolve - it's how the app works.

If you want to change that behaviour, you can modify AddEditAlarmActivity. You can see in there that it creates a new Alarm entry as soon as the FAB is pressed on the Alarms list page:

private Alarm getAlarm() {
        switch (getMode()) {
            case ADD_ALARM:
                final long id = DatabaseHelper.getInstance(this).addAlarm();
                LoadAlarmsService.launchLoadAlarmsService(this);
                return new Alarm(id);

You'll just need to defer this until the Alarm is saved.

PPartisan avatar Feb 03 '21 12:02 PPartisan

Sir really appreciate your quick response but don't know how to defer this... Please can you tell me what to change in AddEditAlarmActivity and AddEditAlarmFragment classes. Because when i commented this case lines it shows error in the AddEditAlarmFragment class . Waiting for your response. Thanks & Regards

brittle123 avatar Feb 04 '21 05:02 brittle123

You'll have to defer this code until the alarm is saved, means you'll have to create the Alarm instance in the save() function which actually saves the alarm..

smfahadhassan avatar Feb 04 '21 06:02 smfahadhassan

Thanks @smfahadhassan

brittle123 avatar Feb 04 '21 10:02 brittle123