From 36bdc2cce7008130e1bd73d6fde5507f429cbf10 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 21 Aug 2018 13:57:07 +0000 Subject: [PATCH] Close message on moving from archive --- .../java/eu/faircode/email/FragmentMessage.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 5cc5edb8..ac340057 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -810,19 +810,23 @@ public class FragmentMessage extends FragmentEx { args.putLong("target", target.getItemId()); - new SimpleTask() { + new SimpleTask() { @Override - protected Void onLoad(Context context, Bundle args) { + protected Boolean onLoad(Context context, Bundle args) { long id = args.getLong("id"); long target = args.getLong("target"); + boolean close = false; + DB db = DB.getInstance(context); try { db.beginTransaction(); EntityMessage message = db.message().getMessage(id); EntityFolder folder = db.folder().getFolder(message.folder); - if (!EntityFolder.ARCHIVE.equals(folder.type)) + + close = EntityFolder.ARCHIVE.equals(folder.type); + if (!close) db.message().setMessageUiHide(message.id, true); EntityOperation.queue(db, message, EntityOperation.MOVE, target); @@ -834,12 +838,14 @@ public class FragmentMessage extends FragmentEx { EntityOperation.process(context); - return null; + return close; } @Override - protected void onLoaded(Bundle args, Void result) { + protected void onLoaded(Bundle args, Boolean close) { Helper.setViewsEnabled(view, true); + if (close) // archived message + getFragmentManager().popBackStack(); } @Override @@ -891,6 +897,7 @@ public class FragmentMessage extends FragmentEx { @Override protected void onLoaded(Bundle args, Void result) { + getFragmentManager().popBackStack(); Helper.setViewsEnabled(view, true); }