From 7aed62b8f9199ec777ae6599da3d82ce2c30c76b Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 22 Oct 2018 06:47:43 +0000 Subject: [PATCH] Remove previous search results --- .../java/eu/faircode/email/ActivityView.java | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 833e7e17..21f8bb1b 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -317,37 +317,48 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB intent.removeExtra(Intent.EXTRA_PROCESS_TEXT); setIntent(intent); - Bundle args = new Bundle(); - args.putString("search", search); - - new SimpleTask() { - @Override - protected Long onLoad(Context context, Bundle args) { - EntityFolder archive = DB.getInstance(context).folder().getPrimaryArchive(); - if (archive == null) - throw new IllegalArgumentException(getString(R.string.title_no_archive)); - return archive.id; - } + if (Helper.isPro(this)) { + Bundle args = new Bundle(); + args.putString("search", search); - @Override - protected void onLoaded(Bundle args, Long archive) { - Bundle sargs = new Bundle(); - sargs.putLong("folder", archive); - sargs.putString("search", args.getString("search")); + new SimpleTask() { + @Override + protected Long onLoad(Context context, Bundle args) { + DB db = DB.getInstance(context); - FragmentMessages fragment = new FragmentMessages(); - fragment.setArguments(sargs); + EntityFolder archive = db.folder().getPrimaryArchive(); + if (archive == null) + throw new IllegalArgumentException(getString(R.string.title_no_archive)); - FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); - fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search"); - fragmentTransaction.commit(); - } + db.message().deleteFoundMessages(); - @Override - protected void onException(Bundle args, Throwable ex) { - Helper.unexpectedError(ActivityView.this, ex); - } - }.load(this, args); + return archive.id; + } + + @Override + protected void onLoaded(Bundle args, Long archive) { + Bundle sargs = new Bundle(); + sargs.putLong("folder", archive); + sargs.putString("search", args.getString("search")); + + FragmentMessages fragment = new FragmentMessages(); + fragment.setArguments(sargs); + + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("search"); + fragmentTransaction.commit(); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(ActivityView.this, ex); + } + }.load(this, args); + } else { + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); + fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro"); + fragmentTransaction.commit(); + } } }