本文整理匯總了Java中android.support.v7.widget.RecyclerView.RecycledViewPool方法的典型用法代碼示例。如果您正苦於以下問題:Java RecyclerView.RecycledViewPool方法的具體用法?Java RecyclerView.RecycledViewPool怎麽用?Java RecyclerView.RecycledViewPool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v7.widget.RecyclerView
的用法示例。
在下文中一共展示了RecyclerView.RecycledViewPool方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_multi_recycler_view);
ButterKnife.bind(this);
toolbar.setNavigationOnClickListener(new NavigationFinishClickListener(this));
RecyclerView.RecycledViewPool recycledViewPool = new RecyclerView.RecycledViewPool();
recyclerView0.setRecycledViewPool(recycledViewPool);
recyclerView1.setRecycledViewPool(recycledViewPool);
recyclerView0.setLayoutManager(new LinearLayoutManager(this));
recyclerView1.setLayoutManager(new LinearLayoutManager(this));
new VerticalHeader(this, recyclerView0);
new VerticalHeader(this, recyclerView0);
new VerticalFooter(this, recyclerView0);
new VerticalFooter(this, recyclerView0);
new VerticalHeader(this, recyclerView1);
new VerticalHeader(this, recyclerView1);
new VerticalFooter(this, recyclerView1);
new VerticalFooter(this, recyclerView1);
adapter0 = new LinearVerticalAdapter(this);
adapter0.getIllustList().addAll(ApiClient.buildIllustList());
recyclerView0.setAdapter(adapter0);
adapter1 = new LinearVerticalAdapter(this);
adapter1.getIllustList().addAll(ApiClient.buildIllustList());
recyclerView1.setAdapter(adapter1);
}
示例2: apply
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* init the cache on your own.
*
* @param recyclerView
* @param items
*/
public void apply(RecyclerView recyclerView, Iterable<Item> items) {
if (items != null) {
//we pre-create the views for our cache
HashMap<Integer, Stack<RecyclerView.ViewHolder>> cache = new HashMap<>();
for (Item d : items) {
if (!cache.containsKey(d.getType())) {
cache.put(d.getType(), new Stack<RecyclerView.ViewHolder>());
}
if (mCacheSize == -1 || cache.get(d.getType()).size() <= mCacheSize) {
cache.get(d.getType()).push(d.getViewHolder(recyclerView));
}
RecyclerView.RecycledViewPool recyclerViewPool = new RecyclerView.RecycledViewPool();
//we fill the pool
for (Map.Entry<Integer, Stack<RecyclerView.ViewHolder>> entry : cache.entrySet()) {
recyclerViewPool.setMaxRecycledViews(entry.getKey(), mCacheSize);
for (RecyclerView.ViewHolder holder : entry.getValue()) {
recyclerViewPool.putRecycledView(holder);
}
//make sure to clear the stack
entry.getValue().clear();
}
//make sure to clear the cache
cache.clear();
recyclerView.setRecycledViewPool(recyclerViewPool);
}
}
}
示例3: RecyclablePagerAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclablePagerAdapter(RecyclerView.Adapter<VH> adapter, RecyclerView.RecycledViewPool pool) {
this.mAdapter = adapter;
if (pool instanceof InnerRecycledViewPool) {
this.mRecycledViewPool = (InnerRecycledViewPool) pool;
} else {
this.mRecycledViewPool = new InnerRecycledViewPool(pool);
}
}
示例4: recycleView
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private void recycleView(@NonNull BaseCell cell) {
if (!mViewHolders.isEmpty()) {
RecyclerView.RecycledViewPool pool = cell.serviceManager.getService(RecyclerView.RecycledViewPool.class);
for (int i = 0, size = mViewHolders.size(); i < size; i++) {
BinderViewHolder viewHolder = mViewHolders.get(i);
viewHolder.unbind();
removeView(viewHolder.itemView);
pool.putRecycledView(viewHolder);
}
mViewHolders.clear();
}
}
示例5: setNumAppsPerRow
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Sets the number of apps per row in this recycler view.
*/
public void setNumAppsPerRow(DeviceProfile grid, int numAppsPerRow) {
mNumAppsPerRow = numAppsPerRow;
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * mNumAppsPerRow);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON, mNumAppsPerRow);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_PREDICTION_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SECTION_BREAK, approxRows);
}
示例6: setNumAppsPerRow
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Sets the number of apps per row in this recycler view.
*/
public void setNumAppsPerRow(DeviceProfile grid, int numAppsPerRow) {
mNumAppsPerRow = numAppsPerRow;
RecyclerView.RecycledViewPool pool = getRecycledViewPool();
int approxRows = (int) Math.ceil(grid.availableHeightPx / grid.allAppsIconSizePx);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_EMPTY_SEARCH, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET_DIVIDER, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_SEARCH_MARKET, 1);
pool.setMaxRecycledViews(AllAppsGridAdapter.VIEW_TYPE_ICON, approxRows * mNumAppsPerRow);
}
示例7: getViewFromRecycler
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
private View getViewFromRecycler(@NonNull BaseCell cell) {
GroupBasicAdapter adapter = cell.serviceManager.getService(GroupBasicAdapter.class);
RecyclerView.RecycledViewPool pool = cell.serviceManager.getService(RecyclerView.RecycledViewPool.class);
int itemViewType = adapter.getItemType(cell);
BinderViewHolder holder = (BinderViewHolder) pool.getRecycledView(itemViewType);
if (holder == null) {
holder = (BinderViewHolder) adapter.createViewHolder(this, itemViewType);
}
holder.bind(cell);
mViewHolders.add(holder);
return holder.itemView;
}
示例8: onCreate
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler);
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
mRecyclerView.addItemDecoration(new RecyclerViewDivider(this).orientation(LinearLayoutManager.VERTICAL)
.itemsDividerWidth(1)
.beforeFirstViewDividerWidth(1)
.afterLastViewDividerWidth(1)
);
mRecyclerView.setLayoutManager(layoutManager);
RecyclerView.RecycledViewPool recycledViewPool = new RecyclerView.RecycledViewPool();
//設置每種布局最大緩存數量,可以不設置
recycledViewPool.setMaxRecycledViews(0, 15);
recycledViewPool.setMaxRecycledViews(1, 15);
recycledViewPool.setMaxRecycledViews(2, 15);
recycledViewPool.setMaxRecycledViews(3, 15);
recycledViewPool.setMaxRecycledViews(4, 15);
mRecyclerView.setRecycledViewPool(recycledViewPool);
mAdapter = new MultiTypeRecyclerAdapter();
mRecyclerView.setAdapter(mAdapter);
List<ItemViewFactory> data = getData();
mAdapter.setData(data);
findViewById(R.id.but).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mAdapter.setData(getData2());
}
});
}
示例9: OuterAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public OuterAdapter(List<List<InnerData>> data) {
this.mData = data;
mPool = new RecyclerView.RecycledViewPool();
mPool.setMaxRecycledViews(0, POOL_SIZE);
}
示例10: PagerAdapter
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public PagerAdapter(SubAdapter adapter, RecyclerView.RecycledViewPool pool) {
super(adapter, pool);
}
示例11: InnerRecycledViewPool
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public InnerRecycledViewPool() {
this(new RecyclerView.RecycledViewPool());
}
示例12: getRecycledViewPool
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
public RecyclerView.RecycledViewPool getRecycledViewPool() {
if (serviceManager != null) {
return serviceManager.getService(RecyclerView.RecycledViewPool.class);
}
return null;
}
示例13: setShareViewPool
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* 設置主層級與副層級使用一個RecycledViewPool
*
* @param viewPool
*/
public void setShareViewPool(RecyclerView.RecycledViewPool viewPool) {
getMainRecyclerView().setRecycledViewPool(viewPool);
getSubRecyclerView().setRecycledViewPool(viewPool);
}
示例14: InnerRecycledViewPool
import android.support.v7.widget.RecyclerView; //導入方法依賴的package包/類
/**
* Wrap an existing pool
*
* @param pool
*/
public InnerRecycledViewPool(RecyclerView.RecycledViewPool pool) {
this.mInnerPool = pool;
}