Commit 8f43055b authored by tonymanou's avatar tonymanou Committed by topjohnwu

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!
parent 953a81b2
...@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.adapters; ...@@ -3,6 +3,7 @@ package com.topjohnwu.magisk.adapters;
import android.content.Context; import android.content.Context;
import android.support.design.widget.Snackbar; import android.support.design.widget.Snackbar;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -41,18 +42,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold ...@@ -41,18 +42,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
final Module module = mList.get(position); final Module module = mList.get(position);
holder.title.setText(module.getName()); holder.title.setText(module.getName());
holder.versionName.setText(module.getVersion());
String author = module.getAuthor(); String author = module.getAuthor();
String versionName = module.getVersion(); holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
String description = module.getDescription(); holder.description.setText(module.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.checkBox.setChecked(module.isEnabled()); holder.checkBox.setChecked(module.isEnabled());
holder.checkBox.setOnClickListener((v) -> { holder.checkBox.setOnClickListener((v) -> {
......
...@@ -52,18 +52,10 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder> ...@@ -52,18 +52,10 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
Repo repo = getItem(position); Repo repo = getItem(position);
holder.title.setText(repo.getName()); holder.title.setText(repo.getName());
holder.versionName.setText(repo.getVersion());
String author = repo.getAuthor(); String author = repo.getAuthor();
String versionName = repo.getVersion(); holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
String description = repo.getDescription(); holder.description.setText(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.setExpanded(expandList.contains(repo)); holder.setExpanded(expandList.contains(repo));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment