From f17f174b49e9bef61e10d399d7f5c33fbe89aaa5 Mon Sep 17 00:00:00 2001 From: Mathis Dirksen-Thedens Date: Wed, 27 Dec 2023 19:45:43 +0100 Subject: [PATCH] make sure the report selection is not empty --- .../trackworktime/ReportsActivity.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/org/zephyrsoft/trackworktime/ReportsActivity.java b/app/src/main/java/org/zephyrsoft/trackworktime/ReportsActivity.java index acbac9f4..88f0ae17 100644 --- a/app/src/main/java/org/zephyrsoft/trackworktime/ReportsActivity.java +++ b/app/src/main/java/org/zephyrsoft/trackworktime/ReportsActivity.java @@ -124,24 +124,28 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { private void restoreSelectionState() { int rangeId = loadSelectedId(Key.REPORT_LAST_RANGE); - checkRadioGroup(binding.range, rangeId); + checkRadioGroup(binding.range, rangeId, R.id.rangeLast); int unitId = loadSelectedId(Key.REPORT_LAST_UNIT); - checkRadioGroup(binding.unit, unitId); + checkRadioGroup(binding.unit, unitId, R.id.unitWeek); int groupingId = loadSelectedId(Key.REPORT_LAST_GROUPING); - checkRadioGroup(binding.grouping, groupingId); + checkRadioGroup(binding.grouping, groupingId, R.id.groupingNone); } private int loadSelectedId(Key key) { return preferences.getInt(key.getName(), NO_ID); } - private void checkRadioGroup(RadioGroup group, int idToCheck) { - if (idToCheck == NO_ID || group.findViewById(idToCheck) == null) { + private void checkRadioGroup(RadioGroup group, int idToCheck, int backupIdToCheck) { + if (group.findViewById(idToCheck) == null) { return; } - group.check(idToCheck); + if (idToCheck == NO_ID) { + group.check(backupIdToCheck); + } else { + group.check(idToCheck); + } } private void preview() {