From f31644894eff1fdf1b3a6cd8ec994fdc16b291b0 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 3 Aug 2018 16:38:35 +0000 Subject: [PATCH] Fixed bottom navigation enabled state --- .../java/eu/faircode/email/FragmentCompose.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 54fb0a2e..b57c02cf 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -158,8 +158,6 @@ public class FragmentCompose extends Fragment { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { - bottom_navigation.setEnabled(false); - switch (item.getItemId()) { case R.id.action_delete: actionDelete(id); @@ -182,7 +180,7 @@ public class FragmentCompose extends Fragment { grpReady.setVisibility(View.GONE); pbWait.setVisibility(View.VISIBLE); bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(id > 0); - bottom_navigation.setEnabled(false); + bottom_navigation.getMenu().setGroupEnabled(0, false); DB.getInstance(getContext()).identity().liveIdentities(true).observe(getActivity(), new Observer>() { @Override @@ -288,13 +286,15 @@ public class FragmentCompose extends Fragment { } private void actionDelete(final long id) { + bottom_navigation.getMenu().setGroupEnabled(0, false); + Bundle args = new Bundle(); args.putLong("id", id); getLoaderManager().restartLoader(ActivityCompose.LOADER_COMPOSE_DELETE, args, deleteLoaderCallbacks).forceLoad(); } private void actionPut(long id, boolean send) { - bottom_navigation.setEnabled(false); + bottom_navigation.getMenu().setGroupEnabled(0, false); EntityIdentity identity = (EntityIdentity) spFrom.getSelectedItem(); @@ -403,7 +403,7 @@ public class FragmentCompose extends Fragment { } @Override - public void onLoadFinished(@NonNull Loader loader, final Bundle result) { + public void onLoadFinished(@NonNull Loader loader, Bundle result) { getLoaderManager().destroyLoader(loader.getId()); long iid = result.getLong("iid", -1); @@ -463,7 +463,7 @@ public class FragmentCompose extends Fragment { } } - bottom_navigation.setEnabled(true); + bottom_navigation.getMenu().setGroupEnabled(0, true); } @Override @@ -516,6 +516,10 @@ public class FragmentCompose extends Fragment { if (ex == null) { getFragmentManager().popBackStack(); Toast.makeText(getContext(), R.string.title_draft_deleted, Toast.LENGTH_LONG).show(); + } else { + Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); + bottom_navigation.getMenu().setGroupEnabled(0, true); + Toast.makeText(getContext(), Helper.formatThrowable(ex), Toast.LENGTH_LONG).show(); } } @@ -654,6 +658,7 @@ public class FragmentCompose extends Fragment { Toast.makeText(getContext(), send ? R.string.title_queued : R.string.title_draft_saved, Toast.LENGTH_LONG).show(); } else { Log.w(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex)); + bottom_navigation.getMenu().setGroupEnabled(0, true); Toast.makeText(getContext(), Helper.formatThrowable(ex), Toast.LENGTH_LONG).show(); } }