mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
Abstract some parts of the AsyncTasks away into ProgressDialogTask
This commit is contained in:
parent
ca210de78e
commit
4f98d8764c
3 changed files with 40 additions and 30 deletions
34
app/src/main/java/me/impy/aegis/ProgressDialogTask.java
Normal file
34
app/src/main/java/me/impy/aegis/ProgressDialogTask.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package me.impy.aegis;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.CallSuper;
|
||||
|
||||
public abstract class ProgressDialogTask<Params, Result> extends AsyncTask<Params, Void, Result> {
|
||||
private ProgressDialog _dialog;
|
||||
|
||||
public ProgressDialogTask(Context context, String message) {
|
||||
_dialog = new ProgressDialog(context);
|
||||
_dialog.setCancelable(false);
|
||||
_dialog.setMessage(message);
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
_dialog.show();
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
@Override
|
||||
protected void onPostExecute(Result result) {
|
||||
if (_dialog.isShowing()) {
|
||||
_dialog.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
protected final ProgressDialog getDialog() {
|
||||
return _dialog;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue