From 8f43055b0e16d7356a4e24407dc0dc54443dc0f6 Mon Sep 17 00:00:00 2001 From: tonymanou Date: Mon, 9 Jan 2017 20:38:42 +0100 Subject: [PATCH] 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! --- .../topjohnwu/magisk/adapters/ModulesAdapter.java | 15 ++++----------- .../topjohnwu/magisk/adapters/ReposAdapter.java | 14 +++----------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java index 8f315808d..b3a35b6df 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ModulesAdapter.java @@ -3,6 +3,7 @@ package com.topjohnwu.magisk.adapters; import android.content.Context; import android.support.design.widget.Snackbar; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -41,18 +42,10 @@ public class ModulesAdapter extends RecyclerView.Adapter { diff --git a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java index d05e26f65..5405dc8ef 100644 --- a/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/adapters/ReposAdapter.java @@ -52,18 +52,10 @@ public class ReposAdapter extends RecyclerView.Adapter 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));