From 519580532a9754fa50a6715c7ffbcb61054f4486 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 16 Oct 2018 10:48:37 +0000 Subject: [PATCH] Refactoring --- .../eu/faircode/email/AdapterMessage.java | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 946c336e..89ddd474 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -544,48 +544,8 @@ public class AdapterMessage extends PagedListAdapter() { - @Override - protected Void onLoad(Context context, Bundle args) { - long id = args.getLong("id"); - - DB db = DB.getInstance(context); - try { - db.beginTransaction(); - - EntityMessage message = db.message().getMessage(id); - EntityFolder folder = db.folder().getFolder(message.folder); - - if (!EntityFolder.OUTBOX.equals(folder.type)) { - if (!message.content) - EntityOperation.queue(db, message, EntityOperation.BODY); - - if (!message.ui_seen) { - db.message().setMessageUiSeen(message.id, true); - EntityOperation.queue(db, message, EntityOperation.SEEN, true); - } - } - - db.setTransactionSuccessful(); - } finally { - db.endTransaction(); - } - - EntityOperation.process(context); - - return null; - } - - @Override - protected void onException(Bundle args, Throwable ex) { - Helper.unexpectedError(context, ex); - } - }.load(context, owner, args); - } + if (expanded.get(message.id)) + handleExpand(message.id); } private SimpleTask bodyTask = new SimpleTask() { @@ -1317,6 +1277,49 @@ public class AdapterMessage extends PagedListAdapter() { + @Override + protected Void onLoad(Context context, Bundle args) { + long id = args.getLong("id"); + + DB db = DB.getInstance(context); + try { + db.beginTransaction(); + + EntityMessage message = db.message().getMessage(id); + EntityFolder folder = db.folder().getFolder(message.folder); + + if (!EntityFolder.OUTBOX.equals(folder.type)) { + if (!message.content) + EntityOperation.queue(db, message, EntityOperation.BODY); + + if (!message.ui_seen) { + db.message().setMessageUiSeen(message.id, true); + EntityOperation.queue(db, message, EntityOperation.SEEN, true); + } + } + + db.setTransactionSuccessful(); + } finally { + db.endTransaction(); + } + + EntityOperation.process(context); + + return null; + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(context, ex); + } + }.load(context, owner, args); + } + private static final DiffUtil.ItemCallback DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override