Clear recycled views

This commit is contained in:
M66B 2019-10-10 10:13:19 +02:00
parent 194a1f9c74
commit 88705707fd
1 changed files with 8 additions and 3 deletions

View File

@ -629,7 +629,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
}
private void clear() {
private void clear(boolean loading) {
ivAvatarStart.setVisibility(View.GONE);
ivAvatarEnd.setVisibility(View.GONE);
vwColor.setVisibility(View.GONE);
@ -655,7 +655,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvPreview.setVisibility(View.GONE);
tvError.setVisibility(View.GONE);
ibHelp.setVisibility(View.GONE);
pbLoading.setVisibility(View.VISIBLE);
pbLoading.setVisibility(loading ? View.VISIBLE : View.GONE);
clearExpanded(null);
}
@ -4029,7 +4029,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
holder.unwire();
if (message == null || context == null)
holder.clear();
holder.clear(true);
else {
holder.bindTo(message);
holder.wire();
@ -4044,6 +4044,11 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
holder.powner.recreate();
}
@Override
public void onViewRecycled(@NonNull ViewHolder holder) {
holder.clear(false);
}
void setSelectionTracker(SelectionTracker<Long> selectionTracker) {
this.selectionTracker = selectionTracker;
}