本文整理匯總了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