Remember the map so that we can look up the name later, as well, closes #275

This commit is contained in:
cpfeiffer 2016-04-14 23:55:40 +02:00
parent a460049a1b
commit e451e8155c
1 changed files with 3 additions and 2 deletions

View File

@ -48,6 +48,7 @@ public class AppBlacklistActivity extends GBActivity {
}; };
private SharedPreferences sharedPrefs; private SharedPreferences sharedPrefs;
private IdentityHashMap<ApplicationInfo, String> nameMap;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -61,7 +62,7 @@ public class AppBlacklistActivity extends GBActivity {
ListView appListView = (ListView) findViewById(R.id.appListView); ListView appListView = (ListView) findViewById(R.id.appListView);
// sort the package list by label and blacklist status // sort the package list by label and blacklist status
final IdentityHashMap<ApplicationInfo, String> nameMap = new IdentityHashMap<>(packageList.size()); nameMap = new IdentityHashMap<>(packageList.size());
for (ApplicationInfo ai : packageList) { for (ApplicationInfo ai : packageList) {
CharSequence name = pm.getApplicationLabel(ai); CharSequence name = pm.getApplicationLabel(ai);
if (name == null) { if (name == null) {
@ -98,7 +99,7 @@ public class AppBlacklistActivity extends GBActivity {
CheckBox checkbox = (CheckBox) view.findViewById(R.id.item_checkbox); CheckBox checkbox = (CheckBox) view.findViewById(R.id.item_checkbox);
deviceAppVersionAuthorLabel.setText(appInfo.packageName); deviceAppVersionAuthorLabel.setText(appInfo.packageName);
deviceAppNameLabel.setText(appInfo.loadLabel(pm)); deviceAppNameLabel.setText(nameMap.get(appInfo));
deviceImageView.setImageDrawable(appInfo.loadIcon(pm)); deviceImageView.setImageDrawable(appInfo.loadIcon(pm));
checkbox.setChecked(GBApplication.blacklist.contains(appInfo.packageName)); checkbox.setChecked(GBApplication.blacklist.contains(appInfo.packageName));