本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法的具体用法?Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition怎么用?Java LinearLayoutManager.findFirstCompletelyVisibleItemPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.findFirstCompletelyVisibleItemPosition方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOnBottomListener
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
RecyclerView.OnScrollListener getOnBottomListener(LinearLayoutManager layoutManager) {
return new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView rv, int dx, int dy) {
int lastItemPosition, firstItemPosition, itemCount;
itemCount = mAdapter.getItemCount();
lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
mPresenter.requestData(HomePresenter.REQUEST_LOAD_MORE);
} else if (firstItemPosition == 0) {
isTransparent(true);
} else {
isTransparent(false);
}
}
};
}
示例2: renewScrollPosition
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
/**
* This method calculates the current scroll position and its offset to help new attached
* recyclerView on window at that position and offset
*
* @see #getScrollPosition()
* @see #getScrollPositionOffset()
*/
private void renewScrollPosition(RecyclerView p_jRecyclerView) {
LinearLayoutManager layoutManager = (LinearLayoutManager) p_jRecyclerView
.getLayoutManager();
m_nScrollPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
// That means there is no completely visible Position.
if (m_nScrollPosition == -1) {
m_nScrollPosition = layoutManager.findFirstVisibleItemPosition();
// That means there is just a visible item on the screen
if (layoutManager.findFirstVisibleItemPosition() == layoutManager
.findLastVisibleItemPosition()) {
// in this case we use the position which is the last & first visible item.
} else {
// That means there are 2 visible item on the screen. However, second one is not
// completely visible.
m_nScrollPosition = m_nScrollPosition + 1;
}
}
m_nScrollPositionOffset = p_jRecyclerView.getLayoutManager().findViewByPosition
(m_nScrollPosition).getLeft();
}
示例3: bottomListener
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void bottomListener(LinearLayoutManager layoutManager) {
int lastItemPosition, firstItemPosition, itemCount;
itemCount = mAdapter.getItemCount();
lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
mPresenter.requestData(ImagePresenter.REQUEST_LOAD_MORE);
} else if (firstItemPosition == 0) {
isTransparent(true);
} else {
isTransparent(true);
}
}
示例4: bottomListener
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void bottomListener(LinearLayoutManager layoutManager) {
int lastItemPosition, firstItemPosition, itemCount;
itemCount = mAdapter.getItemCount();
lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0) {
mPresenter.requestData(IOSPresenter.REQUEST_LOAD_MORE);
} else if (firstItemPosition == 0) {
isTransparent(true);
} else {
isTransparent(false);
}
}
示例5: bottomListener
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void bottomListener(LinearLayoutManager layoutManager) {
int lastItemPosition, firstItemPosition, itemCount;
itemCount = mAdapter.getItemCount();
lastItemPosition = layoutManager.findLastCompletelyVisibleItemPosition();
firstItemPosition = layoutManager.findFirstCompletelyVisibleItemPosition();
if (lastItemPosition == itemCount - 1 && lastItemPosition - firstItemPosition > 0 && lastItemPosition != 0) {
mPresenter.requestData(AndroidPresenter.REQUEST_LOAD_MORE);
} else if (firstItemPosition == 0) {
isTransparent(true);
} else {
isTransparent(false);
}
}
示例6: updateOverscrollMode
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void updateOverscrollMode() {
LinearLayoutManager lm = (LinearLayoutManager) mRecyclerView.getLayoutManager();
if (lm.findFirstCompletelyVisibleItemPosition() == 0 &&
lm.findLastCompletelyVisibleItemPosition() == mRecyclerView.getAdapter().getItemCount() - 1) {
mRecyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_NEVER);
} else {
mRecyclerView.setOverScrollMode(RecyclerView.OVER_SCROLL_ALWAYS);
}
}
示例7: initPendingList
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
private void initPendingList(@NonNull RecyclerView view, long timeOut,
ProductListItemCallback itemCallback){
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager)view.getLayoutManager();
final int firstCompletelyItem = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
final int lastCompletelyItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();
for (int position = firstCompletelyItem; position <= lastCompletelyItem; position++){
if (!mProductPositionItems.containsKey(position) && position >= 0) {
mPendingProductPositionItems.put(position, itemCallback.getItem(position));
}
}
mDelayHandler.postDelayed(mApplyPendingAction, timeOut);
}
示例8: onScrolled
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int lastItem = 0;
int firstItem = 0;
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
int totalItemCount = layoutManager.getItemCount();
if (layoutManager instanceof GridLayoutManager) {
GridLayoutManager gridLayoutManager = ((GridLayoutManager) layoutManager);
firstItem = gridLayoutManager.findFirstCompletelyVisibleItemPosition();
//Position to find the final item of the current LayoutManager
lastItem = gridLayoutManager.findLastCompletelyVisibleItemPosition();
if (lastItem == -1) lastItem = gridLayoutManager.findLastVisibleItemPosition();
} else if (layoutManager instanceof LinearLayoutManager) {
LinearLayoutManager linearLayoutManager = ((LinearLayoutManager) layoutManager);
firstItem = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
lastItem = linearLayoutManager.findLastCompletelyVisibleItemPosition();
if (lastItem == -1) lastItem = linearLayoutManager.findLastVisibleItemPosition();
} else if (layoutManager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager staggeredGridLayoutManager = ((StaggeredGridLayoutManager) layoutManager);
// since may lead to the final item has more than one StaggeredGridLayoutManager the particularity of the so here that is an array
// this array into an array of position and then take the maximum value that is the last show the position value
int[] lastPositions = new int[((StaggeredGridLayoutManager) layoutManager).getSpanCount()];
staggeredGridLayoutManager.findLastCompletelyVisibleItemPositions(lastPositions);
lastItem = findMax(lastPositions);
firstItem = staggeredGridLayoutManager.findFirstVisibleItemPositions(lastPositions)[0];
}
if (firstItem == 0 || firstItem == RecyclerView.NO_POSITION) {
if (mPullLoadMoreRecyclerView.getPullRefreshEnable())
mPullLoadMoreRecyclerView.setSwipeRefreshEnable(true);
} else {
mPullLoadMoreRecyclerView.setSwipeRefreshEnable(false);
}
if (mPullLoadMoreRecyclerView.getPushRefreshEnable()
&& !mPullLoadMoreRecyclerView.isRefresh()
&& mPullLoadMoreRecyclerView.isHasMore()
&& (lastItem == totalItemCount - 1)
&& !mPullLoadMoreRecyclerView.isLoadMore()
&& (dx > 0 || dy > 0)) {
mPullLoadMoreRecyclerView.setIsLoadMore(true);
mPullLoadMoreRecyclerView.loadMore();
}
}