Example usage for java.util ArrayList get

List of usage examples for java.util ArrayList get

Introduction

In this page you can find the example usage for java.util ArrayList get.

Prototype

public E get(int index) 

Source Link

Document

Returns the element at the specified position in this list.

Usage

From source file:com.integryst.kdbrowser.PTHelpers.PTPropertyHelper.java

public static int getPropId(String propName) {
    ArrayList properties = PropertyHelper.getProperties(null);
    for (int x = 0; x < properties.size(); x++) {
        Property tempProp = (Property) properties.get(x);
        if (propName.equals(tempProp.getName()))
            return tempProp.getId();
    }/*from www . j a v  a  2  s  .  co  m*/
    return -1;
}

From source file:Main.java

/**
 * Given a list of coordinates, calculate the total distance travelled.
 *
 * @param gpsCoordArray ArrayList of Location objects. Users route
 * @return Integer total distance in meters.
 *//*from w  w  w.j  a v  a 2  s.co  m*/
public static int calculateTotalDistance(ArrayList<Location> gpsCoordArray) {
    int totalDistance = 0;

    for (int i = 1; i < gpsCoordArray.size(); i++) {
        totalDistance += getDistance(gpsCoordArray.get(i - 1), gpsCoordArray.get(i));
    }

    return totalDistance;
}

From source file:Main.java

public static int indexOfItem(ArrayList<String> list, final String item) {
    if (item == null || list.isEmpty()) {
        return -1;
    }//w  w  w  .j av a  2s .c o m
    for (int i = 0; i < list.size(); i++) {
        if (item.equals(list.get(i))) {
            return i;
        }
    }
    return -1;
}

From source file:Main.java

public static String[] getOccupantsIdsArrayFromList(ArrayList<Integer> occupantsList) {
    String[] occupantsArray = new String[occupantsList.size()];
    for (int i = 0; i < occupantsList.size(); i++) {
        occupantsArray[i] = String.valueOf(occupantsList.get(i));
    }// w  w w .  j  a  va  2s.  c  o  m
    return occupantsArray;
}

From source file:Main.java

public static void removeStringFromArrayList(String strItem, ArrayList<String> alItems) {

    // cycles on the arraylist
    for (int j = 0; j < alItems.size(); j++) {

        // gets the j-thg item
        String strValue = alItems.get(j);

        // if the j-th item is equal to the passed one
        if (strValue.equals(strItem)) {

            // removes it
            alItems.remove(j);/* w  w w.  j ava  2s .  co m*/

            // and returns
            return;
        }

    }

}

From source file:Main.java

public static String getExSdCardPath() {
    if ("".equals(exSdCardPath)) {
        ArrayList<String> paths = (ArrayList<String>) getExtSDCardPaths();
        if (paths.size() != 0) {
            exSdCardPath = paths.get(0) + "/";
        } else {/*from   ww w .ja v  a 2  s  .  co  m*/
            exSdCardPath = null;
        }
    }

    return exSdCardPath;
}

From source file:Main.java

/**
 * Devuelve true si las dos ArrayList que se le pasan como parametro son
 * iguales.//from   w  ww . j av a 2  s  .  c  om
 * 
 * @param n
 *            lista anterior
 * @param l
 *            lista actual
 * 
 * @return true si los ArrayList son iguales.
 */
public static boolean isEqualList(ArrayList n, ArrayList l) {
    if (n.size() != l.size()) {
        return false;
    }

    for (int i = 0; i < n.size(); i++) {
        if (l.get(i) != n.get(i)) {
            return false;
        }
    }

    return true;
}

From source file:Main.java

public static boolean serviceIsWorking(Context context, Class<?> clazz) {
    ActivityManager myManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    ArrayList<RunningServiceInfo> runningService = (ArrayList<RunningServiceInfo>) myManager
            .getRunningServices(30);// w w  w .ja  v a 2  s  .  com
    for (int i = 0; i < runningService.size(); i++) {
        if (runningService.get(i).service.getClassName().toString().equals(clazz.getName())) {// "pr.android.taojia.service.MsgService"
            return true;
        }
    }
    return false;
}

From source file:Main.java

public static ViewFlipper creativeFlipper(Context context, ArrayList<View> addView, int in_ani, int out_ani) {
    ViewFlipper flipper = creativeFlipper(context);
    for (int i = 0; i < addView.size(); i++)
        flipper.addView(addView.get(i));
    setAnimation(context, flipper, in_ani, out_ani);
    return flipper;
}

From source file:com.asual.summer.core.util.BeanUtils.java

public static <T> T getBeanOfType(ConfigurableListableBeanFactory beanFactory, Class<T> clazz) {
    Map<String, T> beans = beanFactory.getBeansOfType(clazz);
    ArrayList<T> values = new ArrayList<T>(beans.values());
    if (values.size() != 0) {
        OrderComparator.sort(values);//  w  w  w  .  ja  va  2  s . c om
        return values.get(0);
    }
    return null;
}