mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01:00
Fix alarm corruption after user configured an alarm further down the list, leaving an unconfigured alarm in between configured alarms
This was not fixable though the UI, this commit also heals already corrupted configurations Fixes #1419
This commit is contained in:
parent
92e92ae792
commit
fd15478a7a
@ -115,8 +115,18 @@ public class ConfigureAlarms extends AbstractGBActivity {
|
||||
DaoSession daoSession = db.getDaoSession();
|
||||
Device device = DBHelper.getDevice(getGbDevice(), daoSession);
|
||||
User user = DBHelper.getUser(daoSession);
|
||||
while (supportedNumAlarms > alarms.size()) {
|
||||
alarms.add(createDefaultAlarm(device, user, alarms.size()));
|
||||
for (int position = 0; position < supportedNumAlarms; position++) {
|
||||
boolean found = false;
|
||||
for (Alarm alarm : alarms) {
|
||||
if (alarm.getPosition() == position) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
LOG.info("adding missing alarm at position " + position);
|
||||
alarms.add(position, createDefaultAlarm(device, user, position));
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error accessing database", e);
|
||||
|
Loading…
Reference in New Issue
Block a user