Skip to content

Commit

Permalink
Hotfix time (older android versions
Browse files Browse the repository at this point in the history
  • Loading branch information
gsantner committed Sep 24, 2017
1 parent 17dd2f4 commit 40c64af
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand All @@ -98,6 +99,8 @@ public void run() {
new LoadAssetsThread(_context).start();
return;
}
} else {
return;
}
} catch (JSONException | ParseException e) {
e.printStackTrace();
Expand All @@ -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<Float>() {
public void onCallback(Float aFloat) {
if (_lastPercent != (int) (aFloat * 100)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/values/strings-not_translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
<string name="pref_key__thumbnail_quality__percent" translatable="false">pref_key__thumbnail_quality__percent</string>
<string name="pref_key__language" translatable="false">pref_key__language</string>
<string name="pref_key__save_directory" translatable="false">pref_key__save_directory</string>
<string name="pref_key__last_asset_archive_date" translatable="false">pref_key__last_asset_archive_date</string>
<string name="pref_key__last_asset_archive_check_date" translatable="false">pref_key__last_asset_archive_check_date</string>
<string name="pref_key__last_asset_archive_date" translatable="false">pref_key__last_asset_archive_date1</string>
<string name="pref_key__last_asset_archive_check_date" translatable="false">pref_key__last_asset_archive_check_date1</string>
<string name="pref_key__is_migrated" translatable="false">pref_key__is_migrated</string>
<string name="pref_key__download_assets_try" translatable="false">pref_key__download_assets_try</string>
</resources>

0 comments on commit 40c64af

Please sign in to comment.