Example usage for java.util List isEmpty

List of usage examples for java.util List isEmpty

Introduction

In this page you can find the example usage for java.util List isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:Main.java

public static String getCurProcessName(Context context) {
    int pid = android.os.Process.myPid();
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

    if (activityManager == null) {
        return null;
    }//from   www. j  a v a 2 s . co  m

    List<RunningAppProcessInfo> runningProcessList = activityManager.getRunningAppProcesses();
    if (runningProcessList == null || runningProcessList.isEmpty()) {
        return null;
    }

    for (ActivityManager.RunningAppProcessInfo appProcess : runningProcessList) {
        if (appProcess.pid == pid) {
            return appProcess.processName;
        }
    }
    return null;
}

From source file:Main.java

public static void findViewIdAndClick(AccessibilityService accessibilityService, String id) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;/*from w  w w.  j av  a  2  s.  c  o  m*/
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByViewId(id);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}

From source file:Main.java

/**
 * Intent chooser is customized to remove unwanted apps.
 * 1. FaceBook has bug where only links can be shared.
 * 2. Cannot share this type of content via Google Docs and Skype.
 *///from  w  w w.  j a va 2 s  .  c  o  m
public static void ShareResult(Context mContext, String mResult, String mTitle) {
    List<Intent> targetedShareIntents = new ArrayList<Intent>();
    Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    List<ResolveInfo> resInfo = mContext.getPackageManager().queryIntentActivities(shareIntent, 0);
    if (!resInfo.isEmpty()) {
        for (ResolveInfo resolveInfo : resInfo) {
            String packageName = resolveInfo.activityInfo.packageName;
            Intent targetedShareIntent = new Intent(android.content.Intent.ACTION_SEND);
            targetedShareIntent.setType("text/plain");
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TITLE, mTitle);
            targetedShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mResult);
            if (!packageName.toLowerCase().contains("com.facebook.katana")
                    && !packageName.toLowerCase().contains("com.google.android.apps.docs")
                    && !packageName.toLowerCase().contains("com.skype.raider")) {
                targetedShareIntent.setPackage(packageName);
                targetedShareIntents.add(targetedShareIntent);
            }
        }
        Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(0), "Send your result");
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[] {}));
        mContext.startActivity(chooserIntent);
    }
    return;
}

From source file:de.oth.keycloak.InitKeycloakServer.java

private static void addApps(RealmResource rRes, List<AppConfig> appList) {
    if (appList == null || appList.isEmpty()) {
        log.info("no apps found");
        return;//  w w  w  .  j  a va  2s . c om
    }
    for (AppConfig app : appList) {
        String name = app.getName();
        ClientResource cRes = KeycloakAccess.getClientFromRealm(rRes, name);
        if (cRes == null) {
            cRes = KeycloakAccess.addClientToRealm(rRes, name, app.getRedirectUrls(), app.getAppRoles());
            KeycloakAccess.addMissedRedirectUrls(rRes, cRes, app.getRedirectUrls());
            KeycloakAccess.addMissedClientRoles(rRes, cRes, app.getAppRoles());
        }
    }
}

From source file:Main.java

public static void findTextAndClick(AccessibilityService accessibilityService, String text) {

    AccessibilityNodeInfo accessibilityNodeInfo = accessibilityService.getRootInActiveWindow();
    if (accessibilityNodeInfo == null) {
        return;/*from  ww  w. j  av  a 2 s  . c  o m*/
    }

    List<AccessibilityNodeInfo> nodeInfoList = accessibilityNodeInfo.findAccessibilityNodeInfosByText(text);
    if (nodeInfoList != null && !nodeInfoList.isEmpty()) {
        for (AccessibilityNodeInfo nodeInfo : nodeInfoList) {
            if (nodeInfo != null
                    && (text.equals(nodeInfo.getText()) || text.equals(nodeInfo.getContentDescription()))) {
                performClick(nodeInfo);
                break;
            }
        }
    }
}

From source file:org.cloudfoundry.reconfiguration.play.Configurer.java

private static void processDatabase(ApplicationConfiguration applicationConfiguration, Cloud cloud,
        String name) {//from ww w .  jav  a2 s.c o  m
    List<ServiceInfo> serviceInfos = cloud.getServiceInfos(DataSource.class);

    if (serviceInfos.isEmpty()) {
        LOGGER.info("No matching service found. Skipping auto-reconfiguration.");
    } else if (serviceInfos.size() > 1) {
        LOGGER.warning(
                String.format("More than one (%d) matching services found. Skipping auto-reconfiguration.",
                        serviceInfos.size()));
    } else {
        configureDatabase(name, (RelationalServiceInfo) serviceInfos.get(0));
        configureJpa(applicationConfiguration);
    }

}

From source file:com.cloudera.oryx.kmeans.computation.local.WeightedPointsByFold.java

private static KSketchIndex buildIndex(List<List<RealVector>> foldVecs, ClusterSettings settings) {
    if (foldVecs.isEmpty()) {
        throw new IllegalStateException("No input vectors found for sketch building");
    }/*from w  w  w.  j av a2 s.c  o m*/
    KSketchIndex index = new KSketchIndex(foldVecs.size(), foldVecs.get(0).get(0).getDimension(),
            settings.getIndexBits(), settings.getIndexSamples(), 1729L);
    for (int i = 0; i < foldVecs.size(); i++) {
        if (!foldVecs.get(i).isEmpty()) {
            index.add(foldVecs.get(i).get(0), i);
        }
    }
    index.rebuildIndices();
    return index;
}

From source file:Main.java

@SuppressWarnings("unchecked")
public static <T> void removeDuplicate(List<T> dest, List<T> src) {
    if (dest == null) {
        return;/*from ww  w  .  j  av a 2  s .c  o m*/
    }

    if (src == null || src.isEmpty()) {
        return;
    }

    int capacity = dest.size() > src.size() ? dest.size() : src.size();
    HashMap<T, Integer> map = new HashMap<T, Integer>(capacity);
    for (int i = 0; i < dest.size(); i++) {
        map.put(dest.get(i), i);
    }

    T[] oldData = (T[]) dest.toArray();
    int length = oldData.length;
    for (T t : src) {
        Integer index = map.get(t);
        if (index != null) {
            oldData[index] = null;
            length--;
        }
    }

    T[] removedDuplicate = (T[]) new Object[length];
    int index = 0;
    for (int i = 0; i < oldData.length; i++) {
        if (oldData[i] != null) {
            removedDuplicate[index++] = oldData[i];
        }
    }

    dest.clear();
    dest.addAll(Arrays.asList(removedDuplicate));
}

From source file:Main.java

public static boolean isFlashSupported(Camera camera, Context context) {

    mPreferences = PreferenceManager.getDefaultSharedPreferences(context);
    if (camera != null) {
        Camera.Parameters mParameters = camera.getParameters();

        if (mParameters.getFlashMode() == null) {
            mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", false).commit();
            return false;
        }/*from   ww  w. j  av  a 2  s. co  m*/

        List<String> mSupportedFlashModes = mParameters.getSupportedFlashModes();
        if (mSupportedFlashModes == null || mSupportedFlashModes.isEmpty() || mSupportedFlashModes.size() == 1
                && mSupportedFlashModes.get(0).equals(Camera.Parameters.FLASH_MODE_OFF)) {
            mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", false).commit();
            return false;
        }
    } else {
        mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", false).commit();
        return false;
    }

    mPrefFlash = mPreferences.edit().putBoolean("mPrefFlash", true).commit();
    return true;
}

From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.domain.impl.CompositeReportExecutionListener.java

public static ReportExecutionListener asListener(List<ReportExecutionListener> listeners) {
    if (listeners == null || listeners.isEmpty()) {
        return EMPTY;
    }//from   ww w  . j  a v  a 2  s.co  m

    if (listeners.size() == 1) {
        return listeners.get(0);
    }

    return new CompositeReportExecutionListener(listeners);
}