Light and dark dialog themes
@ -0,0 +1,41 @@
|
||||
package org.tasks.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import org.tasks.R;
|
||||
import org.tasks.preferences.ActivityPreferences;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DialogBuilder {
|
||||
private Activity activity;
|
||||
private final ActivityPreferences activityPreferences;
|
||||
|
||||
@Inject
|
||||
public DialogBuilder(Activity activity, ActivityPreferences activityPreferences) {
|
||||
this.activity = activity;
|
||||
this.activityPreferences = activityPreferences;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder newDialog() {
|
||||
return new AlertDialog.Builder(activity, activityPreferences.getDialogTheme());
|
||||
}
|
||||
|
||||
public AlertDialog.Builder newMessageDialog(String message) {
|
||||
return newDialog().setMessage(message);
|
||||
}
|
||||
|
||||
public AlertDialog.Builder newMessageDialog(int message, Object... formatArgs) {
|
||||
return newMessageDialog(activity.getString(message, formatArgs));
|
||||
}
|
||||
|
||||
public ProgressDialog newProgressDialog() {
|
||||
ProgressDialog dialog = new ProgressDialog(activity, activityPreferences.getDialogTheme());
|
||||
dialog.setMessage(activity.getString(R.string.DLG_wait));
|
||||
dialog.setCancelable(false);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
return dialog;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package org.tasks.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.tasks.dialogs.DialogBuilder;
|
||||
|
||||
public abstract class ProgressDialogAsyncTask extends AsyncTask<Void, Void, Integer> {
|
||||
|
||||
ProgressDialog progressDialog;
|
||||
private Activity activity;
|
||||
private DialogBuilder dialogBuilder;
|
||||
|
||||
public ProgressDialogAsyncTask(Activity activity, DialogBuilder dialogBuilder) {
|
||||
this.activity = activity;
|
||||
this.dialogBuilder = dialogBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
progressDialog = dialogBuilder.newProgressDialog();
|
||||
progressDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer integer) {
|
||||
if (progressDialog.isShowing()) {
|
||||
progressDialog.dismiss();
|
||||
}
|
||||
|
||||
Toast.makeText(activity, activity.getString(getResultResource(), integer), Toast.LENGTH_LONG).show();
|
||||
|
||||
activity.finish();
|
||||
}
|
||||
|
||||
protected abstract int getResultResource();
|
||||
}
|
After Width: | Height: | Size: 135 B |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 181 B |
After Width: | Height: | Size: 206 B |
After Width: | Height: | Size: 245 B |
After Width: | Height: | Size: 283 B |
After Width: | Height: | Size: 122 B |
After Width: | Height: | Size: 133 B |