Optimizations

pull/177/head
M66B 5 years ago
parent 8ea6a184b2
commit c0cc107d14

@ -815,7 +815,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
@SuppressLint("WrongConstant") @SuppressLint("WrongConstant")
private void bindTo(final TupleMessageEx message, int position) { private void bindTo(final TupleMessageEx message) {
boolean inbox = EntityFolder.INBOX.equals(message.folderType); boolean inbox = EntityFolder.INBOX.equals(message.folderType);
boolean outbox = EntityFolder.OUTBOX.equals(message.folderType); boolean outbox = EntityFolder.OUTBOX.equals(message.folderType);
boolean outgoing = isOutgoing(message); boolean outgoing = isOutgoing(message);
@ -2631,7 +2631,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} else { } else {
message.ui_seen = !message.ui_seen; message.ui_seen = !message.ui_seen;
message.unseen = (message.ui_seen ? 0 : message.count); message.unseen = (message.ui_seen ? 0 : message.count);
bindTo(message, getAdapterPosition()); bindTo(message);
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", message.id); args.putLong("id", message.id);
@ -3007,8 +3007,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
else { else {
boolean expanded = !properties.getValue("expanded", message.id); boolean expanded = !properties.getValue("expanded", message.id);
properties.setExpanded(message, expanded); properties.setExpanded(message, expanded);
bindTo(message, getAdapterPosition()); bindTo(message);
properties.scrollTo(getAdapterPosition(), 0); if (expanded)
properties.scrollTo(getAdapterPosition(), 0);
} }
} }
@ -3617,7 +3618,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
properties.setExpanded(message, false); properties.setExpanded(message, false);
message.ui_seen = args.getBoolean("seen"); message.ui_seen = args.getBoolean("seen");
message.unseen = (message.ui_seen ? 0 : message.count); message.unseen = (message.ui_seen ? 0 : message.count);
bindTo(message, getAdapterPosition()); bindTo(message);
} }
@Override @Override
@ -4882,10 +4883,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
holder.unwire(); holder.unwire();
holder.bindTo(message, position); holder.bindTo(message);
holder.wire(); holder.wire();
} }
public void collapse(@NonNull ViewHolder holder, int position) {
TupleMessageEx message = getItemAtPosition(position);
if (message != null)
holder.clearExpanded(message);
}
public void focusBody(@NonNull ViewHolder holder, int position) { public void focusBody(@NonNull ViewHolder holder, int position) {
if (holder.tvBody != null && holder.tvBody.getVisibility() == View.VISIBLE) if (holder.tvBody != null && holder.tvBody.getVisibility() == View.VISIBLE)
holder.tvBody.requestFocus(); holder.tvBody.requestFocus();

@ -1429,9 +1429,15 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
for (Long other : new ArrayList<>(values.get("expanded"))) for (Long other : new ArrayList<>(values.get("expanded")))
if (!other.equals(message.id)) { if (!other.equals(message.id)) {
values.get("expanded").remove(other); values.get("expanded").remove(other);
int pos = adapter.getPositionForKey(other); int pos = adapter.getPositionForKey(other);
if (pos != NO_POSITION) if (pos == NO_POSITION)
adapter.notifyItemChanged(pos); continue;
AdapterMessage.ViewHolder holder =
(AdapterMessage.ViewHolder) rvMessage.findViewHolderForAdapterPosition(pos);
if (holder == null)
continue;
adapter.collapse(holder, pos);
} }
} }

Loading…
Cancel
Save