From 40c64afe38afc45e2ebb42e8b0c1a33f384c2636 Mon Sep 17 00:00:00 2001 From: Gregor Santner Date: Sun, 24 Sep 2017 11:51:59 +0200 Subject: [PATCH] Hotfix time (older android versions --- .../github/gsantner/memetastic/service/AssetUpdater.java | 9 ++++++--- .../io/github/gsantner/memetastic/util/AppSettings.java | 8 ++++---- app/src/main/res/values/strings-not_translatable.xml | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/github/gsantner/memetastic/service/AssetUpdater.java b/app/src/main/java/io/github/gsantner/memetastic/service/AssetUpdater.java index b755a74b1..48138f3df 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/service/AssetUpdater.java +++ b/app/src/main/java/io/github/gsantner/memetastic/service/AssetUpdater.java @@ -34,7 +34,7 @@ @SuppressLint("SimpleDateFormat") public class AssetUpdater { - public static final SimpleDateFormat FORMAT_RFC3339 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); + public static final SimpleDateFormat FORMAT_MINUTE = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); private static final String URL_ARCHIVE_ZIP = "https://github.com/gsantner/memetastic-assets/archive/master.zip"; private static final String URL_API = "https://api.github.com/repos/gsantner/memetastic-assets"; @@ -87,7 +87,8 @@ public void run() { try { JSONObject apiJson = new JSONObject(apiJsonS); String lastUpdate = apiJson.getString("pushed_at"); - Date date = FORMAT_RFC3339.parse(lastUpdate); + int datesubstrindex = lastUpdate.indexOf(":", lastUpdate.indexOf(":") + 1); + Date date = FORMAT_MINUTE.parse(lastUpdate.substring(0, datesubstrindex)); if (date.after(_appSettings.getLastAssetArchiveDate())) { _appSettings.setLastArchiveCheckDate(new Date(System.currentTimeMillis())); if (!_doDownload) { @@ -98,6 +99,8 @@ public void run() { new LoadAssetsThread(_context).start(); return; } + } else { + return; } } catch (JSONException | ParseException e) { e.printStackTrace(); @@ -120,7 +123,7 @@ private synchronized void doDownload(Date date) throws ParseException { FileUtils.deleteRecursive(file); boolean ok; if (file.mkdirs() && (templatesDir.exists() || templatesDir.mkdirs())) { - file = new File(file, FORMAT_RFC3339.format(date) + ".memetastic.zip"); + file = new File(file, FORMAT_MINUTE.format(date) + ".memetastic.zip"); ok = NetworkUtils.downloadFile(URL_ARCHIVE_ZIP, file, new Callback() { public void onCallback(Float aFloat) { if (_lastPercent != (int) (aFloat * 100)) { diff --git a/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java b/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java index 7d245c641..105e36410 100644 --- a/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java +++ b/app/src/main/java/io/github/gsantner/memetastic/util/AppSettings.java @@ -238,11 +238,11 @@ public Date getLastAssetArchiveDate() throws ParseException { if (date.isEmpty()) { return new Date(0); } - return AssetUpdater.FORMAT_RFC3339.parse(date); + return AssetUpdater.FORMAT_MINUTE.parse(date); } public void setLastArchiveCheckDate(Date value) { - setString(R.string.pref_key__last_asset_archive_check_date, AssetUpdater.FORMAT_RFC3339.format(value)); + setString(R.string.pref_key__last_asset_archive_check_date, AssetUpdater.FORMAT_MINUTE.format(value)); } public Date getLastAssetArchiveCheckDate() { @@ -251,14 +251,14 @@ public Date getLastAssetArchiveCheckDate() { return new Date(0); } try { - return AssetUpdater.FORMAT_RFC3339.parse(date); + return AssetUpdater.FORMAT_MINUTE.parse(date); } catch (ParseException e) { return new Date(0); } } public void setLastArchiveDate(Date value) { - setString(R.string.pref_key__last_asset_archive_date, AssetUpdater.FORMAT_RFC3339.format(value)); + setString(R.string.pref_key__last_asset_archive_date, AssetUpdater.FORMAT_MINUTE.format(value)); } public boolean isMigrated() { diff --git a/app/src/main/res/values/strings-not_translatable.xml b/app/src/main/res/values/strings-not_translatable.xml index 2577408f6..ac0c4021d 100644 --- a/app/src/main/res/values/strings-not_translatable.xml +++ b/app/src/main/res/values/strings-not_translatable.xml @@ -68,8 +68,8 @@ pref_key__thumbnail_quality__percent pref_key__language pref_key__save_directory - pref_key__last_asset_archive_date - pref_key__last_asset_archive_check_date + pref_key__last_asset_archive_date1 + pref_key__last_asset_archive_check_date1 pref_key__is_migrated pref_key__download_assets_try