Failed attempt to fix scroll lag

pull/162/head
M66B 5 years ago
parent b4e71d3644
commit 14703eb12a

@ -402,7 +402,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibHelp = itemView.findViewById(R.id.ibHelp);
pbLoading = itemView.findViewById(R.id.pbLoading);
if (compact && tvSubject != null)
if (tvSubject != null) {
tvSubject.setTextColor(colorRead);
if (compact)
if ("start".equals(subject_ellipsize))
tvSubject.setEllipsize(TextUtils.TruncateAt.START);
else if ("end".equals(subject_ellipsize))
@ -410,6 +413,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
else
tvSubject.setEllipsize(TextUtils.TruncateAt.MIDDLE);
}
}
private void ensureExpanded() {
if (vsBody != null)
@ -751,18 +755,28 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvCount.setTypeface(typeface);
int colorUnseen = (message.unseen > 0 ? colorUnread : colorRead);
if (tvFrom.getTag() == null || (int) tvFrom.getTag() != colorUnseen) {
tvFrom.setTag(colorUnseen);
tvFrom.setTextColor(colorUnseen);
tvSize.setTextColor(colorUnseen);
tvTime.setTextColor(colorUnseen);
tvSubject.setTextColor(colorRead);
}
// Account color
vwColor.setVisibility(View.VISIBLE);
vwColor.setBackgroundColor(message.accountColor == null || !ActivityBilling.isPro(context)
int colorBackground =
(message.accountColor == null || !ActivityBilling.isPro(context)
? colorSeparator : message.accountColor);
vwColor.setVisibility(View.VISIBLE);
if (vwColor.getTag() == null || (int) vwColor.getTag() != colorBackground) {
vwColor.setTag(colorBackground);
vwColor.setBackgroundColor(colorBackground);
}
// Expander
if (ibExpander.getTag() == null || (boolean) ibExpander.getTag() != expanded) {
ibExpander.setTag(expanded);
ibExpander.setImageLevel(expanded ? 0 /* less */ : 1 /* more */);
}
if (viewType == ViewType.THREAD)
ibExpander.setVisibility(EntityFolder.DRAFTS.equals(message.folderType) ? View.INVISIBLE : View.VISIBLE);
else
@ -788,17 +802,22 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
Boolean.FALSE.equals(message.mx));
// Line 3
int icon;
if (outgoing && !EntityFolder.SENT.equals(message.folderType)) {
ivType.setImageResource(EntityFolder.getIcon(EntityFolder.SENT));
icon = EntityFolder.getIcon(EntityFolder.SENT);
ivType.setVisibility(View.VISIBLE);
} else {
ivType.setImageResource(message.drafts > 0
icon = (message.drafts > 0
? R.drawable.baseline_edit_24 : EntityFolder.getIcon(message.folderType));
ivType.setVisibility(message.drafts > 0 ||
(viewType == ViewType.UNIFIED && type == null && !inbox) ||
(viewType == ViewType.THREAD && EntityFolder.SENT.equals(message.folderType))
? View.VISIBLE : View.GONE);
}
if (ivType.getTag() == null || (int) ivType.getTag() != icon) {
ivType.setTag(icon);
ivType.setImageResource(icon);
}
ivPriority.setVisibility(EntityMessage.PRIORITIY_HIGH.equals(message.priority) ? View.VISIBLE : View.GONE);
ibAuth.setVisibility(authentication && !authenticated ? View.VISIBLE : View.GONE);
@ -832,7 +851,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
bindFlagged(message, expanded);
// Message text preview
tvPreview.setTextColor(contrast ? textColorPrimary : textColorSecondary);
int textColor = (contrast ? textColorPrimary : textColorSecondary);
if (tvPreview.getTag() == null || (int) tvPreview.getTag() != textColor) {
tvPreview.setTag(textColor);
tvPreview.setTextColor(textColor);
}
tvPreview.setTypeface(
monospaced ? Typeface.MONOSPACE : Typeface.DEFAULT,
preview_italic ? Typeface.ITALIC : Typeface.NORMAL);

@ -46,11 +46,15 @@ public class ViewCardOptional extends CardView {
setCardBackgroundColor(Color.TRANSPARENT);
}
private boolean initialized = false;
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
if (!initialized) {
initialized = true;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
boolean compact = prefs.getBoolean("compact", false);
@ -69,9 +73,15 @@ public class ViewCardOptional extends CardView {
setCardElevation(0);
}
}
private Integer color = null;
@Override
public void setCardBackgroundColor(int color) {
if (this.color == null || this.color != color) {
this.color = color;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean cards = prefs.getBoolean("cards", true);
if (cards && color == Color.TRANSPARENT)
@ -79,4 +89,5 @@ public class ViewCardOptional extends CardView {
super.setCardBackgroundColor(color);
}
}
}

Loading…
Cancel
Save