use Collections' isEmpty() to test for emptiness
This should make the code intent clearer and more standard Java.
This commit is contained in:
parent
c7f3910472
commit
c987e6ad4c
@ -199,7 +199,7 @@ class NotificationHelper {
|
|||||||
|
|
||||||
Notification notification;
|
Notification notification;
|
||||||
if (updates.size() != 1 || useStackedNotifications()) {
|
if (updates.size() != 1 || useStackedNotifications()) {
|
||||||
if (updates.size() == 0) {
|
if (updates.isEmpty()) {
|
||||||
// No updates, remove summary
|
// No updates, remove summary
|
||||||
notificationManager.cancel(GROUP_UPDATES, NOTIFY_ID_UPDATES);
|
notificationManager.cancel(GROUP_UPDATES, NOTIFY_ID_UPDATES);
|
||||||
} else {
|
} else {
|
||||||
@ -208,7 +208,7 @@ class NotificationHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (installed.size() != 1 || useStackedNotifications()) {
|
if (installed.size() != 1 || useStackedNotifications()) {
|
||||||
if (installed.size() == 0) {
|
if (installed.isEmpty()) {
|
||||||
// No installed, remove summary
|
// No installed, remove summary
|
||||||
notificationManager.cancel(GROUP_INSTALLED, NOTIFY_ID_INSTALLED);
|
notificationManager.cancel(GROUP_INSTALLED, NOTIFY_ID_INSTALLED);
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,8 +64,8 @@ public class Provisioner {
|
|||||||
List<ProvisionPlaintext> plaintexts = p.extractProvisionsPlaintext(files);
|
List<ProvisionPlaintext> plaintexts = p.extractProvisionsPlaintext(files);
|
||||||
List<Provision> provisions = p.parseProvisions(plaintexts);
|
List<Provision> provisions = p.parseProvisions(plaintexts);
|
||||||
|
|
||||||
if (provisions == null || provisions.size() == 0) {
|
if (provisions == null || provisions.isEmpty()) {
|
||||||
Utils.debugLog(TAG, "Provision dir does not contain any provisions: '" + provisionDir.getAbsolutePath() + "' moving on ...");
|
Utils.debugLog(TAG, "Provision dir is empty: '" + provisionDir.getAbsolutePath() + "' moving on ...");
|
||||||
} else {
|
} else {
|
||||||
int cleanupCounter = 0;
|
int cleanupCounter = 0;
|
||||||
for (Provision provision : provisions) {
|
for (Provision provision : provisions) {
|
||||||
|
@ -638,7 +638,7 @@ public class AppProvider extends FDroidProvider {
|
|||||||
// Put in a Set to remove duplicates
|
// Put in a Set to remove duplicates
|
||||||
final Set<String> keywordSet = new HashSet<>(Arrays.asList(query.split("\\s")));
|
final Set<String> keywordSet = new HashSet<>(Arrays.asList(query.split("\\s")));
|
||||||
|
|
||||||
if (keywordSet.size() == 0) {
|
if (keywordSet.isEmpty()) {
|
||||||
return new AppQuerySelection();
|
return new AppQuerySelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ abstract class QueryBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String orderBySql() {
|
private String orderBySql() {
|
||||||
if (orderBys.size() == 0) {
|
if (orderBys.isEmpty()) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return " ORDER BY " + TextUtils.join(", ", orderBys);
|
return " ORDER BY " + TextUtils.join(", ", orderBys);
|
||||||
|
@ -182,12 +182,12 @@ public class RepoPersister {
|
|||||||
private void calcApkCompatibilityFlags(List<Apk> apks) {
|
private void calcApkCompatibilityFlags(List<Apk> apks) {
|
||||||
for (final Apk apk : apks) {
|
for (final Apk apk : apks) {
|
||||||
final List<String> reasons = checker.getIncompatibleReasons(apk);
|
final List<String> reasons = checker.getIncompatibleReasons(apk);
|
||||||
if (reasons.size() > 0) {
|
if (reasons.isEmpty()) {
|
||||||
apk.compatible = false;
|
|
||||||
apk.incompatibleReasons = reasons.toArray(new String[reasons.size()]);
|
|
||||||
} else {
|
|
||||||
apk.compatible = true;
|
apk.compatible = true;
|
||||||
apk.incompatibleReasons = null;
|
apk.incompatibleReasons = null;
|
||||||
|
} else {
|
||||||
|
apk.compatible = false;
|
||||||
|
apk.incompatibleReasons = reasons.toArray(new String[reasons.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
|
|
||||||
boolean haveTriedWithoutPath = false;
|
boolean haveTriedWithoutPath = false;
|
||||||
while (repo == null && !haveTriedWithoutPath) {
|
while (repo == null && !haveTriedWithoutPath) {
|
||||||
if (pathSegments.size() == 0) {
|
if (pathSegments.isEmpty()) {
|
||||||
haveTriedWithoutPath = true;
|
haveTriedWithoutPath = true;
|
||||||
} else {
|
} else {
|
||||||
pathSegments.remove(pathSegments.size() - 1);
|
pathSegments.remove(pathSegments.size() - 1);
|
||||||
@ -99,7 +99,11 @@ public class RepoProvider extends FDroidProvider {
|
|||||||
String address, String[] projection) {
|
String address, String[] projection) {
|
||||||
List<Repo> repos = findBy(
|
List<Repo> repos = findBy(
|
||||||
context, Cols.ADDRESS, address, projection);
|
context, Cols.ADDRESS, address, projection);
|
||||||
return repos.size() > 0 ? repos.get(0) : null;
|
if (repos.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return repos.get(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Repo> all(Context context) {
|
public static List<Repo> all(Context context) {
|
||||||
|
@ -153,13 +153,13 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
addItem(VIEWTYPE_DONATE);
|
addItem(VIEWTYPE_DONATE);
|
||||||
addItem(VIEWTYPE_LINKS);
|
addItem(VIEWTYPE_LINKS);
|
||||||
addItem(VIEWTYPE_PERMISSIONS);
|
addItem(VIEWTYPE_PERMISSIONS);
|
||||||
if (versions.size() > 0) {
|
if (versions.isEmpty()) {
|
||||||
|
addItem(VIEWTYPE_NO_VERSIONS);
|
||||||
|
} else {
|
||||||
addItem(VIEWTYPE_VERSIONS);
|
addItem(VIEWTYPE_VERSIONS);
|
||||||
if (showVersions) {
|
if (showVersions) {
|
||||||
setShowVersions(true);
|
setShowVersions(true);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
addItem(VIEWTYPE_NO_VERSIONS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
@ -563,7 +563,7 @@ public class AppDetailsRecyclerViewAdapter
|
|||||||
|
|
||||||
updateAntiFeaturesWarning();
|
updateAntiFeaturesWarning();
|
||||||
buttonPrimaryView.setText(R.string.menu_install);
|
buttonPrimaryView.setText(R.string.menu_install);
|
||||||
buttonPrimaryView.setVisibility(versions.size() > 0 ? View.VISIBLE : View.GONE);
|
buttonPrimaryView.setVisibility(versions.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
buttonSecondaryView.setText(R.string.menu_uninstall);
|
buttonSecondaryView.setText(R.string.menu_uninstall);
|
||||||
buttonSecondaryView.setVisibility(app.isUninstallable(context) ? View.VISIBLE : View.INVISIBLE);
|
buttonSecondaryView.setVisibility(app.isUninstallable(context) ? View.VISIBLE : View.INVISIBLE);
|
||||||
buttonSecondaryView.setOnClickListener(new View.OnClickListener() {
|
buttonSecondaryView.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -840,7 +840,7 @@ public class RepoXMLHandlerTest {
|
|||||||
for (App app : apps) {
|
for (App app : apps) {
|
||||||
if (expectedAntiFeatures.containsKey(app.packageName)) {
|
if (expectedAntiFeatures.containsKey(app.packageName)) {
|
||||||
List<String> antiFeatures = expectedAntiFeatures.get(app.packageName);
|
List<String> antiFeatures = expectedAntiFeatures.get(app.packageName);
|
||||||
if (antiFeatures.size() == 0) {
|
if (antiFeatures.isEmpty()) {
|
||||||
assertNull(app.antiFeatures);
|
assertNull(app.antiFeatures);
|
||||||
} else {
|
} else {
|
||||||
List<String> actualAntiFeatures = new ArrayList<>();
|
List<String> actualAntiFeatures = new ArrayList<>();
|
||||||
|
@ -423,7 +423,7 @@ public class IndexV1UpdaterTest extends FDroidProviderTest {
|
|||||||
for (String field : allowed) {
|
for (String field : allowed) {
|
||||||
fields.remove(field);
|
fields.remove(field);
|
||||||
}
|
}
|
||||||
if (fields.size() > 0) {
|
if (!fields.isEmpty()) {
|
||||||
String sb = String.valueOf(instance.getClass()) + " has fields not setup for Jackson: " +
|
String sb = String.valueOf(instance.getClass()) + " has fields not setup for Jackson: " +
|
||||||
TextUtils.join(", ", fields) + "\nRead class javadoc for more info.";
|
TextUtils.join(", ", fields) + "\nRead class javadoc for more info.";
|
||||||
fail(sb);
|
fail(sb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user