improve UI setup here for list to reduce NPE crashes
This commit is contained in:
parent
dedf213028
commit
e7443890c5
|
@ -191,29 +191,38 @@ public class AppManager extends AppCompatActivity implements OnCheckedChangeList
|
||||||
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
|
entry.box = (CheckBox) convertView.findViewById(R.id.itemcheck);
|
||||||
entry.text = (TextView) convertView.findViewById(R.id.itemtext);
|
entry.text = (TextView) convertView.findViewById(R.id.itemtext);
|
||||||
|
|
||||||
entry.text.setOnClickListener(AppManager.this);
|
|
||||||
entry.text.setOnClickListener(AppManager.this);
|
|
||||||
|
|
||||||
convertView.setTag(entry);
|
convertView.setTag(entry);
|
||||||
|
|
||||||
entry.box.setOnCheckedChangeListener(AppManager.this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final TorifiedApp app = mApps.get(position);
|
final TorifiedApp app = mApps.get(position);
|
||||||
|
|
||||||
if (app.getIcon() != null && entry.icon != null)
|
if (entry.icon != null) {
|
||||||
|
if (app.getIcon() != null)
|
||||||
entry.icon.setImageDrawable(app.getIcon());
|
entry.icon.setImageDrawable(app.getIcon());
|
||||||
else
|
else
|
||||||
entry.icon.setVisibility(View.GONE);
|
entry.icon.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.text != null) {
|
||||||
entry.text.setText(app.getName());
|
entry.text.setText(app.getName());
|
||||||
|
entry.text.setOnClickListener(AppManager.this);
|
||||||
|
entry.text.setOnClickListener(AppManager.this);
|
||||||
|
|
||||||
final CheckBox box = entry.box;
|
if (entry.box != null)
|
||||||
box.setTag(app);
|
entry.text.setTag(entry.box);
|
||||||
box.setChecked(app.isTorified());
|
}
|
||||||
|
|
||||||
entry.text.setTag(box);
|
|
||||||
entry.icon.setTag(box);
|
if (entry.box != null) {
|
||||||
|
entry.box.setOnCheckedChangeListener(AppManager.this);
|
||||||
|
entry.box.setTag(app);
|
||||||
|
entry.box.setChecked(app.isTorified());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue