Refactoring

pull/147/head
M66B 7 years ago
parent 9ab964e659
commit 7ffb44f292

@ -397,7 +397,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) {
protected Long onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
db.message().resetSearch();
@ -409,7 +409,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
@Override
protected void onLoaded(Bundle args, Long archive) {
protected void onExecuted(Bundle args, Long archive) {
Bundle sargs = new Bundle();
sargs.putLong("folder", archive);
sargs.putString("search", args.getString("search"));
@ -426,7 +426,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(ActivityView.this, args);
}.execute(ActivityView.this, args);
} else {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
@ -554,7 +554,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void checkCrash() {
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) throws Throwable {
protected Long onExecute(Context context, Bundle args) throws Throwable {
File file = new File(context.getCacheDir(), "crash.log");
if (file.exists()) {
StringBuilder sb = new StringBuilder();
@ -580,7 +580,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
@Override
protected void onLoaded(Bundle args, Long id) {
protected void onExecuted(Bundle args, Long id) {
if (id != null)
startActivity(
new Intent(ActivityView.this, ActivityCompose.class)
@ -595,7 +595,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
else
Toast.makeText(ActivityView.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}.load(this, new Bundle());
}.execute(this, new Bundle());
}
private class UpdateInfo {
@ -614,7 +614,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new SimpleTask<UpdateInfo>() {
@Override
protected UpdateInfo onLoad(Context context, Bundle args) throws Throwable {
protected UpdateInfo onExecute(Context context, Bundle args) throws Throwable {
StringBuilder json = new StringBuilder();
HttpsURLConnection urlConnection = null;
try {
@ -666,7 +666,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
@Override
protected void onLoaded(Bundle args, UpdateInfo info) {
protected void onExecuted(Bundle args, UpdateInfo info) {
if (info == null)
return;
@ -688,7 +688,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
if (BuildConfig.DEBUG)
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(this, new Bundle());
}.execute(this, new Bundle());
}
private void updateShortcuts() {
@ -820,13 +820,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) {
protected Long onExecute(Context context, Bundle args) {
long account = args.getLong("account");
return DB.getInstance(context).folder().getFolderByType(account, EntityFolder.INBOX).id;
}
@Override
protected void onLoaded(Bundle args, Long folder) {
protected void onExecuted(Bundle args, Long folder) {
long account = args.getLong("account");
getSupportFragmentManager().popBackStack("unified", 0);
@ -842,7 +842,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(this, args);
}.execute(this, args);
}
private void onMenuSetup() {
@ -925,12 +925,12 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
private void onDebugInfo() {
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) throws IOException {
protected Long onExecute(Context context, Bundle args) throws IOException {
return Helper.getDebugInfo(context, R.string.title_debug_info_remark, null, null).id;
}
@Override
protected void onLoaded(Bundle args, Long id) {
protected void onExecuted(Bundle args, Long id) {
startActivity(new Intent(ActivityView.this, ActivityCompose.class)
.putExtra("action", "edit")
.putExtra("id", id));
@ -944,13 +944,13 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
Toast.makeText(ActivityView.this, ex.toString(), Toast.LENGTH_LONG).show();
}
}.load(this, new Bundle());
}.execute(this, new Bundle());
}
private void onCleanup() {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
JobDaily.cleanup(ActivityView.this);
return null;
}
@ -959,7 +959,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(this, new Bundle());
}.execute(this, new Bundle());
}
private void onShowLog() {
@ -1188,7 +1188,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new SimpleTask<PendingIntent>() {
@Override
protected PendingIntent onLoad(Context context, Bundle args) throws Throwable {
protected PendingIntent onExecute(Context context, Bundle args) throws Throwable {
// Get arguments
long id = args.getLong("id");
Intent data = args.getParcelable("data");
@ -1308,7 +1308,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
@Override
protected void onLoaded(Bundle args, PendingIntent pi) {
protected void onExecuted(Bundle args, PendingIntent pi) {
if (pi != null)
try {
Log.i("PGP executing pi=" + pi);
@ -1329,7 +1329,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
else
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(ActivityView.this, args);
}.execute(ActivityView.this, args);
}
@Override
@ -1343,7 +1343,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
Uri uri = args.getParcelable("uri");
@ -1389,7 +1389,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
Toast.makeText(ActivityView.this, R.string.title_attachment_saved, Toast.LENGTH_LONG).show();
}
@ -1400,7 +1400,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
else
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(this, args);
}.execute(this, args);
}
} else if (requestCode == REQUEST_DECRYPT) {
if (data != null)

@ -145,7 +145,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB.getInstance(context).attachment().deleteAttachment(attachment.id);
EntityAttachment.getFile(context, attachment.id).delete();
return null;
@ -155,7 +155,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
} else if (view.getId() == R.id.ivSave) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
@ -239,7 +239,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
long message = args.getLong("message");
long sequence = args.getInt("sequence");
@ -265,7 +265,7 @@ public class AdapterAttachment extends RecyclerView.Adapter<AdapterAttachment.Vi
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
}
}

@ -262,7 +262,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
new SimpleTask<Boolean>() {
@Override
protected Boolean onLoad(Context context, Bundle args) {
protected Boolean onExecute(Context context, Bundle args) {
long aid = args.getLong("account");
long fid = args.getLong("folder");
@ -276,7 +276,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
}
@Override
protected void onLoaded(Bundle args, Boolean connected) {
protected void onExecuted(Bundle args, Boolean connected) {
if (!connected)
Snackbar.make(itemView, R.string.title_sync_queued, Snackbar.LENGTH_LONG).show();
}
@ -285,7 +285,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void OnActionDeleteLocal() {
@ -295,7 +295,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean outbox = args.getBoolean("outbox");
Log.i("Delete local messages outbox=" + outbox);
@ -310,7 +310,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
public void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void onActionEmptyTrash() {
@ -325,7 +325,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -349,7 +349,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
})
.setNegativeButton(android.R.string.cancel, null)

@ -363,7 +363,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Drawable>() {
@Override
protected Drawable onLoad(Context context, Bundle args) {
protected Drawable onExecute(Context context, Bundle args) {
String uri = args.getString("uri");
if (avatars && !outgoing && uri != null)
try {
@ -386,7 +386,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onLoaded(Bundle args, Drawable avatar) {
protected void onExecuted(Bundle args, Drawable avatar) {
if (avatar != null) {
if ((long) ivAvatar.getTag() == args.getLong("id")) {
ivAvatar.setImageDrawable(avatar);
@ -400,7 +400,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, aargs);
}.execute(context, owner, aargs);
} else
ivAvatar.setVisibility(View.GONE);
@ -560,7 +560,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (body == null && message.content) {
Bundle args = new Bundle();
args.putSerializable("message", message);
bodyTask.load(context, owner, args);
bodyTask.execute(context, owner, args);
}
// Observe attachments
@ -584,7 +584,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message.content) {
Bundle args = new Bundle();
args.putSerializable("message", message);
bodyTask.load(context, owner, args);
bodyTask.execute(context, owner, args);
}
}
};
@ -597,23 +597,23 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<List<EntityFolder>>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
bnvActions.setHasTransientState(true);
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
bnvActions.setHasTransientState(false);
}
@Override
protected List<EntityFolder> onLoad(Context context, Bundle args) {
protected List<EntityFolder> onExecute(Context context, Bundle args) {
long account = args.getLong("account");
return DB.getInstance(context).folder().getSystemFolders(account);
}
@Override
protected void onLoaded(Bundle args, List<EntityFolder> folders) {
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
boolean hasJunk = false;
boolean hasTrash = false;
boolean hasArchive = false;
@ -654,7 +654,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, sargs);
}.execute(context, owner, sargs);
} else
properties.setBody(message.id, null);
@ -812,7 +812,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Bundle args = new Bundle();
args.putSerializable("message", message);
bodyTask.load(context, owner, args);
bodyTask.execute(context, owner, args);
}
private void onShowImages(final TupleMessageEx message) {
@ -837,14 +837,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Bundle args = new Bundle();
args.putSerializable("message", message);
bodyTask.load(context, owner, args);
bodyTask.execute(context, owner, args);
}
private SimpleTask<SpannableStringBuilder> bodyTask = new SimpleTask<SpannableStringBuilder>() {
private String body = null;
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
btnHtml.setHasTransientState(true);
ibQuotes.setHasTransientState(true);
ibImages.setHasTransientState(true);
@ -853,7 +853,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
btnHtml.setHasTransientState(false);
ibQuotes.setHasTransientState(false);
ibImages.setHasTransientState(false);
@ -862,7 +862,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected SpannableStringBuilder onLoad(Context context, final Bundle args) {
protected SpannableStringBuilder onExecute(Context context, final Bundle args) {
DB db = DB.getInstance(context);
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
if (body == null)
@ -916,7 +916,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onLoaded(Bundle args, SpannableStringBuilder body) {
protected void onExecuted(Bundle args, SpannableStringBuilder body) {
TupleMessageEx message = (TupleMessageEx) args.getSerializable("message");
boolean has_quotes = (body.getSpans(0, body.length(), StyledQuoteSpan.class).length > 0);
@ -1060,7 +1060,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -1083,7 +1083,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -1096,7 +1096,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Boolean>() {
@Override
protected Boolean onLoad(Context context, Bundle args) {
protected Boolean onExecute(Context context, Bundle args) {
long id = args.getLong("id");
List<EntityAttachment> attachments = DB.getInstance(context).attachment().getAttachments(id);
for (EntityAttachment attachment : attachments)
@ -1106,7 +1106,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onLoaded(Bundle args, Boolean available) {
protected void onExecuted(Bundle args, Boolean available) {
final Intent forward = new Intent(context, ActivityCompose.class)
.putExtra("action", "forward")
.putExtra("reference", data.message.id)
@ -1130,18 +1130,18 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void onAnswer(final ActionData data) {
new SimpleTask<List<EntityAnswer>>() {
@Override
protected List<EntityAnswer> onLoad(Context context, Bundle args) {
protected List<EntityAnswer> onExecute(Context context, Bundle args) {
return DB.getInstance(context).answer().getAnswers();
}
@Override
protected void onLoaded(Bundle args, List<EntityAnswer> answers) {
protected void onExecuted(Bundle args, List<EntityAnswer> answers) {
if (answers == null || answers.size() == 0) {
Snackbar snackbar = Snackbar.make(
itemView,
@ -1198,7 +1198,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, new Bundle());
}.execute(context, owner, new Bundle());
}
private void onUnseen(final ActionData data) {
@ -1207,7 +1207,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -1226,7 +1226,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onLoaded(Bundle args, Void ignored) {
protected void onExecuted(Bundle args, Void ignored) {
properties.setValue("expanded", data.message.id, false);
notifyDataSetChanged();
}
@ -1235,7 +1235,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void onToggleFlag(TupleMessageEx message) {
@ -1247,7 +1247,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean flagged = args.getBoolean("flagged");
boolean thread = args.getBoolean("thread");
@ -1266,7 +1266,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void onShowHeaders(ActionData data) {
@ -1284,7 +1284,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
Long id = args.getLong("id");
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(id);
@ -1296,7 +1296,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
} else
notifyDataSetChanged();
}
@ -1313,13 +1313,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<EntityFolder>() {
@Override
protected EntityFolder onLoad(Context context, Bundle args) {
protected EntityFolder onExecute(Context context, Bundle args) {
EntityMessage message = (EntityMessage) args.getSerializable("message");
return DB.getInstance(context).folder().getFolder(message.folder);
}
@Override
protected void onLoaded(final Bundle args, EntityFolder folder) {
protected void onExecuted(final Bundle args, EntityFolder folder) {
EntityMessage message = (EntityMessage) args.getSerializable("message");
List<String> keywords = Arrays.asList(message.keywords);
@ -1355,7 +1355,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
EntityMessage message = (EntityMessage) args.getSerializable("message");
String[] keywords = args.getStringArray("keywords");
boolean[] selected = args.getBooleanArray("selected");
@ -1382,7 +1382,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
})
.setNeutralButton(R.string.title_add, new DialogInterface.OnClickListener() {
@ -1402,7 +1402,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
EntityMessage message = (EntityMessage) args.getSerializable("message");
String keyword = args.getString("keyword");
@ -1416,7 +1416,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
}
}).show();
@ -1429,7 +1429,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void onDecrypt(ActionData data) {
@ -1516,7 +1516,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -1547,7 +1547,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -1562,7 +1562,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<List<EntityFolder>>() {
@Override
protected List<EntityFolder> onLoad(Context context, Bundle args) {
protected List<EntityFolder> onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
EntityMessage message = db.message().getMessage(args.getLong("id"));
@ -1583,7 +1583,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onLoaded(final Bundle args, List<EntityFolder> folders) {
protected void onExecuted(final Bundle args, List<EntityFolder> folders) {
View anchor = bnvActions.findViewById(R.id.action_move);
PopupMenu popupMenu = new PopupMenu(context, anchor);
@ -1598,13 +1598,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<String>() {
@Override
protected String onLoad(Context context, Bundle args) {
protected String onExecute(Context context, Bundle args) {
long target = args.getLong("target");
return DB.getInstance(context).folder().getFolder(target).name;
}
@Override
protected void onLoaded(Bundle args, String folderName) {
protected void onExecuted(Bundle args, String folderName) {
long id = args.getLong("id");
properties.move(id, folderName, false);
}
@ -1613,7 +1613,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
return true;
}
@ -1626,7 +1626,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
private void onArchive(ActionData data) {
@ -1639,7 +1639,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
new SimpleTask<Boolean>() {
@Override
protected Boolean onLoad(Context context, Bundle args) {
protected Boolean onExecute(Context context, Bundle args) {
long id = args.getLong("id");
List<EntityAttachment> attachments = DB.getInstance(context).attachment().getAttachments(id);
for (EntityAttachment attachment : attachments)
@ -1649,7 +1649,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
@Override
protected void onLoaded(Bundle args, Boolean available) {
protected void onExecuted(Bundle args, Boolean available) {
final Intent reply = new Intent(context, ActivityCompose.class)
.putExtra("action", all ? "reply_all" : "reply")
.putExtra("reference", data.message.id);
@ -1672,7 +1672,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
ItemDetailsLookup.ItemDetails<Long> getItemDetails(@NonNull MotionEvent motionEvent) {

@ -108,13 +108,13 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
new SimpleTask<EntityFolder>() {
@Override
protected EntityFolder onLoad(Context context, Bundle args) {
protected EntityFolder onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return DB.getInstance(context).folder().getFolder(id);
}
@Override
protected void onLoaded(Bundle args, EntityFolder folder) {
protected void onExecuted(Bundle args, EntityFolder folder) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_MESSAGES)
@ -127,20 +127,20 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
} else {
Bundle args = new Bundle();
args.putLong("id", operation.message);
new SimpleTask<EntityMessage>() {
@Override
protected EntityMessage onLoad(Context context, Bundle args) {
protected EntityMessage onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return DB.getInstance(context).message().getMessage(id);
}
@Override
protected void onLoaded(Bundle args, EntityMessage message) {
protected void onExecuted(Bundle args, EntityMessage message) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(
new Intent(ActivityView.ACTION_VIEW_THREAD)
@ -153,7 +153,7 @@ public class AdapterOperation extends RecyclerView.Adapter<AdapterOperation.View
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(context, owner, ex);
}
}.load(context, owner, args);
}.execute(context, owner, args);
}
}
}

@ -266,25 +266,25 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<Provider>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
etDomain.setEnabled(false);
btnAutoConfig.setEnabled(false);
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
etDomain.setEnabled(true);
btnAutoConfig.setEnabled(true);
}
@Override
protected Provider onLoad(Context context, Bundle args) throws Throwable {
protected Provider onExecute(Context context, Bundle args) throws Throwable {
String domain = args.getString("domain");
return Provider.fromDomain(context, domain);
}
@Override
protected void onLoaded(Bundle args, Provider provider) {
protected void onExecuted(Bundle args, Provider provider) {
etHost.setText(provider.imap_host);
etPort.setText(Integer.toString(provider.imap_port));
cbStartTls.setChecked(provider.imap_starttls);
@ -297,7 +297,7 @@ public class FragmentAccount extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentAccount.this, args);
}.execute(FragmentAccount.this, args);
}
});
@ -426,7 +426,7 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<CheckResult>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
Helper.setViewsEnabled(view, false);
btnAuthorize.setEnabled(false);
btnCheck.setEnabled(false);
@ -438,7 +438,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
Helper.setViewsEnabled(view, true);
btnAuthorize.setEnabled(true);
btnCheck.setEnabled(true);
@ -446,7 +446,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected CheckResult onLoad(Context context, Bundle args) throws Throwable {
protected CheckResult onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
String host = args.getString("host");
boolean starttls = args.getBoolean("starttls");
@ -533,7 +533,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, CheckResult result) {
protected void onExecuted(Bundle args, CheckResult result) {
tvIdle.setVisibility(result.idle ? View.GONE : View.VISIBLE);
setFolders(result.folders);
@ -564,7 +564,7 @@ public class FragmentAccount extends FragmentEx {
});
}
}
}.load(FragmentAccount.this, args);
}.execute(FragmentAccount.this, args);
}
});
@ -619,7 +619,7 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
Helper.setViewsEnabled(view, false);
btnAuthorize.setEnabled(false);
btnCheck.setEnabled(false);
@ -629,7 +629,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
Helper.setViewsEnabled(view, true);
btnAuthorize.setEnabled(true);
btnCheck.setEnabled(true);
@ -638,7 +638,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
int auth_type = args.getInt("auth_type");
@ -846,7 +846,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@ -865,7 +865,7 @@ public class FragmentAccount extends FragmentEx {
});
}
}
}.load(FragmentAccount.this, args);
}.execute(FragmentAccount.this, args);
}
});
@ -926,13 +926,13 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<EntityAccount>() {
@Override
protected EntityAccount onLoad(Context context, Bundle args) {
protected EntityAccount onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return DB.getInstance(context).account().getAccount(id);
}
@Override
protected void onLoaded(Bundle args, EntityAccount account) {
protected void onExecuted(Bundle args, EntityAccount account) {
// Get providers
List<Provider> providers = Provider.loadProfiles(getContext());
providers.add(0, new Provider(getString(R.string.title_select)));
@ -984,12 +984,12 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<EntityAccount>() {
@Override
protected EntityAccount onLoad(Context context, Bundle args) {
protected EntityAccount onExecute(Context context, Bundle args) {
return DB.getInstance(context).account().getPrimaryAccount();
}
@Override
protected void onLoaded(Bundle args, EntityAccount primary) {
protected void onExecuted(Bundle args, EntityAccount primary) {
if (primary == null)
cbPrimary.setChecked(true);
}
@ -998,7 +998,7 @@ public class FragmentAccount extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentAccount.this, new Bundle());
}.execute(FragmentAccount.this, new Bundle());
} else {
int provider = savedInstanceState.getInt("provider");
spProvider.setTag(provider);
@ -1022,13 +1022,13 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<List<EntityFolder>>() {
@Override
protected List<EntityFolder> onLoad(Context context, Bundle args) {
protected List<EntityFolder> onExecute(Context context, Bundle args) {
long account = args.getLong("account");
return DB.getInstance(context).folder().getFolders(account);
}
@Override
protected void onLoaded(Bundle args, List<EntityFolder> folders) {
protected void onExecuted(Bundle args, List<EntityFolder> folders) {
if (folders == null)
folders = new ArrayList<>();
setFolders(folders);
@ -1038,14 +1038,14 @@ public class FragmentAccount extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentAccount.this, args);
}.execute(FragmentAccount.this, args);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
@Override
@ -1088,7 +1088,7 @@ public class FragmentAccount extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -1100,7 +1100,7 @@ public class FragmentAccount extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@ -1108,7 +1108,7 @@ public class FragmentAccount extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentAccount.this, args);
}.execute(FragmentAccount.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null)

@ -107,13 +107,13 @@ public class FragmentAnswer extends FragmentEx {
new SimpleTask<EntityAnswer>() {
@Override
protected EntityAnswer onLoad(Context context, Bundle args) throws Throwable {
protected EntityAnswer onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
return DB.getInstance(context).answer().getAnswer(id);
}
@Override
protected void onLoaded(Bundle args, EntityAnswer answer) {
protected void onExecuted(Bundle args, EntityAnswer answer) {
etName.setText(answer == null ? null : answer.name);
etText.setText(answer == null ? null : Html.fromHtml(answer.text));
bottom_navigation.findViewById(R.id.action_delete).setVisibility(answer == null ? View.GONE : View.VISIBLE);
@ -126,7 +126,7 @@ public class FragmentAnswer extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
private void onActionTrash() {
@ -142,14 +142,14 @@ public class FragmentAnswer extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB.getInstance(context).answer().deleteAnswer(id);
return null;
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
finish();
}
@ -158,7 +158,7 @@ public class FragmentAnswer extends FragmentEx {
Helper.setViewsEnabled(view, true);
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentAnswer.this, args);
}.execute(FragmentAnswer.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -175,7 +175,7 @@ public class FragmentAnswer extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
String name = args.getString("name");
String text = args.getString("text");
@ -197,7 +197,7 @@ public class FragmentAnswer extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
finish();
}
@ -206,7 +206,7 @@ public class FragmentAnswer extends FragmentEx {
Helper.setViewsEnabled(view, true);
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
private void handleExit() {

@ -462,7 +462,7 @@ public class FragmentCompose extends FragmentEx {
args.putString("subject", getArguments().getString("subject"));
args.putString("body", getArguments().getString("body"));
args.putParcelableArrayList("attachments", getArguments().getParcelableArrayList("attachments"));
draftLoader.load(this, args);
draftLoader.execute(this, args);
} else {
Bundle args = new Bundle();
args.putString("action", "edit");
@ -470,7 +470,7 @@ public class FragmentCompose extends FragmentEx {
args.putLong("account", -1);
args.putLong("reference", -1);
args.putLong("answer", -1);
draftLoader.load(this, args);
draftLoader.execute(this, args);
}
} else {
working = savedInstanceState.getLong("working");
@ -480,7 +480,7 @@ public class FragmentCompose extends FragmentEx {
args.putLong("account", -1);
args.putLong("reference", -1);
args.putLong("answer", -1);
draftLoader.load(this, args);
draftLoader.execute(this, args);
}
}
@ -718,7 +718,7 @@ public class FragmentCompose extends FragmentEx {
new SimpleTask<PendingIntent>() {
@Override
protected PendingIntent onLoad(Context context, Bundle args) throws Throwable {
protected PendingIntent onExecute(Context context, Bundle args) throws Throwable {
// Get arguments
long id = args.getLong("id");
Intent data = args.getParcelable("data");
@ -838,7 +838,7 @@ public class FragmentCompose extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, PendingIntent pi) {
protected void onExecuted(Bundle args, PendingIntent pi) {
if (pi != null)
try {
startIntentSenderForResult(
@ -858,7 +858,7 @@ public class FragmentCompose extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
@Override
@ -938,14 +938,14 @@ public class FragmentCompose extends FragmentEx {
new SimpleTask<EntityAttachment>() {
@Override
protected EntityAttachment onLoad(Context context, Bundle args) throws IOException {
protected EntityAttachment onExecute(Context context, Bundle args) throws IOException {
Long id = args.getLong("id");
Uri uri = args.getParcelable("uri");
return addAttachment(context, id, uri, image);
}
@Override
protected void onLoaded(Bundle args, EntityAttachment attachment) {
protected void onExecuted(Bundle args, EntityAttachment attachment) {
if (image) {
File file = EntityAttachment.getFile(getContext(), attachment.id);
Drawable d = Drawable.createFromPath(file.getAbsolutePath());
@ -969,7 +969,7 @@ public class FragmentCompose extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
private void handleExit() {
@ -1023,8 +1023,8 @@ public class FragmentCompose extends FragmentEx {
args.putString("body", Html.toHtml(spannable));
Log.i("Run load id=" + working);
actionLoader.load(this, args);
Log.i("Run execute id=" + working);
actionLoader.execute(this, args);
}
private boolean isEmpty() {
@ -1144,7 +1144,7 @@ public class FragmentCompose extends FragmentEx {
private SimpleTask<DraftAccount> draftLoader = new SimpleTask<DraftAccount>() {
@Override
protected DraftAccount onLoad(Context context, Bundle args) throws IOException {
protected DraftAccount onExecute(Context context, Bundle args) throws IOException {
String action = args.getString("action");
long id = args.getLong("id", -1);
long reference = args.getLong("reference", -1);
@ -1425,7 +1425,7 @@ public class FragmentCompose extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, final DraftAccount result) {
protected void onExecuted(Bundle args, final DraftAccount result) {
working = result.draft.id;
final String action = getArguments().getString("action");
@ -1530,7 +1530,7 @@ public class FragmentCompose extends FragmentEx {
new SimpleTask<Spanned[]>() {
@Override
protected Spanned[] onLoad(final Context context, Bundle args) throws Throwable {
protected Spanned[] onExecute(final Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
final long reference = args.getLong("reference", -1);
@ -1550,7 +1550,7 @@ public class FragmentCompose extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Spanned[] texts) {
protected void onExecuted(Bundle args, Spanned[] texts) {
etBody.setText(texts[0]);
etBody.setSelection(0);
etBody.setVisibility(View.VISIBLE);
@ -1584,7 +1584,7 @@ public class FragmentCompose extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentCompose.this, args);
}.execute(FragmentCompose.this, args);
}
}
}
@ -1599,21 +1599,21 @@ public class FragmentCompose extends FragmentEx {
private SimpleTask<EntityMessage> actionLoader = new SimpleTask<EntityMessage>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
busy = true;
Helper.setViewsEnabled(view, false);
getActivity().invalidateOptionsMenu();
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
busy = false;
Helper.setViewsEnabled(view, true);
getActivity().invalidateOptionsMenu();
}
@Override
protected EntityMessage onLoad(final Context context, Bundle args) throws Throwable {
protected EntityMessage onExecute(final Context context, Bundle args) throws Throwable {
// Get data
long id = args.getLong("id");
int action = args.getInt("action");
@ -1813,7 +1813,7 @@ public class FragmentCompose extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, EntityMessage draft) {
protected void onExecuted(Bundle args, EntityMessage draft) {
int action = args.getInt("action");
Log.i("Loaded action id=" + (draft == null ? null : draft.id) + " action=" + action);

@ -144,21 +144,21 @@ public class FragmentFolder extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
Helper.setViewsEnabled(view, false);
btnSave.setEnabled(false);
pbSave.setVisibility(View.VISIBLE);
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
Helper.setViewsEnabled(view, true);
btnSave.setEnabled(true);
pbSave.setVisibility(View.GONE);
}
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
long aid = args.getLong("account");
String name = args.getString("name");
@ -248,7 +248,7 @@ public class FragmentFolder extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@ -259,7 +259,7 @@ public class FragmentFolder extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentFolder.this, args);
}.execute(FragmentFolder.this, args);
}
});
@ -310,7 +310,7 @@ public class FragmentFolder extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -327,7 +327,7 @@ public class FragmentFolder extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@ -342,7 +342,7 @@ public class FragmentFolder extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentFolder.this, args);
}.execute(FragmentFolder.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -358,13 +358,13 @@ public class FragmentFolder extends FragmentEx {
new SimpleTask<EntityFolder>() {
@Override
protected EntityFolder onLoad(Context context, Bundle args) {
protected EntityFolder onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return DB.getInstance(context).folder().getFolder(id);
}
@Override
protected void onLoaded(Bundle args, EntityFolder folder) {
protected void onExecuted(Bundle args, EntityFolder folder) {
if (savedInstanceState == null) {
etName.setText(folder == null ? null : folder.name);
etDisplay.setText(folder == null ? null : (folder.display == null ? folder.name : folder.display));
@ -398,6 +398,6 @@ public class FragmentFolder extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
}

@ -366,25 +366,25 @@ public class FragmentIdentity extends FragmentEx {
new SimpleTask<Provider>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
etDomain.setEnabled(false);
btnAutoConfig.setEnabled(false);
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
etDomain.setEnabled(true);
btnAutoConfig.setEnabled(true);
}
@Override
protected Provider onLoad(Context context, Bundle args) throws Throwable {
protected Provider onExecute(Context context, Bundle args) throws Throwable {
String domain = args.getString("domain");
return Provider.fromDomain(context, domain);
}
@Override
protected void onLoaded(Bundle args, Provider provider) {
protected void onExecuted(Bundle args, Provider provider) {
etHost.setText(provider.smtp_host);
etPort.setText(Integer.toString(provider.smtp_port));
cbStartTls.setChecked(provider.smtp_starttls);
@ -397,7 +397,7 @@ public class FragmentIdentity extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentIdentity.this, args);
}.execute(FragmentIdentity.this, args);
}
});
@ -452,7 +452,7 @@ public class FragmentIdentity extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
Helper.setViewsEnabled(view, false);
btnSave.setEnabled(false);
pbSave.setVisibility(View.VISIBLE);
@ -460,14 +460,14 @@ public class FragmentIdentity extends FragmentEx {
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
Helper.setViewsEnabled(view, true);
btnSave.setEnabled(true);
pbSave.setVisibility(View.GONE);
}
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
String name = args.getString("name");
String email = args.getString("email");
@ -606,7 +606,7 @@ public class FragmentIdentity extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@ -625,7 +625,7 @@ public class FragmentIdentity extends FragmentEx {
});
}
}
}.load(FragmentIdentity.this, args);
}.execute(FragmentIdentity.this, args);
}
});
@ -668,13 +668,13 @@ public class FragmentIdentity extends FragmentEx {
new SimpleTask<EntityIdentity>() {
@Override
protected EntityIdentity onLoad(Context context, Bundle args) {
protected EntityIdentity onExecute(Context context, Bundle args) {
long id = args.getLong("id");
return DB.getInstance(context).identity().getIdentity(id);
}
@Override
protected void onLoaded(Bundle args, final EntityIdentity identity) {
protected void onExecuted(Bundle args, final EntityIdentity identity) {
if (savedInstanceState == null) {
etName.setText(identity == null ? null : identity.name);
etEmail.setText(identity == null ? null : identity.email);
@ -703,12 +703,12 @@ public class FragmentIdentity extends FragmentEx {
if (identity == null)
new SimpleTask<Integer>() {
@Override
protected Integer onLoad(Context context, Bundle args) {
protected Integer onExecute(Context context, Bundle args) {
return DB.getInstance(context).identity().getSynchronizingIdentityCount();
}
@Override
protected void onLoaded(Bundle args, Integer count) {
protected void onExecuted(Bundle args, Integer count) {
cbPrimary.setChecked(count == 0);
}
@ -716,7 +716,7 @@ public class FragmentIdentity extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentIdentity.this, new Bundle());
}.execute(FragmentIdentity.this, new Bundle());
} else {
tilPassword.getEditText().setText(savedInstanceState.getString("password"));
grpAdvanced.setVisibility(savedInstanceState.getInt("advanced"));
@ -743,12 +743,12 @@ public class FragmentIdentity extends FragmentEx {
new SimpleTask<List<EntityAccount>>() {
@Override
protected List<EntityAccount> onLoad(Context context, Bundle args) {
protected List<EntityAccount> onExecute(Context context, Bundle args) {
return DB.getInstance(context).account().getAccounts();
}
@Override
protected void onLoaded(Bundle args, List<EntityAccount> accounts) {
protected void onExecuted(Bundle args, List<EntityAccount> accounts) {
if (accounts == null)
accounts = new ArrayList<>();
@ -812,14 +812,14 @@ public class FragmentIdentity extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentIdentity.this, args);
}.execute(FragmentIdentity.this, args);
}
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
@Override
@ -860,7 +860,7 @@ public class FragmentIdentity extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -872,7 +872,7 @@ public class FragmentIdentity extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
getFragmentManager().popBackStack();
}
@ -880,7 +880,7 @@ public class FragmentIdentity extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentIdentity.this, args);
}.execute(FragmentIdentity.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -903,7 +903,7 @@ public class FragmentIdentity extends FragmentEx {
new SimpleTask<IdentityFolders>() {
@Override
protected IdentityFolders onLoad(Context context, Bundle args) {
protected IdentityFolders onExecute(Context context, Bundle args) {
long aid = args.getLong("account");
long iid = args.getLong("identity");
@ -918,7 +918,7 @@ public class FragmentIdentity extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, IdentityFolders result) {
protected void onExecuted(Bundle args, IdentityFolders result) {
EntityFolder none = new EntityFolder();
none.name = "-";
result.folders.add(0, none);
@ -947,7 +947,7 @@ public class FragmentIdentity extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
class IdentityFolders {

@ -211,7 +211,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Boolean>() {
@Override
protected Boolean onLoad(Context context, Bundle args) {
protected Boolean onExecute(Context context, Bundle args) {
long fid = args.getLong("folder");
boolean connected = false;
@ -253,7 +253,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Boolean connected) {
protected void onExecuted(Bundle args, Boolean connected) {
if (!connected) {
swipeRefresh.setRefreshing(false);
Snackbar.make(view, R.string.title_sync_queued, Snackbar.LENGTH_LONG).show();
@ -264,7 +264,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
});
@ -373,7 +373,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<MessageTarget>() {
@Override
protected MessageTarget onLoad(Context context, Bundle args) {
protected MessageTarget onExecute(Context context, Bundle args) {
long id = args.getLong("id");
String name = args.getString("name");
boolean type = args.getBoolean("type");
@ -400,7 +400,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, MessageTarget result) {
protected void onExecuted(Bundle args, MessageTarget result) {
moveAsk(result);
}
@ -408,7 +408,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
});
@ -545,7 +545,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<MessageTarget>() {
@Override
protected MessageTarget onLoad(Context context, Bundle args) {
protected MessageTarget onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean thread = args.getBoolean("thread");
int direction = args.getInt("direction");
@ -592,7 +592,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(final Bundle args, final MessageTarget result) {
protected void onExecuted(final Bundle args, final MessageTarget result) {
moveUndo(result);
}
@ -600,7 +600,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
}).attachToRecyclerView(rvMessage);
@ -640,7 +640,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<MessageTarget>() {
@Override
protected MessageTarget onLoad(Context context, Bundle args) {
protected MessageTarget onExecute(Context context, Bundle args) {
long account = args.getLong("account");
String thread = args.getString("thread");
long id = args.getLong("id");
@ -676,7 +676,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, MessageTarget result) {
protected void onExecuted(Bundle args, MessageTarget result) {
moveAsk(result);
}
@ -684,7 +684,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
private void onActionNavigate(ViewModelMessages.Target target) {
@ -744,7 +744,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Boolean[]>() {
@Override
protected Boolean[] onLoad(Context context, Bundle args) {
protected Boolean[] onExecute(Context context, Bundle args) {
long fid = args.getLong("folder");
long[] ids = args.getLongArray("ids");
@ -782,7 +782,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, final Boolean[] result) {
protected void onExecuted(Bundle args, final Boolean[] result) {
PopupMenu popupMenu = new PopupMenu(getContext(), fabMore);
if (result[0] && !result[9])
@ -854,7 +854,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
private long[] getSelection() {
@ -877,7 +877,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
boolean seen = args.getBoolean("seen");
@ -907,7 +907,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
private void onActionFlag(boolean flagged) {
@ -919,7 +919,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
boolean flagged = args.getBoolean("flagged");
@ -949,7 +949,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
private void onActionJunk() {
@ -978,7 +978,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
DB db = DB.getInstance(context);
@ -1010,7 +1010,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
})
.setNegativeButton(android.R.string.cancel, null)
@ -1026,7 +1026,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<MessageTarget>() {
@Override
protected MessageTarget onLoad(Context context, Bundle args) {
protected MessageTarget onExecute(Context context, Bundle args) {
String type = args.getString("type");
long[] ids = args.getLongArray("ids");
@ -1059,7 +1059,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, MessageTarget result) {
protected void onExecuted(Bundle args, MessageTarget result) {
if (EntityFolder.JUNK.equals(result.target.type))
moveAskConfirmed(result);
else
@ -1070,7 +1070,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
private void onActionMove() {
@ -1080,7 +1080,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<List<EntityFolder>>() {
@Override
protected List<EntityFolder> onLoad(Context context, Bundle args) {
protected List<EntityFolder> onExecute(Context context, Bundle args) {
long fid = args.getLong("folder");
long[] ids = args.getLongArray("ids");
@ -1112,7 +1112,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(final Bundle args, List<EntityFolder> folders) {
protected void onExecuted(final Bundle args, List<EntityFolder> folders) {
PopupMenu popupMenu = new PopupMenu(getContext(), popupAnchor);
int order = 0;
@ -1128,7 +1128,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<MessageTarget>() {
@Override
protected MessageTarget onLoad(Context context, Bundle args) {
protected MessageTarget onExecute(Context context, Bundle args) {
long[] ids = args.getLongArray("ids");
long target = args.getLong("target");
@ -1159,7 +1159,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, MessageTarget result) {
protected void onExecuted(Bundle args, MessageTarget result) {
moveAsk(result);
}
@ -1167,7 +1167,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
return true;
}
@ -1180,7 +1180,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
});
@ -1449,13 +1449,13 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB.getInstance(context).message().resetSearch();
return null;
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
FragmentMessages fragment = new FragmentMessages();
fragment.setArguments(args);
@ -1468,7 +1468,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
} else {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
@ -1587,7 +1587,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long outbox = args.getLong("folder");
DB db = DB.getInstance(context);
@ -1619,7 +1619,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
private void loadMessages() {
@ -1826,7 +1826,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Boolean[]>() {
@Override
protected Boolean[] onLoad(Context context, Bundle args) {
protected Boolean[] onExecute(Context context, Bundle args) {
long account = args.getLong("account");
String thread = args.getString("thread");
long id = args.getLong("id");
@ -1856,7 +1856,7 @@ public class FragmentMessages extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Boolean[] data) {
protected void onExecuted(Bundle args, Boolean[] data) {
bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(trashes.size() > 0 && data[0]);
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(archives.size() > 0 && data[1]);
bottom_navigation.setVisibility(View.VISIBLE);
@ -1866,7 +1866,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
} else {
@ -1900,7 +1900,7 @@ public class FragmentMessages extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
DB db = DB.getInstance(context);
@ -1928,7 +1928,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
private void moveAsk(final MessageTarget result) {
@ -1962,7 +1962,7 @@ public class FragmentMessages extends FragmentEx {
// Move messages
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
try {
MessageTarget result = (MessageTarget) args.getSerializable("result");
@ -1989,7 +1989,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
private void moveUndo(final MessageTarget result) {
@ -2012,7 +2012,7 @@ public class FragmentMessages extends FragmentEx {
// Show message again
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
MessageTarget result = (MessageTarget) args.getSerializable("result");
for (long id : result.ids) {
@ -2026,7 +2026,7 @@ public class FragmentMessages extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentMessages.this, args);
}.execute(FragmentMessages.this, args);
}
});
snackbar.show();

@ -137,7 +137,7 @@ public class FragmentOperations extends FragmentEx {
public void onClick(DialogInterface dialog, int which) {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
List<EntityOperation> ops = db.operation().getOperationsError();
Log.i("Operations with error count=" + ops.size());
@ -154,7 +154,7 @@ public class FragmentOperations extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentOperations.this, new Bundle());
}.execute(FragmentOperations.this, new Bundle());
}
})
.setNegativeButton(android.R.string.cancel, null)

@ -217,7 +217,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
if (checked)
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
@ -245,7 +245,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentOptions.this, null);
}.execute(FragmentOptions.this, null);
}
});

@ -205,7 +205,7 @@ public class FragmentSetup extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
etName.setEnabled(false);
etEmail.setEnabled(false);
tilPassword.setEnabled(false);
@ -215,7 +215,7 @@ public class FragmentSetup extends FragmentEx {
}
@Override
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
etName.setEnabled(true);
etEmail.setEnabled(true);
tilPassword.setEnabled(true);
@ -223,7 +223,7 @@ public class FragmentSetup extends FragmentEx {
}
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
String name = args.getString("name");
String email = args.getString("email");
String password = args.getString("password");
@ -391,7 +391,7 @@ public class FragmentSetup extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
etName.setText(null);
etEmail.setText(null);
tilPassword.getEditText().setText(null);
@ -417,7 +417,7 @@ public class FragmentSetup extends FragmentEx {
grpQuickError.setVisibility(View.VISIBLE);
}
}
}.load(FragmentSetup.this, args);
}.execute(FragmentSetup.this, args);
}
});
@ -567,7 +567,7 @@ public class FragmentSetup extends FragmentEx {
// Create outbox
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
try {
db.beginTransaction();
@ -596,7 +596,7 @@ public class FragmentSetup extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, new Bundle());
}.execute(this, new Bundle());
return view;
}
@ -750,7 +750,7 @@ public class FragmentSetup extends FragmentEx {
if (has && !init)
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) {
protected Void onExecute(Context context, Bundle args) {
DB db = DB.getInstance(context);
for (EntityFolder folder : db.folder().getFoldersSynchronizing())
EntityOperation.sync(db, folder.id);
@ -761,7 +761,7 @@ public class FragmentSetup extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(FragmentSetup.this, new Bundle());
}.execute(FragmentSetup.this, new Bundle());
}
@Override
@ -871,7 +871,7 @@ public class FragmentSetup extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
String password = args.getString("password");
@ -954,7 +954,7 @@ public class FragmentSetup extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
Snackbar.make(view, R.string.title_setup_exported, Snackbar.LENGTH_LONG).show();
}
@ -965,7 +965,7 @@ public class FragmentSetup extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
private void handleImport(Intent data, String password) {
@ -975,7 +975,7 @@ public class FragmentSetup extends FragmentEx {
new SimpleTask<Void>() {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
protected Void onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
String password = args.getString("password");
@ -1092,7 +1092,7 @@ public class FragmentSetup extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, Void data) {
protected void onExecuted(Bundle args, Void data) {
Snackbar.make(view, R.string.title_setup_imported, Snackbar.LENGTH_LONG).show();
}
@ -1105,6 +1105,6 @@ public class FragmentSetup extends FragmentEx {
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
}

@ -128,7 +128,7 @@ public class FragmentWebView extends FragmentEx {
} else if (args.containsKey("id")) {
new SimpleTask<String>() {
@Override
protected String onLoad(Context context, Bundle args) throws Throwable {
protected String onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
String html = EntityMessage.read(context, id);
@ -174,7 +174,7 @@ public class FragmentWebView extends FragmentEx {
}
@Override
protected void onLoaded(Bundle args, String html) {
protected void onExecuted(Bundle args, String html) {
String from = args.getString("from");
webview.loadDataWithBaseURL("email://", html, "text/html", "UTF-8", null);
setSubtitle(from);
@ -184,7 +184,7 @@ public class FragmentWebView extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}.execute(this, args);
}
((ActivityBase) getActivity()).addBackPressedListener(onBackPressedListener);

@ -253,12 +253,12 @@ public class Helper {
public void onClick(DialogInterface dialog, int which) {
new SimpleTask<Long>() {
@Override
protected Long onLoad(Context context, Bundle args) throws Throwable {
protected Long onExecute(Context context, Bundle args) throws Throwable {
return getDebugInfo(context, R.string.title_crash_info_remark, ex, null).id;
}
@Override
protected void onLoaded(Bundle args, Long id) {
protected void onExecuted(Bundle args, Long id) {
context.startActivity(
new Intent(context, ActivityCompose.class)
.putExtra("action", "edit")
@ -272,7 +272,7 @@ public class Helper {
else
Toast.makeText(context, ex.toString(), Toast.LENGTH_LONG).show();
}
}.load(context, owner, new Bundle());
}.execute(context, owner, new Bundle());
}
})
.show();

@ -36,7 +36,7 @@ import androidx.lifecycle.OnLifecycleEvent;
//
// This simple task is simple to use, but it is also simple to cause bugs that can easily lead to crashes
// Make sure to not access any member in any outer scope from onLoad
// Make sure to not access any member in any outer scope from onExecute
// Results will not be delivered to destroyed fragments
//
@ -48,19 +48,19 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
private static ExecutorService executor = Executors.newCachedThreadPool(Helper.backgroundThreadFactory);
public void load(Context context, LifecycleOwner owner, Bundle args) {
public void execute(Context context, LifecycleOwner owner, Bundle args) {
run(context, owner, args);
}
public void load(LifecycleService service, Bundle args) {
public void execute(LifecycleService service, Bundle args) {
run(service, service, args);
}
public void load(AppCompatActivity activity, Bundle args) {
public void execute(AppCompatActivity activity, Bundle args) {
run(activity, activity, args);
}
public void load(final Fragment fragment, Bundle args) {
public void execute(final Fragment fragment, Bundle args) {
try {
run(fragment.getContext(), fragment.getViewLifecycleOwner(), args);
} catch (IllegalStateException ex) {
@ -117,7 +117,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
this.stored = null;
try {
onInit(args);
onPreExecute(args);
} catch (Throwable ex) {
Log.e(ex);
}
@ -133,7 +133,7 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
final Result result = new Result();
try {
result.data = onLoad(context, args);
result.data = onExecute(context, args);
} catch (Throwable ex) {
Log.e(ex);
result.ex = ex;
@ -158,15 +158,15 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
} else {
Log.i("Delivery task " + this);
try {
if (result.ex == null)
onLoaded(args, (T) result.data);
else
onException(args, result.ex);
onPostExecute(args);
} catch (Throwable ex) {
Log.e(ex);
} finally {
try {
onCleanup(args);
if (result.ex == null)
onExecuted(args, (T) result.data);
else
onException(args, result.ex);
} catch (Throwable ex) {
Log.e(ex);
}
@ -175,17 +175,17 @@ public abstract class SimpleTask<T> implements LifecycleObserver {
}
}
protected void onInit(Bundle args) {
protected void onPreExecute(Bundle args) {
}
protected abstract T onLoad(Context context, Bundle args) throws Throwable;
protected abstract T onExecute(Context context, Bundle args) throws Throwable;
protected void onLoaded(Bundle args, T data) {
protected void onExecuted(Bundle args, T data) {
}
protected abstract void onException(Bundle args, Throwable ex);
protected void onCleanup(Bundle args) {
protected void onPostExecute(Bundle args) {
}
private static class Result {

Loading…
Cancel
Save