Example usage for android.widget ListAdapter getItemId

List of usage examples for android.widget ListAdapter getItemId

Introduction

In this page you can find the example usage for android.widget ListAdapter getItemId.

Prototype

long getItemId(int position);

Source Link

Document

Get the row id associated with the specified position in the list.

Usage

From source file:com.wheelly.fragments.LocationsListFragment.java

private int getItemPositionByAdapterId(final long id) {
    final ListAdapter adapter = getListAdapter();
    int i = 0;//ww  w  .jav  a2  s  .co  m
    while (i < adapter.getCount() && id != adapter.getItemId(i++))
        ;

    return i == adapter.getCount() && id != adapter.getItemId(i - 1) ? -1 : --i;
}

From source file:net.potterpcs.recipebook.RecipeListFragment.java

long[] getItemIds() {
    ListAdapter adapter = getListAdapter();
    long[] ids = new long[adapter.getCount()];
    for (int i = 0; i < ids.length; i++) {
        ids[i] = adapter.getItemId(i);
    }/*from  w w  w.  j  a  v  a  2s.c om*/
    return ids;
}

From source file:ru.orangesoftware.financisto.activity.ActivityLayout.java

public void selectItemId(Context context, final int id, int titleId, final ListAdapter adapter,
        int selectedPosition) {
    selectSingleChoice(context, titleId, adapter, selectedPosition, (dialog, which) -> {
        dialog.cancel();/*w  w w.j  a v a  2  s. co  m*/
        long selectedId = adapter.getItemId(which);
        listener.onSelectedId(id, selectedId);
    });
}

From source file:com.nextgis.maplibui.fragment.ReorderedLayerView.java

/**
 * Stores a reference to the views above and below the item currently corresponding to the hover
 * cell. It is important to note that if this item is either at the top or bottom of the list,
 * mAboveItemId or mBelowItemId may be invalid.
 *//*w  ww  .j  av  a  2  s  .  c o  m*/
protected void updateNeighborViewsForID(long itemID) {
    int position = getPositionForID(itemID);
    ListAdapter adapter = getAdapter();
    mAboveItemId = adapter.getItemId(position - 1);
    mBelowItemId = adapter.getItemId(position + 1);
}

From source file:com.nextgis.maplibui.fragment.ReorderedLayerView.java

/**
 * Retrieves the view in the list corresponding to itemID
 *///from  w  w w .  j av a2 s .c o m
public View getViewForID(long itemID) {
    int firstVisiblePosition = getFirstVisiblePosition();
    ListAdapter adapter = getAdapter();
    for (int i = 0; i < getChildCount(); i++) {
        View v = getChildAt(i);
        int position = firstVisiblePosition + i;
        long id = adapter.getItemId(position);
        if (id == itemID) {
            return v;
        }
    }
    return null;
}

From source file:com.spatialnetworks.fulcrum.widget.DynamicListView.java

/**
 * Stores a reference to the views above and below the item currently
 * corresponding to the hover cell. It is important to note that if this
 * item is either at the top or bottom of the list, mAboveItemId or mBelowItemId
 * may be invalid./*from  w w  w .ja va 2 s  .  c om*/
 */
private void updateNeighborViewsForID(long itemID) {
    int position = getPositionForID(itemID);
    ListAdapter adapter = getAdapter();
    mAboveItemId = adapter.getItemId(position - 1);
    mBelowItemId = adapter.getItemId(position + 1);
}

From source file:net.osmand.plus.views.controls.DynamicListView.java

/**
 * Retrieves the view in the list corresponding to itemID
 *///from w w  w.  j  av  a 2 s  .  c  om
public View getViewForID(long itemID) {
    if (itemID != INVALID_ID) {
        int firstVisiblePosition = getFirstVisiblePosition();
        ListAdapter adapter = getAdapter();
        for (int i = 0; i < getChildCount(); i++) {
            View v = getChildAt(i);
            int position = firstVisiblePosition + i;
            long id = adapter.getItemId(position);
            if (id == itemID) {
                return v;
            }
        }
    }
    return null;
}

From source file:net.osmand.plus.views.controls.DynamicListView.java

/**
 * Stores a reference to the views above and below the item currently
 * corresponding to the hover cell. It is important to note that if this
 * item is either at the top or bottom of the list, mAboveItemId or mBelowItemId
 * may be invalid./*from   www .  j a  v a2 s. c om*/
 */
private void updateNeighborViewsForID(long itemID) {
    ListAdapter adapter = getAdapter();
    int position = getPositionForID(itemID);
    int pos = position;
    mAboveItemId = INVALID_ID;
    while (mAboveItemId == INVALID_ID && pos > 0) {
        pos--;
        mAboveItemId = adapter.getItemId(pos);
        if (mAboveItemId != INVALID_ID) {
            Object obj = adapter.getItem(pos);
            if (mActiveItemsList == null || !mActiveItemsList.contains(obj)) {
                mAboveItemId = INVALID_ID;
            }
        }
    }
    pos = position;
    mBelowItemId = INVALID_ID;
    while (mBelowItemId == INVALID_ID && pos < mItemsList.size()) {
        pos++;
        mBelowItemId = adapter.getItemId(pos);
        if (mBelowItemId != INVALID_ID) {
            Object obj = adapter.getItem(pos);
            if (mActiveItemsList == null || !mActiveItemsList.contains(obj)) {
                mBelowItemId = INVALID_ID;
            }
        }
    }
}

From source file:android.support.v7.widget.ListPopupWindow.java

/**
 * Perform an item click operation on the specified list adapter position.
 *
 * @param position Adapter position for performing the click
 * @return true if the click action could be performed, false if not.
 *         (e.g. if the popup was not showing, this method would return false.)
 *//*from www.  j a v a2 s.  c  om*/
public boolean performItemClick(int position) {
    if (isShowing()) {
        if (mItemClickListener != null) {
            final DropDownListView list = mDropDownList;
            final View child = list.getChildAt(position - list.getFirstVisiblePosition());
            final ListAdapter adapter = list.getAdapter();
            mItemClickListener.onItemClick(list, child, position, adapter.getItemId(position));
        }
        return true;
    }
    return false;
}

From source file:android.support.v7.widget.AbstractXpListPopupWindow.java

/**
 * Perform an item click operation on the specified list adapter position.
 *
 * @param position Adapter position for performing the click
 * @return true if the click action could be performed, false if not.
 * (e.g. if the popup was not showing, this method would return false.)
 *///from w w  w .  j av a 2s. co m
public boolean performItemClick(int position) {
    if (isShowing()) {
        if (mItemClickListener != null) {
            final XpDropDownListView list = mDropDownList;
            final View child = list.getChildAt(position - list.getFirstVisiblePosition());
            final ListAdapter adapter = list.getAdapter();
            mItemClickListener.onItemClick(list, child, position, adapter.getItemId(position));
        }
        return true;
    }
    return false;
}