Postpone some actions

This commit is contained in:
Thomas 2020-08-11 15:38:54 +02:00
parent 8c7ccefc83
commit 8aad7a2679
1 changed files with 18 additions and 11 deletions

View File

@ -1324,6 +1324,7 @@ public abstract class BaseMainActivity extends BaseActivity
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new ManageFiltersAsyncTask(BaseMainActivity.this, GET_ALL_FILTER, null, BaseMainActivity.this).execute(); new ManageFiltersAsyncTask(BaseMainActivity.this, GET_ALL_FILTER, null, BaseMainActivity.this).execute();
} }
} }
/* Clean cache for statuses */ /* Clean cache for statuses */
@ -1333,21 +1334,27 @@ public abstract class BaseMainActivity extends BaseActivity
new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString); new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString);
}); });
if (Helper.isLoggedIn(BaseMainActivity.this)) { if (Helper.isLoggedIn(BaseMainActivity.this)) {
new UpdateAccountInfoByIDAsyncTask(BaseMainActivity.this, account, BaseMainActivity.this).execute(); final Handler handler = new Handler();
handler.postDelayed(() -> new UpdateAccountInfoByIDAsyncTask(BaseMainActivity.this, account, BaseMainActivity.this).execute(), 2000);
} }
mutedAccount = new TempMuteDAO(BaseMainActivity.this, db).getAllTimeMuted(account); mutedAccount = new TempMuteDAO(BaseMainActivity.this, db).getAllTimeMuted(account);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) { if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
new RetrieveFeedsAsyncTask(BaseMainActivity.this, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this).execute(); final Handler handler = new Handler();
if (BuildConfig.lite) { handler.postDelayed(() -> {
String datesupdate = sharedpreferences.getString(Helper.TRACKING_LAST_UPDATE, null); new RetrieveFeedsAsyncTask(BaseMainActivity.this, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this).execute();
Date dateLastUpdate = Helper.stringToDate(BaseMainActivity.this, datesupdate); if (BuildConfig.lite) {
Date dateUpdate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10)); String datesupdate = sharedpreferences.getString(Helper.TRACKING_LAST_UPDATE, null);
//Refresh tracking db if needed Date dateLastUpdate = Helper.stringToDate(BaseMainActivity.this, datesupdate);
if (datesupdate == null || dateUpdate.after(dateLastUpdate)) { Date dateUpdate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10));
Intent scriptIntent = new Intent(BaseMainActivity.this, DownloadTrackingDBScriptsService.class); //Refresh tracking db if needed
startService(scriptIntent); if (datesupdate == null || dateUpdate.after(dateLastUpdate)) {
Intent scriptIntent = new Intent(BaseMainActivity.this, DownloadTrackingDBScriptsService.class);
startService(scriptIntent);
}
} }
} }, 3000);
} }
} }