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