本文整理汇总了Java中android.support.v7.widget.LinearLayoutManager.setInitialPrefetchItemCount方法的典型用法代码示例。如果您正苦于以下问题:Java LinearLayoutManager.setInitialPrefetchItemCount方法的具体用法?Java LinearLayoutManager.setInitialPrefetchItemCount怎么用?Java LinearLayoutManager.setInitialPrefetchItemCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.LinearLayoutManager
的用法示例。
在下文中一共展示了LinearLayoutManager.setInitialPrefetchItemCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bind
import android.support.v7.widget.LinearLayoutManager; //导入方法依赖的package包/类
@Override
public void bind(EpubView epubView, ViewGroup parent) {
this.epubView = epubView;
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
binding = EpubVerticalVerticalContentBinding.inflate(inflater, parent, true);
LinearLayoutManager layoutManager = new LinearLayoutManager(epubView.getContext());
layoutManager.setInitialPrefetchItemCount(2);
binding.recyclerview.setLayoutManager(layoutManager);
chapterAdapter = new ChapterAdapter(this, epubView);
binding.recyclerview.setAdapter(chapterAdapter);
binding.recyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
View firstVisibleView = layoutManager.findViewByPosition(firstVisibleItemPosition);
scrollPosition.onNext(new Pair<>(firstVisibleItemPosition, firstVisibleView.getTop()));
setCurrentChapter(firstVisibleItemPosition);
}
});
scrollPosition
.sample(200, TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.doOnNext(positionTopPair -> {
ChapterAdapter.ChapterViewHolder holder = (ChapterAdapter.ChapterViewHolder) binding.recyclerview.findViewHolderForAdapterPosition(positionTopPair.first);
if (holder != null) {
float density = epubView.getContext().getResources().getDisplayMetrics().density;
holder.binding.webview.callJavascriptMethod("updateFirstVisibleElementByTopPosition", -positionTopPair.second/density);
}
})
.subscribe(new BaseDisposableObserver<>());
}
开发者ID:smartmobilefactory,项目名称:EpubReaderAndroid,代码行数:35,代码来源:VerticalWithVerticalContentEpubDisplayStrategy.java