forked from organicmaps/organicmaps
[android] Simplify some routines.
This commit is contained in:
parent
ebf96d00d2
commit
56e229c257
2 changed files with 14 additions and 22 deletions
|
@ -134,23 +134,19 @@ public class WorkerService extends IntentService
|
|||
{
|
||||
final SharedPreferences prefs = getApplicationContext().
|
||||
getSharedPreferences(getApplicationContext().getString(R.string.pref_file_name), Context.MODE_PRIVATE);
|
||||
final String lastNotification = prefs.getString(country, "");
|
||||
boolean shouldPlaceNotification = false; // should place notification only if it wasnt displayed for 180 days at least
|
||||
if (lastNotification.equals(""))
|
||||
shouldPlaceNotification = true;
|
||||
else
|
||||
final String lastNotification = prefs.getString(country, null);
|
||||
if (lastNotification != null)
|
||||
{
|
||||
// Do not place notification if it was displayed less than 180 days ago.
|
||||
final long timeStamp = Long.valueOf(lastNotification);
|
||||
final long outdatedMillis = 180L * 24 * 60 * 60 * 1000; // half of year
|
||||
if (System.currentTimeMillis() - timeStamp > outdatedMillis)
|
||||
shouldPlaceNotification = true;
|
||||
}
|
||||
if (shouldPlaceNotification)
|
||||
{
|
||||
Notifier.placeDownloadSuggest(country, String.format(getApplicationContext().getString(R.string.download_location_country), country),
|
||||
Framework.nativeGetCountryIndex(l.getLatitude(), l.getLongitude()));
|
||||
prefs.edit().putString(country, String.valueOf(System.currentTimeMillis())).commit();
|
||||
final long outdatedMillis = 180L * 24 * 60 * 60 * 1000;
|
||||
if (System.currentTimeMillis() - timeStamp < outdatedMillis)
|
||||
return;
|
||||
}
|
||||
|
||||
Notifier.placeDownloadSuggest(country, String.format(getApplicationContext().getString(R.string.download_location_country), country),
|
||||
Framework.nativeGetCountryIndex(l.getLatitude(), l.getLongitude()));
|
||||
prefs.edit().putString(country, String.valueOf(System.currentTimeMillis())).commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,13 +25,9 @@ public class Event
|
|||
@Override
|
||||
public String toString()
|
||||
{
|
||||
final StringBuilder sb = new StringBuilder(getClass().getSimpleName());
|
||||
sb.append("[name = ")
|
||||
.append(getName())
|
||||
.append(", params: ")
|
||||
.append(Utils.mapPrettyPrint(getParams()))
|
||||
.append("]");
|
||||
return sb.toString();
|
||||
return (getClass().getSimpleName() +
|
||||
"[name = " + getName() +
|
||||
", params: " + Utils.mapPrettyPrint(getParams()) +
|
||||
"]");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue