From 74b6cb037dfba60df5782f67f5e9e4d65cd746af Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 3 Aug 2018 09:58:44 +0000 Subject: [PATCH] Refactoring --- app/src/main/java/eu/faircode/email/ActivityCompose.java | 4 +++- app/src/main/java/eu/faircode/email/ActivityView.java | 6 ++++-- app/src/main/java/eu/faircode/email/FragmentCompose.java | 2 ++ app/src/main/java/eu/faircode/email/FragmentMessage.java | 3 ++- app/src/main/java/eu/faircode/email/FragmentSetup.java | 5 +++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ActivityCompose.java b/app/src/main/java/eu/faircode/email/ActivityCompose.java index 82f30169..d536c19b 100644 --- a/app/src/main/java/eu/faircode/email/ActivityCompose.java +++ b/app/src/main/java/eu/faircode/email/ActivityCompose.java @@ -40,11 +40,13 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB getSupportFragmentManager().addOnBackStackChangedListener(this); if (getSupportFragmentManager().getFragments().size() == 0) { - FragmentCompose fragment = new FragmentCompose(); Bundle args = getIntent().getExtras(); if (args == null) args = new Bundle(); + + FragmentCompose fragment = new FragmentCompose(); fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("compose"); fragmentTransaction.commit(); diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index 12bd5db6..38bc9137 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -212,9 +212,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack if (prefs.getBoolean("eula", false)) { drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); - FragmentMessages fragment = new FragmentMessages(); Bundle args = new Bundle(); args.putLong("folder", -1); + + FragmentMessages fragment = new FragmentMessages(); fragment.setArguments(args); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); @@ -257,9 +258,10 @@ public class ActivityView extends ActivityBase implements FragmentManager.OnBack } private void onMenuUnified() { - FragmentMessages fragment = new FragmentMessages(); Bundle args = new Bundle(); args.putLong("folder", -1); + + FragmentMessages fragment = new FragmentMessages(); fragment.setArguments(args); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 59a2d2f5..7cc88dcf 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -121,8 +121,10 @@ public class FragmentCompose extends Fragment { public void onClick(View view) { Bundle args = new Bundle(); args.putLong("id", -1); + FragmentIdentity fragment = new FragmentIdentity(); fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("identity"); fragmentTransaction.commit(); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessage.java b/app/src/main/java/eu/faircode/email/FragmentMessage.java index 919cb0f7..49ce6951 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessage.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessage.java @@ -262,9 +262,10 @@ public class FragmentMessage extends Fragment { } private void onActionThread(long id) { - FragmentMessages fragment = new FragmentMessages(); Bundle args = new Bundle(); args.putLong("thread", id); // message ID + + FragmentMessages fragment = new FragmentMessages(); fragment.setArguments(args); FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); diff --git a/app/src/main/java/eu/faircode/email/FragmentSetup.java b/app/src/main/java/eu/faircode/email/FragmentSetup.java index 48dd4381..90d768b2 100644 --- a/app/src/main/java/eu/faircode/email/FragmentSetup.java +++ b/app/src/main/java/eu/faircode/email/FragmentSetup.java @@ -86,11 +86,14 @@ public class FragmentSetup extends Fragment { if (!once) { once = true; + Bundle args = new Bundle(); if (account != null) args.putLong("id", account.id); + FragmentAccount fragment = new FragmentAccount(); fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("account"); fragmentTransaction.commit(); @@ -120,8 +123,10 @@ public class FragmentSetup extends Fragment { Bundle args = new Bundle(); if (identity != null) args.putLong("id", identity.id); + FragmentIdentity fragment = new FragmentIdentity(); fragment.setArguments(args); + FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment).addToBackStack("identity"); fragmentTransaction.commit();