package com.securecomcode.text.util; import android.app.ProgressDialog; import android.content.Context; import android.os.AsyncTask; public abstract class ProgressDialogAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> { private final Context context; private ProgressDialog progress; private final String title; private final String message; public ProgressDialogAsyncTask(Context context, String title, String message) { super(); this.context = context; this.title = title; this.message = message; } public ProgressDialogAsyncTask(Context context, int title, int message) { this(context, context.getString(title), context.getString(message)); } @Override protected void onPreExecute() { progress = ProgressDialog.show(context, title, message, true); } @Override protected void onPostExecute(Result result) { if (progress != null) progress.dismiss(); } }