1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-28 02:37:16 +00:00

Simplification

This commit is contained in:
M66B 2018-12-05 13:25:55 +01:00
parent c4733427ae
commit d0f5d41ab3

View file

@ -1195,6 +1195,27 @@ public class FragmentMessages extends FragmentEx {
trashes.add(folder.account);
loadMessages();
if (actionbar && viewType == AdapterMessage.ViewType.THREAD) {
boolean hasTrash = false;
boolean hasArchive = false;
if (folders != null)
for (EntityFolder folder : folders)
if (EntityFolder.TRASH.equals(folder.type))
hasTrash = true;
else if (EntityFolder.ARCHIVE.equals(folder.type))
hasArchive = true;
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
ViewModelMessages.Target[] pn = model.getPrevNext(thread);
bottom_navigation.setTag(pn);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null);
bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(hasTrash);
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(hasArchive);
bottom_navigation.setVisibility(View.VISIBLE);
}
}
});
@ -1203,32 +1224,7 @@ public class FragmentMessages extends FragmentEx {
else
fabMore.hide();
if (viewType == AdapterMessage.ViewType.THREAD) {
if (actionbar)
db.folder().liveSystemFolders(account).observe(getViewLifecycleOwner(), new Observer<List<EntityFolder>>() {
@Override
public void onChanged(@Nullable List<EntityFolder> folders) {
boolean hasTrash = false;
boolean hasArchive = false;
if (folders != null)
for (EntityFolder folder : folders)
if (EntityFolder.TRASH.equals(folder.type))
hasTrash = true;
else if (EntityFolder.ARCHIVE.equals(folder.type))
hasArchive = true;
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
ViewModelMessages.Target[] pn = model.getPrevNext(thread);
bottom_navigation.setTag(pn);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(pn[0] != null);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(pn[1] != null);
bottom_navigation.getMenu().findItem(R.id.action_delete).setVisible(hasTrash);
bottom_navigation.getMenu().findItem(R.id.action_archive).setVisible(hasArchive);
bottom_navigation.setVisibility(View.VISIBLE);
}
});
} else {
if (viewType != AdapterMessage.ViewType.THREAD) {
db.folder().liveDrafts(account < 0 ? null : account).observe(getViewLifecycleOwner(), new Observer<EntityFolder>() {
@Override
public void onChanged(EntityFolder drafts) {