Fixed list performance

pull/156/head
M66B 6 years ago
parent 91084fbb31
commit b17855ab7a

@ -325,6 +325,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
pbLoading = itemView.findViewById(R.id.pbLoading); pbLoading = itemView.findViewById(R.id.pbLoading);
vwRipple = itemView.findViewById(R.id.vwRipple); vwRipple = itemView.findViewById(R.id.vwRipple);
if (viewType == ViewType.THREAD) {
ConstraintLayout inAttachments = itemView.findViewById(R.id.inAttachments); ConstraintLayout inAttachments = itemView.findViewById(R.id.inAttachments);
ConstraintLayout inAttachmentsAlt = itemView.findViewById(R.id.inAttachmentsAlt); ConstraintLayout inAttachmentsAlt = itemView.findViewById(R.id.inAttachmentsAlt);
inAttachments.setVisibility(attachments_alt ? View.GONE : View.VISIBLE); inAttachments.setVisibility(attachments_alt ? View.GONE : View.VISIBLE);
@ -417,6 +418,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
grpAttachments = attachments.findViewById(R.id.grpAttachments); grpAttachments = attachments.findViewById(R.id.grpAttachments);
grpImages = itemView.findViewById(R.id.grpImages); grpImages = itemView.findViewById(R.id.grpImages);
} }
}
Rect getItemRect() { Rect getItemRect() {
return new Rect( return new Rect(
@ -444,6 +446,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivSnoozed.setOnClickListener(this); ivSnoozed.setOnClickListener(this);
ivFlagged.setOnClickListener(this); ivFlagged.setOnClickListener(this);
if (viewType == ViewType.THREAD) {
ivExpanderAddress.setOnClickListener(this); ivExpanderAddress.setOnClickListener(this);
ibSearchContact.setOnClickListener(this); ibSearchContact.setOnClickListener(this);
ibNotifyContact.setOnClickListener(this); ibNotifyContact.setOnClickListener(this);
@ -462,6 +465,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bnvActions.setOnNavigationItemSelectedListener(this); bnvActions.setOnNavigationItemSelectedListener(this);
} }
}
private void unwire() { private void unwire() {
if (viewType == ViewType.THREAD) { if (viewType == ViewType.THREAD) {
@ -473,6 +477,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivSnoozed.setOnClickListener(null); ivSnoozed.setOnClickListener(null);
ivFlagged.setOnClickListener(null); ivFlagged.setOnClickListener(null);
if (viewType == ViewType.THREAD) {
ivExpanderAddress.setOnClickListener(null); ivExpanderAddress.setOnClickListener(null);
ibSearchContact.setOnClickListener(null); ibSearchContact.setOnClickListener(null);
ibNotifyContact.setOnClickListener(null); ibNotifyContact.setOnClickListener(null);
@ -491,6 +496,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bnvActions.setOnNavigationItemSelectedListener(null); bnvActions.setOnNavigationItemSelectedListener(null);
} }
}
private void clear() { private void clear() {
vwColor.setVisibility(View.GONE); vwColor.setVisibility(View.GONE);
@ -531,6 +537,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * (message.unseen > 0 ? 1.1f : 1f)); tvFrom.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * (message.unseen > 0 ? 1.1f : 1f));
tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvSubject.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f); tvPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize * 0.9f);
if (viewType == ViewType.THREAD)
tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize); tvBody.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
int px = Math.round(TypedValue.applyDimension( int px = Math.round(TypedValue.applyDimension(
@ -751,8 +758,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.setBody(message.id, null); properties.setBody(message.id, null);
properties.setHtml(message.id, null); properties.setHtml(message.id, null);
} }
} else }
clearExpanded();
} }
private void clearExpanded() { private void clearExpanded() {
@ -3536,7 +3542,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
if (viewType == ViewType.THREAD)
return (compact ? R.layout.item_message_compact : R.layout.item_message_normal); return (compact ? R.layout.item_message_compact : R.layout.item_message_normal);
else
return (compact ? R.layout.include_message_compact : R.layout.include_message_normal);
} }
@Override @Override

Loading…
Cancel
Save