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:Main.java

public static String[] removeLocalUserNameFromArray(String[] user) {
    ArrayList<String> userList = new ArrayList<String>();
    for (int i = 0; i < user.length; i++) {
        Log.d("i=" + i, user[i]);
        if (USER_NAME.equals(user[i]) == false) {
            userList.add(user[i]);//from   w  ww .  ja va2  s .c o m
        }
    }
    String returnArray[] = new String[userList.size()];
    for (int i = 0; i < returnArray.length; i++) {
        returnArray[i] = userList.get(i).toString();
    }
    return returnArray;
}

From source file:io.jxcore.node.jxcore.java

public static void javaCall(ArrayList<Object> params) {
    if (params.size() < 2 || params.get(0).getClass() != String.class
            || params.get(params.size() - 1).getClass() != String.class) {
        Log.e(LOGTAG, "JavaCall recevied an unknown call");
        return;//  w  w w. j a v  a  2s . c  om
    }

    String receiver = params.remove(0).toString();
    String callId = params.remove(params.size() - 1).toString();

    if (!java_callbacks.containsKey(receiver)) {
        Log.e(LOGTAG, "JavaCall recevied a call for unknown method " + receiver);
        return;
    }

    java_callbacks.get(receiver).Receiver(params, callId);
}

From source file:Main.java

private static void replaceAllCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) {
    final ArrayList<Preference> preferences = new ArrayList<>();
    final int count = group.getPreferenceCount();
    for (int index = 0; index < count; index++) {
        preferences.add(group.getPreference(index));
    }//  w  w w.jav a  2 s . c om
    group.removeAll();
    for (int index = 0; index < count; index++) {
        final Preference preference = preferences.get(index);
        if (preference instanceof CheckBoxPreference) {
            addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference) preference, group);
        } else {
            group.addPreference(preference);
            if (preference instanceof PreferenceGroup) {
                replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup) preference);
            }
        }
    }
}

From source file:unalcol.termites.boxplots.HybridGlobalInfoReport.java

private static String getTitle(ArrayList<Double> pf) {
    String s = "pf=";

    for (int i = 0; i < pf.size(); i++) {
        s += pf.get(i);
        if (i != pf.size() - 1) {
            s += " and ";
        }/*  ww w .jav a2 s  . c o m*/
    }
    return s;
}

From source file:com.clutch.ClutchAB.java

private static void sendABLogs() {
    ArrayList<ABRow> logs = stats.getABLogs();
    if (logs.size() == 0) {
        return;/*from  w  w  w  . j a v  a 2  s  .c o  m*/
    }
    final ABRow lastRow = logs.get(logs.size() - 1);
    JSONArray jsonLogs = new JSONArray();
    for (ABRow row : logs) {
        JSONObject rowObj = new JSONObject();
        try {
            rowObj.put("uuid", row.uuid);
            rowObj.put("ts", row.ts);
            rowObj.put("data", row.data);
        } catch (JSONException e1) {
            Log.e(TAG,
                    "Could not properly encode the AB logs into JSON for upload to Clutch. Discarding the row."); // TODO: Don't discard the row.
            continue;
        }
        jsonLogs.put(rowObj);
    }
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("logs", jsonLogs);
    params.put("guid", ClutchAPIClient.getFakeGUID());
    ClutchAPIClient.callMethod("send_ab_logs", params, new ClutchAPIResponseHandler() {
        @Override
        public void onSuccess(JSONObject response) {
            if ("ok".equals(response.optString("status"))) {
                stats.deleteABLogs(lastRow.ts);
            } else {
                Log.e(TAG, "Failed to send the Clutch AB logs to the server.");
            }
        }

        @Override
        public void onFailure(Throwable e, JSONObject errorResponse) {
            Log.e(TAG, "Failed to send AB logs to Clutch: " + errorResponse);
        }
    });
}

From source file:mlflex.helper.MathUtilities.java

/** Calculates the median value from a list of numeric values.
 *
 * @param values List of numeric values//w w w  .java2s.  c  o  m
 * @return Median value
 */
public static double Median(ArrayList<Double> values) {
    Collections.sort(values);

    if (values.size() % 2 == 1)
        return values.get((values.size() + 1) / 2 - 1);
    else {
        double lower = values.get(values.size() / 2 - 1);
        double upper = values.get(values.size() / 2);

        return (lower + upper) / 2.0;
    }
}

From source file:Main.java

/**
 * @param newMenu//w  w  w.j a va2 s .c  o  m
 * @param menuBar
 * @param index
 * @return The same JMenuBar, for cascading.
 *         TODO See if the same thing can be done with Container.add( component, index )
 */
public static JMenuBar addMenuAt(JMenu newMenu, JMenuBar menuBar, int index) {

    ArrayList menuList = new ArrayList();
    for (int i = 0; i < menuBar.getMenuCount(); i++) {
        if (i == index) {
            menuList.add(newMenu);
        }
        menuList.add(menuBar.getMenu(i));
    }
    menuBar.removeAll();
    //        menuBar = new JMenuBar();
    for (int i = 0; i < menuList.size(); i++) {
        JMenu menu = (JMenu) menuList.get(i);
        menuBar.add(menu);
    }
    return menuBar;
}

From source file:org.apache.streams.gnip.powertrack.GnipActivityFixer.java

public static void editJson(JSONObject json, ArrayList<String> keyPath, Object nullFragment)
        throws JSONException {
    Integer numKeys = keyPath.size();
    JSONObject newJson = new JSONObject();
    if (numKeys > 1) {
        for (int i = numKeys - 1; i > 0; i -= 1) {
            String key = keyPath.get(i);
            if (i == numKeys - 1) {
                newJson = newJson.put(key, nullFragment);
            } else {
                newJson = newJson.put(key, newJson);
            }//  w  w  w.j a va 2  s  .  c o m
        }
        json.put(keyPath.get(0), newJson);
    } else {
        json.put(keyPath.get(0), nullFragment);
    }
}

From source file:mlflex.helper.MathUtilities.java

/** Rounds each of a list of numeric values to the specified number of decimal places.
 *
 * @param numbers List of numeric values to round
 * @param decimalPlaces Number of decimal places to use
 * @return List of rounded values/* w ww  . java 2s .  c om*/
 */
public static ArrayList<Double> Round(ArrayList<Double> numbers, int decimalPlaces) {
    for (int i = 0; i < numbers.size(); i++)
        numbers.set(i, Round(numbers.get(i), decimalPlaces));
    return numbers;
}

From source file:android.databinding.tool.util.XmlEditor.java

private static void fixPosition(ArrayList<String> lines, Position pos) {
    String line = lines.get(pos.line);
    while (pos.charIndex > line.length()) {
        pos.charIndex--;/* ww  w.  j  a  v a2 s .  co  m*/
    }
}