Example usage for android.support.v4.util SparseArrayCompat valueAt

List of usage examples for android.support.v4.util SparseArrayCompat valueAt

Introduction

In this page you can find the example usage for android.support.v4.util SparseArrayCompat valueAt.

Prototype

public E valueAt(int i) 

Source Link

Usage

From source file:Main.java

public static <C> List<C> asList(SparseArrayCompat<C> sparseArray) {
    if (sparseArray == null)
        return null;
    List<C> arrayList = new ArrayList<C>(sparseArray.size());
    for (int i = 0; i < sparseArray.size(); i++)
        arrayList.add(sparseArray.valueAt(i));
    return arrayList;
}

From source file:Main.java

public static <T> List<T> asList(SparseArrayCompat<T> sparseArray) {
    if (sparseArray == null) {
        return null;
    }//from w  w  w .  j  a  va  2 s .  c om

    List<T> list = new ArrayList<>(sparseArray.size());
    for (int i = 0; i < sparseArray.size(); i++) {
        list.add(sparseArray.valueAt(i));
    }
    return list;
}

From source file:com.facebook.litho.ComponentHostUtils.java

static List<?> extractContent(SparseArrayCompat<MountItem> items) {
    final int size = items.size();
    if (size == 1) {
        return Collections.singletonList(items.valueAt(0).getContent());
    }/*from  w  w  w.  j a v  a2 s  .  c  o m*/

    final List<Object> content = new ArrayList<>(size);

    for (int i = 0; i < size; i++) {
        content.add(items.valueAt(i).getContent());
    }

    return content;
}

From source file:net.xisberto.phonetodesktop.ui.LinkListActivity.java

public static <C> ArrayList<C> asArrayList(SparseArrayCompat<C> sparseArray) {
    if (sparseArray == null)
        return null;
    ArrayList<C> arrayList = new ArrayList<>(sparseArray.size());
    for (int i = 0; i < sparseArray.size(); i++)
        arrayList.add(sparseArray.valueAt(i));
    return arrayList;
}

From source file:net.xisberto.work_schedule.settings.BootCompletedReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Log.d(context.getPackageName(), intent.getAction());
    Database database = Database.getInstance(context);
    SparseArrayCompat<Period> periods = database.listPeriodsFromDay(Calendar.getInstance());
    boolean updateWidgets = true;
    for (int i = 0; i < periods.size(); i++) {
        if (updateWidgets && periods.valueAt(i).enabled) {
            updateWidgets = false;/*from   w  w  w  . j a  va2s  .com*/
        }
        periods.valueAt(i).setAlarm(context, updateWidgets);
    }
}

From source file:com.awrtechnologies.carbudgetsales.hlistview.widget.HListView.java

/**
 * Returns the set of checked items ids. The result is only valid if the choice mode has not been set to
 * {@link #CHOICE_MODE_NONE}.// w  w  w  .  ja v  a  2  s  . com
 * 
 * @return A new array which contains the id of each checked item in the list.
 * 
 * @deprecated Use {@link #getCheckedItemIds()} instead.
 */
@Deprecated
public long[] getCheckItemIds() {
    // Use new behavior that correctly handles stable ID mapping.
    if (mAdapter != null && mAdapter.hasStableIds()) {
        return getCheckedItemIds();
    }

    // Old behavior was buggy, but would sort of work for adapters without stable IDs.
    // Fall back to it to support legacy apps.
    if (mChoiceMode != AbsListView.CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
        final SparseArrayCompat<Boolean> states = mCheckStates;
        final int count = states.size();
        final long[] ids = new long[count];
        final ListAdapter adapter = mAdapter;

        int checkedCount = 0;
        for (int i = 0; i < count; i++) {
            if (states.valueAt(i)) {
                ids[checkedCount++] = adapter.getItemId(states.keyAt(i));
            }
        }

        // Trim array if needed. mCheckStates may contain false values
        // resulting in checkedCount being smaller than count.
        if (checkedCount == count) {
            return ids;
        } else {
            final long[] result = new long[checkedCount];
            System.arraycopy(ids, 0, result, 0, checkedCount);

            return result;
        }
    }
    return new long[0];
}

From source file:com.awrtechnologies.valor.valorfireplace.hlistview.widget.HListView.java

/**
 * Returns the set of checked items ids. The result is only valid if the choice mode has not been set to
 * {@link #CHOICE_MODE_NONE}.//from  w  w w  .  j av a  2 s.c  om
 * 
 * @return A new array which contains the id of each checked item in the list.
 * 
 * @deprecated Use {@link #getCheckedItemIds()} instead.
 */
@Deprecated
public long[] getCheckItemIds() {
    // Use new behavior that correctly handles stable ID mapping.
    if (mAdapter != null && mAdapter.hasStableIds()) {
        return getCheckedItemIds();
    }

    // Old behavior was buggy, but would sort of work for adapters without stable IDs.
    // Fall back to it to support legacy apps.
    if (mChoiceMode != ListView.CHOICE_MODE_NONE && mCheckStates != null && mAdapter != null) {
        final SparseArrayCompat<Boolean> states = mCheckStates;
        final int count = states.size();
        final long[] ids = new long[count];
        final ListAdapter adapter = mAdapter;

        int checkedCount = 0;
        for (int i = 0; i < count; i++) {
            if (states.valueAt(i)) {
                ids[checkedCount++] = adapter.getItemId(states.keyAt(i));
            }
        }

        // Trim array if needed. mCheckStates may contain false values
        // resulting in checkedCount being smaller than count.
        if (checkedCount == count) {
            return ids;
        } else {
            final long[] result = new long[checkedCount];
            System.arraycopy(ids, 0, result, 0, checkedCount);

            return result;
        }
    }
    return new long[0];
}