Fixed expanded state

This commit is contained in:
M66B 2019-05-31 09:37:28 +02:00
parent fd8e202e59
commit ea385e9788
1 changed files with 10 additions and 4 deletions

View File

@ -876,10 +876,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
values.get(name).remove(id); values.get(name).remove(id);
if ("expanded".equals(name)) { if ("expanded".equals(name)) {
updateExpanded();
if (enabled) if (enabled)
handleExpand(id); handleExpand(id);
ibDown.setVisibility(values.get(name).size() > 0 ? View.VISIBLE : View.GONE);
ibUp.setVisibility(values.get(name).size() > 0 ? View.VISIBLE : View.GONE);
} }
} }
@ -2089,6 +2088,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
loadMessages(false); loadMessages(false);
updateExpanded();
if (selectionTracker != null && selectionTracker.hasSelection()) if (selectionTracker != null && selectionTracker.hasSelection())
fabMore.show(); fabMore.show();
else else
@ -2917,6 +2918,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
return false; return false;
} }
private void updateExpanded() {
boolean expanded = (values.containsKey("expanded") && values.get("expanded").size() > 0);
ibDown.setVisibility(expanded ? View.VISIBLE : View.GONE);
ibUp.setVisibility(expanded ? View.VISIBLE : View.GONE);
}
private void handleExpand(long id) { private void handleExpand(long id) {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", id); args.putLong("id", id);
@ -3226,8 +3233,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
boolean collapse = prefs.getBoolean("collapse", false); boolean collapse = prefs.getBoolean("collapse", false);
if ((count == 1 && collapse) || count > 1) { if ((count == 1 && collapse) || count > 1) {
values.get("expanded").clear(); values.get("expanded").clear();
ibDown.setVisibility(View.GONE); updateExpanded();
ibUp.setVisibility(View.GONE);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
return true; return true;
} }