Take hidden folders into account for collapsible

pull/156/head
M66B 6 years ago
parent 6e5aba2535
commit e5d91ac619

@ -76,6 +76,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
private int level;
private EntityFolder parent;
private boolean collapsable;
private boolean collapsable_hidden;
private IProperties properties;
private boolean subscriptions;
private boolean debug;
@ -228,12 +229,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
ivReadOnly.setVisibility(folder.read_only ? View.VISIBLE : View.GONE);
boolean folder_collapsible = (show_hidden ? collapsable : collapsable_hidden);
ViewGroup.LayoutParams lp = vwLevel.getLayoutParams();
lp.width = (account < 0 || !collapsable ? 1 : level) * dp12;
lp.width = (account < 0 || !folder_collapsible ? 1 : level) * dp12;
vwLevel.setLayoutParams(lp);
ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */);
ivExpander.setVisibility(account < 0 || !collapsable ? View.GONE : (folder.childs > 0 ? View.VISIBLE : View.INVISIBLE));
ivExpander.setVisibility(account < 0 || !folder_collapsible ? View.GONE : (folder.childs > 0 ? View.VISIBLE : View.INVISIBLE));
ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE);
ivSubscribed.setVisibility(subscriptions && folder.subscribed != null && folder.subscribed ? View.VISIBLE : View.GONE);
@ -707,14 +710,18 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
if (parent == null) {
this.collapsable = false;
this.collapsable_hidden = false;
for (TupleFolderEx folder : folders)
if (folder.childs > 0) {
this.collapsable = true;
this.collapsable_hidden = (folder.childs - folder.hidden_childs > 0);
break;
}
} else
} else {
this.collapsable = true;
this.collapsable_hidden = true;
}
final Collator collator = Collator.getInstance(Locale.getDefault());
collator.setStrength(Collator.SECONDARY); // Case insensitive, process accents etc

@ -57,6 +57,7 @@ public interface DaoFolder {
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id AND child.hide) AS hidden_childs" +
" FROM folder" +
" LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
@ -75,6 +76,7 @@ public interface DaoFolder {
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id AND child.hide) AS hidden_childs" +
" FROM folder" +
" JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
@ -115,6 +117,7 @@ public interface DaoFolder {
", SUM(CASE WHEN message.ui_seen = 0 THEN 1 ELSE 0 END) AS unseen" +
", (SELECT COUNT(operation.id) FROM operation WHERE operation.folder = folder.id AND operation.state = 'executing') AS executing" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id) AS childs" +
", (SELECT COUNT(child.id) FROM folder child WHERE child.parent = folder.id AND child.hide) AS hidden_childs" +
" FROM folder" +
" LEFT JOIN account ON account.id = folder.account" +
" LEFT JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +

@ -40,6 +40,7 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
public int unseen;
public int executing;
public int childs;
public int hidden_childs;
@Override
public boolean equals(Object obj) {
@ -53,7 +54,8 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
this.content == other.content &&
this.unseen == other.unseen &&
this.executing == other.executing &&
this.childs == other.childs);
this.childs == other.childs &&
this.hidden_childs == other.hidden_childs);
} else
return false;
}

Loading…
Cancel
Save