mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-24 10:35:26 +00:00
Extract getItem() method from onBindViewHolder()
This commit is contained in:
parent
1d34ae7934
commit
953a81b299
@ -49,18 +49,8 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||||
Context context = holder.itemView.getContext();
|
Context context = holder.itemView.getContext();
|
||||||
final Repo repo;
|
Repo repo = getItem(position);
|
||||||
if (position >= mUpdateRepos.size()) {
|
|
||||||
position -= mUpdateRepos.size();
|
|
||||||
if (position >= mInstalledRepos.size()) {
|
|
||||||
position -= mInstalledRepos.size();
|
|
||||||
repo = mOthersRepos.get(position);
|
|
||||||
} else {
|
|
||||||
repo = mInstalledRepos.get(position);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
repo = mUpdateRepos.get(position);
|
|
||||||
}
|
|
||||||
holder.title.setText(repo.getName());
|
holder.title.setText(repo.getName());
|
||||||
String author = repo.getAuthor();
|
String author = repo.getAuthor();
|
||||||
String versionName = repo.getVersion();
|
String versionName = repo.getVersion();
|
||||||
@ -122,6 +112,20 @@ public class ReposAdapter extends RecyclerView.Adapter<ReposAdapter.ViewHolder>
|
|||||||
return mUpdateRepos.size() + mInstalledRepos.size() + mOthersRepos.size();
|
return mUpdateRepos.size() + mInstalledRepos.size() + mOthersRepos.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Repo getItem(int position) {
|
||||||
|
if (position >= mUpdateRepos.size()) {
|
||||||
|
position -= mUpdateRepos.size();
|
||||||
|
if (position >= mInstalledRepos.size()) {
|
||||||
|
position -= mInstalledRepos.size();
|
||||||
|
return mOthersRepos.get(position);
|
||||||
|
} else {
|
||||||
|
return mInstalledRepos.get(position);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return mUpdateRepos.get(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
@BindView(R.id.title) TextView title;
|
@BindView(R.id.title) TextView title;
|
||||||
|
Loading…
Reference in New Issue
Block a user