mirror of
https://github.com/M66B/FairEmail.git
synced 2025-12-30 01:21:11 +01:00
Refactoring
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user