Fix possible list items displaying wrong information

It is better to display empty strings rather than forget to reset
textviews when a viewholder is reused!
This commit is contained in:
tonymanou
2017-01-09 20:38:42 +01:00
committed by topjohnwu
parent 953a81b299
commit 8f43055b0e
2 changed files with 7 additions and 22 deletions

View File

@@ -52,18 +52,10 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
Repo repo = getItem(position);
holder.title.setText(repo.getName());
holder.versionName.setText(repo.getVersion());
String author = repo.getAuthor();
String versionName = repo.getVersion();
String description = repo.getDescription();
if (versionName != null) {
holder.versionName.setText(versionName);
}
if (author != null) {
holder.author.setText(context.getString(R.string.author, author));
}
if (description != null) {
holder.description.setText(description);
}
holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
holder.description.setText(repo.getDescription());
holder.setExpanded(expandList.contains(repo));