mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Remove HabitNotFound exception from WidgetPreferences
This commit is contained in:
@@ -390,9 +390,11 @@ public class Preferences
|
||||
putString(key, StringUtils.joinLongs(values));
|
||||
}
|
||||
|
||||
default long[] getLongArray(String key)
|
||||
default long[] getLongArray(String key, long[] defValue)
|
||||
{
|
||||
return StringUtils.splitLongs(getString(key, ""));
|
||||
String string = getString(key, "");
|
||||
if (string.isEmpty()) return defValue;
|
||||
else return StringUtils.splitLongs(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ public class WidgetPreferences {
|
||||
}
|
||||
|
||||
public long[] getHabitIdsFromWidgetId(int widgetId) {
|
||||
long habitIds[];
|
||||
long[] habitIds;
|
||||
String habitIdKey = getHabitIdKey(widgetId);
|
||||
try {
|
||||
habitIds = storage.getLongArray(habitIdKey);
|
||||
habitIds = storage.getLongArray(habitIdKey, new long[]{-1});
|
||||
} catch (ClassCastException e) {
|
||||
// Up to Loop 1.7.11, this preference was not an array, but a single
|
||||
// long. Trying to read the old preference causes a cast exception.
|
||||
@@ -49,7 +49,6 @@ public class WidgetPreferences {
|
||||
habitIds[0] = storage.getLong(habitIdKey, -1);
|
||||
storage.putLongArray(habitIdKey, habitIds);
|
||||
}
|
||||
if (habitIds.length == 0) throw new HabitNotFoundException();
|
||||
return habitIds;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user