Use apkName to keep track of expanded version items

This commit is contained in:
wsdfhjxc 2018-09-03 17:14:36 +02:00
parent 8b30179ac2
commit 62f1a60949

View File

@ -107,7 +107,7 @@ public class AppDetailsRecyclerViewAdapter
private HeaderViewHolder headerView;
private Apk downloadedApk;
private final HashMap<Integer, Boolean> versionsExpandTracker = new HashMap<>();
private final HashMap<String, Boolean> versionsExpandTracker = new HashMap<>();
public AppDetailsRecyclerViewAdapter(Context context, @NonNull App app, AppDetailsRecyclerViewAdapterCallbacks callbacks) {
this.context = context;
@ -131,8 +131,8 @@ public class AppDetailsRecyclerViewAdapter
compatibleVersionsDifferentSig.add(apk);
if (allowBySig) {
versions.add(apk);
if (!versionsExpandTracker.containsKey(apk.versionCode)) {
versionsExpandTracker.put(apk.versionCode, false);
if (!versionsExpandTracker.containsKey(apk.apkName)) {
versionsExpandTracker.put(apk.apkName, false);
}
}
}
@ -1102,7 +1102,7 @@ public class AppDetailsRecyclerViewAdapter
}
// Expand the view if it was previously expanded or when downloading
expand(versionsExpandTracker.get(apk.versionCode) || isApkDownloading);
expand(versionsExpandTracker.get(apk.apkName) || isApkDownloading);
// Toggle expanded view when clicking the whole version item
itemView.setOnClickListener(new View.OnClickListener() {
@ -1168,7 +1168,7 @@ public class AppDetailsRecyclerViewAdapter
}
private void expand(boolean expand) {
versionsExpandTracker.put(apk.versionCode, expand);
versionsExpandTracker.put(apk.apkName, expand);
expandedLayout.setVisibility(expand ? View.VISIBLE : View.GONE);
expandArrow.setImageDrawable(ContextCompat.getDrawable(context, expand ?
R.drawable.ic_expand_less_grey600 : R.drawable.ic_expand_more_grey600));
@ -1188,7 +1188,7 @@ public class AppDetailsRecyclerViewAdapter
return;
}
boolean expand = !versionsExpandTracker.get(apk.versionCode);
boolean expand = !versionsExpandTracker.get(apk.apkName);
expand(expand);
if (expand) {