Example usage for java.util ArrayList add

List of usage examples for java.util ArrayList add

Introduction

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

Prototype

public boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:Main.java

@NonNull
public static Intent sendEmail(@NonNull String[] to, @NonNull String subject, @NonNull String body,
        @Nullable List<Uri> attachments) {
    final Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
    intent.setType("message/rfc822");
    intent.putExtra(Intent.EXTRA_EMAIL, to);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    final ArrayList<CharSequence> extraText = new ArrayList<>(1);
    extraText.add(body);
    intent.putCharSequenceArrayListExtra(Intent.EXTRA_TEXT, extraText);
    if (attachments != null && !attachments.isEmpty()) {
        intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, new ArrayList<Parcelable>(attachments));
    }/* w w w. ja  v  a  2  s .co m*/
    return intent;
}

From source file:Main.java

public static void setAllCapsInputFilter(EditText et) {
    InputFilter[] prefFilters;/*  w ww  .  ja v  a2s.  co m*/
    prefFilters = et.getFilters();
    ArrayList<InputFilter> filters = new ArrayList<>(Arrays.asList(prefFilters));
    filters.add(new InputFilter.AllCaps());
    prefFilters = new InputFilter[filters.size()];
    filters.toArray(prefFilters);
    et.setFilters(prefFilters);
}

From source file:Main.java

/**
 * Creates a new ArrayList from the given pair of values.
 *
 * @param <DataType>/*from www .  ja  va  2 s .c om*/
 *      The data type.
 * @param   first
 *      The first value.
 * @param   second
 *      The second value.
 * @return
 *      A new array list with the two elements in it.
 */
public static <DataType> ArrayList<DataType> createArrayList(final DataType first, final DataType second) {
    final ArrayList<DataType> result = new ArrayList<DataType>(2);
    result.add(first);
    result.add(second);
    return result;
}

From source file:Main.java

/**
 * Creates a new {@link ArrayList} with the inferred type
 * and size, using the given value for each element.
 *///w w  w .  j  a  va2 s .c o m
public static <T> ArrayList<T> alistInit(T value, int size) {
    ArrayList<T> ret = new ArrayList<T>(size);
    for (int i = 0; i < size; i++)
        ret.add(value);
    return ret;
}

From source file:Main.java

public static <E> ArrayList<E> newArrayList(Iterator<? extends E> elements) {
    ArrayList<E> list = new ArrayList<E>();
    while (elements.hasNext()) {
        list.add(elements.next());
    }/*w  w  w .  jav a  2  s .  com*/
    return list;
}

From source file:Main.java

public static <E> ArrayList<E> newArrayList(Iterable<E> iterable) {
    ArrayList<E> list = new ArrayList<E>();
    for (E element : iterable) {
        list.add(element);
    }/* w w w.  j  ava2  s.co  m*/
    return list;
}

From source file:Main.java

public static <E> ArrayList<E> asArrayList(E first, E... other) {
    if (other == null) {
        throw new NullPointerException("other");
    }//  w  w w .jav a2s  .  c om
    ArrayList<E> list = new ArrayList<>(1 + other.length);
    list.add(first);
    list.addAll(Arrays.asList(other));
    return list;
}

From source file:Main.java

public static <T> ArrayList<T> list(T[] array) {
    ArrayList<T> list = new ArrayList<T>();
    for (int i = 0; i < array.length; ++i)
        list.add(array[i]);
    return list;//  w  w w.j a v  a  2s  . com
}

From source file:Main.java

public static ArrayList<String> getAllSDCardFilePath(String leafFolder) {
    ArrayList<String> result = new ArrayList<String>();
    //TODO tfling
    result.add(getDataSDCardRoot() + leafFolder);
    result.add(getMainSDCardRoot() + leafFolder);
    return result;
}

From source file:Main.java

public static HashMap<String, List<Object[]>> getUnitDataMap(List<Object[]> list, int index) {
    HashMap<String, List<Object[]>> dataMap = new HashMap<String, List<Object[]>>();
    for (int i = 0; i < list.size(); i++) {
        Object obj = list.get(i)[index];
        String unit = obj.toString();

        if (dataMap.containsKey(unit)) {
            dataMap.get(unit).add((Object[]) list.get(i));
        } else {//from   w w w  .  j  a  v a  2  s. co m
            ArrayList<Object[]> rowdata = new ArrayList<Object[]>();
            rowdata.add((Object[]) list.get(i));
            dataMap.put(unit, rowdata);
        }
    }

    return dataMap;
}