mirror of https://github.com/tasks/tasks
Remove ProgressDialogAsyncTask
parent
bf3c7c2c78
commit
4ed4d62ec9
@ -1,43 +0,0 @@
|
|||||||
package org.tasks.ui;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.ProgressDialog;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.widget.Toast;
|
|
||||||
import org.tasks.R;
|
|
||||||
import org.tasks.dialogs.DialogBuilder;
|
|
||||||
import timber.log.Timber;
|
|
||||||
|
|
||||||
public abstract class ProgressDialogAsyncTask extends AsyncTask<Void, Void, Integer> {
|
|
||||||
|
|
||||||
private final Activity activity;
|
|
||||||
private final DialogBuilder dialogBuilder;
|
|
||||||
private ProgressDialog progressDialog;
|
|
||||||
|
|
||||||
public ProgressDialogAsyncTask(Activity activity, DialogBuilder dialogBuilder) {
|
|
||||||
this.activity = activity;
|
|
||||||
this.dialogBuilder = dialogBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreExecute() {
|
|
||||||
progressDialog = dialogBuilder.newProgressDialog(R.string.DLG_wait);
|
|
||||||
progressDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPostExecute(Integer integer) {
|
|
||||||
if (progressDialog.isShowing()) {
|
|
||||||
try {
|
|
||||||
progressDialog.dismiss();
|
|
||||||
} catch (Exception e) {
|
|
||||||
Timber.e(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Toast.makeText(activity, activity.getString(getResultResource(), integer), Toast.LENGTH_LONG)
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract int getResultResource();
|
|
||||||
}
|
|
@ -0,0 +1,33 @@
|
|||||||
|
package org.tasks.ui;
|
||||||
|
|
||||||
|
import static android.widget.Toast.LENGTH_LONG;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.Toast;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import org.tasks.injection.ForActivity;
|
||||||
|
import org.tasks.locale.Locale;
|
||||||
|
|
||||||
|
public class Toaster {
|
||||||
|
|
||||||
|
private final Context context;
|
||||||
|
private final Locale locale;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public Toaster(@ForActivity Context context, Locale locale) {
|
||||||
|
this.context = context;
|
||||||
|
this.locale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void longToast(@StringRes int resId, int number) {
|
||||||
|
Toast.makeText(context, context.getString(resId, locale.formatNumber(number)), LENGTH_LONG)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
@Deprecated
|
||||||
|
public void longToastUnformatted(@StringRes int resId, int number) {
|
||||||
|
Toast.makeText(context, context.getString(resId, number), LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue