mirror of https://github.com/M66B/FairEmail.git
Optimize folder processing
This commit is contained in:
parent
a3658a869c
commit
b7a0987c52
|
@ -142,18 +142,6 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
|
||||
private void bindTo(final TupleFolderEx folder) {
|
||||
boolean hidden = false;
|
||||
|
||||
int level = 0;
|
||||
TupleFolderEx parent = folder.parent_ref;
|
||||
while (parent != null) {
|
||||
level++;
|
||||
if (parent.collapsed)
|
||||
hidden = true;
|
||||
parent = parent.parent_ref;
|
||||
}
|
||||
|
||||
view.setVisibility(hidden ? View.GONE : View.VISIBLE);
|
||||
view.setActivated(folder.tbc != null || folder.tbd != null);
|
||||
view.setAlpha(disabledIds.contains(folder.id) ? Helper.LOW_LIGHT : 1.0f);
|
||||
|
||||
|
@ -195,13 +183,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
|
||||
ViewGroup.LayoutParams lp = vwLevel.getLayoutParams();
|
||||
lp.width = (account < 0 ? 1 : level) * dp12;
|
||||
lp.width = (account < 0 ? 1 : folder.indentation) * dp12;
|
||||
vwLevel.setLayoutParams(lp);
|
||||
|
||||
ivExpander.setImageLevel(folder.collapsed ? 1 /* more */ : 0 /* less */);
|
||||
ivExpander.setVisibility(account < 0
|
||||
? View.GONE
|
||||
: folder.child_refs.size() > 0 ? View.VISIBLE : View.INVISIBLE);
|
||||
: folder.child_refs != null && folder.child_refs.size() > 0
|
||||
? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
if (listener == null) {
|
||||
ivNotify.setVisibility(folder.notify ? View.VISIBLE : View.GONE);
|
||||
|
@ -210,10 +199,10 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
|
||||
if (folder.unseen > 0)
|
||||
tvName.setText(context.getString(R.string.title_name_count,
|
||||
folder.getDisplayName(context, parent),
|
||||
folder.getDisplayName(context, folder.parent_ref == null ? null : folder.parent_ref),
|
||||
nf.format(folder.unseen)));
|
||||
else
|
||||
tvName.setText(folder.getDisplayName(context, parent));
|
||||
tvName.setText(folder.getDisplayName(context, folder.parent_ref == null ? null : folder.parent_ref));
|
||||
|
||||
tvName.setTypeface(folder.unseen > 0 ? Typeface.DEFAULT_BOLD : Typeface.DEFAULT);
|
||||
tvName.setTextColor(folder.unseen > 0 ? colorUnread : textColorSecondary);
|
||||
|
@ -715,6 +704,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
|
||||
TupleFolderEx root = new TupleFolderEx();
|
||||
root.name = "[root]";
|
||||
root.child_refs = parents;
|
||||
for (TupleFolderEx parent : parents)
|
||||
parent.parent_ref = root;
|
||||
|
@ -728,7 +718,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
}
|
||||
}
|
||||
|
||||
List<TupleFolderEx> hierarchical = getHierchical(parents);
|
||||
List<TupleFolderEx> hierarchical = getHierchical(parents, 0);
|
||||
|
||||
DiffUtil.DiffResult diff = DiffUtil.calculateDiff(new DiffCallback(items, hierarchical), false);
|
||||
|
||||
|
@ -758,13 +748,14 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
|||
diff.dispatchUpdatesTo(this);
|
||||
}
|
||||
|
||||
List<TupleFolderEx> getHierchical(List<TupleFolderEx> parents) {
|
||||
List<TupleFolderEx> getHierchical(List<TupleFolderEx> parents, int indentation) {
|
||||
List<TupleFolderEx> result = new ArrayList<>();
|
||||
|
||||
for (TupleFolderEx parent : parents) {
|
||||
parent.indentation = indentation;
|
||||
result.add(parent);
|
||||
if (parent.child_refs != null)
|
||||
result.addAll(getHierchical(parent.child_refs));
|
||||
if (!parent.collapsed && parent.child_refs != null)
|
||||
result.addAll(getHierchical(parent.child_refs, indentation + 1));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -44,6 +44,9 @@ public class TupleFolderEx extends EntityFolder implements Serializable {
|
|||
public int unseen;
|
||||
public int executing;
|
||||
|
||||
@Ignore
|
||||
int indentation;
|
||||
|
||||
@Ignore
|
||||
TupleFolderEx parent_ref;
|
||||
|
||||
|
|
Loading…
Reference in New Issue