Clear cache when updating profile

This commit is contained in:
stom79 2018-01-13 18:31:32 +01:00
parent 61ae0a086a
commit 7931623fa3
1 changed files with 20 additions and 0 deletions

View File

@ -18,6 +18,9 @@ package fr.gouv.etalab.mastodon.activities;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@ -64,6 +67,7 @@ import fr.gouv.etalab.mastodon.asynctasks.UpdateCredentialAsyncTask;
import fr.gouv.etalab.mastodon.client.APIResponse;
import fr.gouv.etalab.mastodon.client.Entities.Account;
import fr.gouv.etalab.mastodon.client.Entities.Error;
import fr.gouv.etalab.mastodon.client.Glide.GlideApp;
import fr.gouv.etalab.mastodon.helper.Helper;
import fr.gouv.etalab.mastodon.interfaces.OnRetrieveAccountInterface;
import fr.gouv.etalab.mastodon.interfaces.OnUpdateCredentialInterface;
@ -368,6 +372,13 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
@Override
public void onClick(DialogInterface dialog, int id) {
set_profile_save.setEnabled(false);
new Thread(new Runnable() {
@Override
public void run() {
GlideApp.get(getApplicationContext()).clearDiskCache();
}
}).start();
GlideApp.get(getApplicationContext()).clearMemory();
new UpdateCredentialAsyncTask(getApplicationContext(), profile_username, profile_note, profile_picture, header_picture, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
});
@ -475,6 +486,15 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
}
Toast.makeText(getApplicationContext(), R.string.toast_update_credential_ok, Toast.LENGTH_LONG).show();
set_profile_save.setEnabled(true);
Intent mStartActivity = new Intent(EditProfileActivity.this, BaseMainActivity.class);
int mPendingIntentId = 45641;
PendingIntent mPendingIntent = PendingIntent.getActivity(EditProfileActivity.this, mPendingIntentId, mStartActivity,
PendingIntent.FLAG_CANCEL_CURRENT);
AlarmManager mgr = (AlarmManager) EditProfileActivity.this.getSystemService(Context.ALARM_SERVICE);
assert mgr != null;
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 100, mPendingIntent);
System.exit(0);
finish();
}
}