Fix view recycling issue (#742)

Fix view issue

Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/742
This commit is contained in:
M M Arif 2020-10-29 13:52:40 +01:00
parent 2064c40c7d
commit 3c7b505b5b
2 changed files with 12 additions and 2 deletions

View File

@ -50,12 +50,13 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
private ImageView assigneesAvatar; private ImageView assigneesAvatar;
private AssigneesViewHolder(View itemView) { private AssigneesViewHolder(View itemView) {
super(itemView); super(itemView);
this.setIsRecyclable(false);
assigneesSelection = itemView.findViewById(R.id.assigneesSelection); assigneesSelection = itemView.findViewById(R.id.assigneesSelection);
assigneesName = itemView.findViewById(R.id.assigneesName); assigneesName = itemView.findViewById(R.id.assigneesName);
assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar); assigneesAvatar = itemView.findViewById(R.id.assigneesAvatar);
} }
} }
@ -73,9 +74,11 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
Collaborators currentItem = assigneesList.get(position); Collaborators currentItem = assigneesList.get(position);
if(currentItem.getFull_name().equals("")) { if(currentItem.getFull_name().equals("")) {
holder.assigneesName.setText(currentItem.getLogin()); holder.assigneesName.setText(currentItem.getLogin());
} }
else { else {
holder.assigneesName.setText(currentItem.getFull_name()); holder.assigneesName.setText(currentItem.getFull_name());
} }
PicassoService PicassoService
@ -90,6 +93,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
} }
currentAssignees = new ArrayList<>(new LinkedHashSet<>(currentAssignees)); currentAssignees = new ArrayList<>(new LinkedHashSet<>(currentAssignees));
for(int i = 0; i < currentAssignees.size(); i++) { for(int i = 0; i < currentAssignees.size(); i++) {
if(currentAssignees.contains(currentItem.getLogin())) { if(currentAssignees.contains(currentItem.getLogin())) {
@ -98,6 +102,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
assigneesStrings.add(currentAssignees.get(i)); assigneesStrings.add(currentAssignees.get(i));
} }
} }
assigneesListener.assigneesInterface(assigneesStrings); assigneesListener.assigneesInterface(assigneesStrings);
holder.assigneesSelection.setOnCheckedChangeListener((buttonView, isChecked) -> { holder.assigneesSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
@ -119,6 +124,7 @@ public class AssigneesListAdapter extends RecyclerView.Adapter<AssigneesListAdap
@Override @Override
public int getItemCount() { public int getItemCount() {
return assigneesList.size(); return assigneesList.size();
} }

View File

@ -48,12 +48,13 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
private ImageView labelColor; private ImageView labelColor;
private LabelsViewHolder(View itemView) { private LabelsViewHolder(View itemView) {
super(itemView); super(itemView);
this.setIsRecyclable(false);
labelSelection = itemView.findViewById(R.id.labelSelection); labelSelection = itemView.findViewById(R.id.labelSelection);
labelText = itemView.findViewById(R.id.labelText); labelText = itemView.findViewById(R.id.labelText);
labelColor = itemView.findViewById(R.id.labelColor); labelColor = itemView.findViewById(R.id.labelColor);
} }
} }
@ -85,6 +86,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
} }
currentLabelsIds = new ArrayList<>(new LinkedHashSet<>(currentLabelsIds)); currentLabelsIds = new ArrayList<>(new LinkedHashSet<>(currentLabelsIds));
for(int i = 0; i < currentLabelsIds.size(); i++) { for(int i = 0; i < currentLabelsIds.size(); i++) {
if(currentLabelsIds.contains(currentItem.getId())) { if(currentLabelsIds.contains(currentItem.getId())) {
@ -93,6 +95,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
labelsIds.add(currentLabelsIds.get(i)); labelsIds.add(currentLabelsIds.get(i));
} }
} }
labelsListener.labelsIdsInterface(labelsIds); labelsListener.labelsIdsInterface(labelsIds);
holder.labelSelection.setOnCheckedChangeListener((buttonView, isChecked) -> { holder.labelSelection.setOnCheckedChangeListener((buttonView, isChecked) -> {
@ -117,6 +120,7 @@ public class LabelsListAdapter extends RecyclerView.Adapter<LabelsListAdapter.La
@Override @Override
public int getItemCount() { public int getItemCount() {
return labels.size(); return labels.size();
} }