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

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

Loading…
Cancel
Save