Java Code Examples for android.widget.AbsListView#getPositionForView()

The following examples show how to use android.widget.AbsListView#getPositionForView() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListUnit.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
@Override
public void setListViewBusy(boolean isBusy, AbsListView listView) {
	busy = isBusy;
	if (!busy) {
		CacheManager cacheManager = CacheManager.getInstance();
		int count = listView.getChildCount();
		for (int i = 0; i < count; i++) {
			View view = listView.getChildAt(i);
			int position = listView.getPositionForView(view);
			GalleryItem galleryItem = getItem(position);
			Uri thumbnailUri = galleryItem.getThumbnailUri(instance.locator);
			if (thumbnailUri != null) {
				GridViewHolder holder = (GridViewHolder) view.getTag();
				String key = cacheManager.getCachedFileKey(thumbnailUri);
				holder.thumbnail.resetImage(key, AttachmentView.Overlay.NONE);
				loadImage(holder.thumbnail, thumbnailUri, key);
			}
		}
	}
}
 
Example 2
Source File: AutoListView.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void ifNeedLoad(AbsListView view, int scrollState) {
	if (!loadEnable) {
		return;
	}
	try {
		if (scrollState == OnScrollListener.SCROLL_STATE_IDLE
				&& !isLoading
				&& view.getLastVisiblePosition() == view
						.getPositionForView(footer) && !isLoadFull) {
			onLoad();
			isLoading = true;
		}
	} catch (Exception e) {
	}
}
 
Example 3
Source File: AutoListView.java    From SweetMusicPlayer with Apache License 2.0 5 votes vote down vote up
private void ifNeedLoad(AbsListView view, int scrollState) {
    if (!loadEnable) {
        return;
    }
    try {
        if (scrollState == OnScrollListener.SCROLL_STATE_IDLE
                && !isLoading
                && view.getLastVisiblePosition() == view
                .getPositionForView(footer) && !isLoadFull) {
            onLoad();
            isLoading = true;
        }
    } catch (Exception e) {
    }
}
 
Example 4
Source File: ClickableView.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
private int getListPosition(AbsListView listView) {
	View view = ListViewUtils.getRootViewInList(this);
	if (view != null) {
		return listView.getPositionForView(view);
	} else {
		return AbsListView.INVALID_POSITION;
	}
}
 
Example 5
Source File: AdapterViewUtil.java    From ListViewAnimations with Apache License 2.0 3 votes vote down vote up
/**
 * Returns the position within the adapter's dataset for the view, where view is an adapter item or a descendant of an adapter item.
 * Unlike {@link AdapterView#getPositionForView(android.view.View)}, returned position will reflect the position of the item given view is representing,
 * by subtracting the header views count.
 *
 * @param absListView the ListView containing the view.
 * @param view        an adapter item or a descendant of an adapter item. This must be visible in given AdapterView at the time of the call.
 *
 * @return the position of the item in the AdapterView represented by given view, or {@link AdapterView#INVALID_POSITION} if the view does not
 * correspond to a list item (or it is not visible).
 */
public static int getPositionForView(@NonNull final AbsListView absListView, @NonNull final View view) {
    int position = absListView.getPositionForView(view);
    if (absListView instanceof ListView) {
        position -= ((ListView) absListView).getHeaderViewsCount();
    }
    return position;
}