Skip to content

Commit

Permalink
lastAutoLocationRequest
Browse files Browse the repository at this point in the history
modifies `lastAutoLocationRequest` so that it tolerates the wrong type (a Long as String because of #783).
  • Loading branch information
forrestguice committed Mar 15, 2024
1 parent 219c514 commit 087eb18
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,20 @@ public static long timeSinceLastAutoLocationRequest(Context context) {
public static long lastAutoLocationRequest(Context context)
{
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
return pref.getLong(PREF_KEY_LOCATION_TIME, 0);
long t = 0;
try {
t = pref.getLong(PREF_KEY_LOCATION_TIME, 0);

} catch (ClassCastException e) {
try {
t = Long.parseLong(pref.getString(PREF_KEY_LOCATION_TIME, "0"));
Log.w("lastAutoLocationRequest", "lastAutoLocationRequest has the wrong type! found Long as String.");

} catch (NumberFormatException | ClassCastException e1) {
Log.e("lastAutoLocationRequest", "Failed to get last auto location request time: " + e1);
}
}
return t;
}
public static void saveLastAutoLocationRequest(Context context, long value)
{
Expand Down

0 comments on commit 087eb18

Please sign in to comment.