Nicer loops. Don't start an iterator if not needed

This commit is contained in:
Daniel Martí 2013-05-03 21:29:31 +02:00
parent 26e7875c02
commit 0efdc9df00

View File

@ -443,10 +443,11 @@ public class AppDetails extends ListActivity {
tv = (TextView) infoView.findViewById(R.id.permissions_list); tv = (TextView) infoView.findViewById(R.id.permissions_list);
if (pref_permissions) { if (pref_permissions) {
CommaSeparatedList permsList = app.apks.get(0).detail_permissions; CommaSeparatedList permsList = app.apks.get(0).detail_permissions;
Iterator<String> permissions = permsList != null ? permsList.iterator() : null; if (permsList == null) tv.setText("NONE");
if (null != permissions && permissions.hasNext()) { else {
Iterator<String> permissions = permsList.iterator();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
while(permissions.hasNext()) { while (permissions.hasNext()) {
String permissionName = permissions.next(); String permissionName = permissions.next();
try { try {
Permission permission = new Permission(this, permissionName); Permission permission = new Permission(this, permissionName);
@ -460,8 +461,6 @@ public class AppDetails extends ListActivity {
} }
} }
tv.setText(sb.toString()); tv.setText(sb.toString());
} else {
tv.setText("NONE");
} }
tv = (TextView) infoView.findViewById(R.id.permissions); tv = (TextView) infoView.findViewById(R.id.permissions);
tv.setText(getResources().getString( tv.setText(getResources().getString(