Java Code Examples for android.support.v7.widget.RecyclerView#Adapter
The following examples show how to use
android.support.v7.widget.RecyclerView#Adapter .
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: MultiCheckHelper.java From CheckHelper with Apache License 2.0 | 5 votes |
/** * 取消全部选中 */ public void unCheckAll(RecyclerView.Adapter adapter) { if (mMap.size() == 0) { return; } mMap.clear(); adapter.notifyDataSetChanged(); }
Example 2
Source File: PullToZoomRecyclerViewEx.java From PullZoomView with Apache License 2.0 | 5 votes |
private boolean isFirstItemVisible() { if (mRootView != null) { final RecyclerView.Adapter adapter = mRootView.getAdapter(); final GridLayoutManager mLayoutmanager = (GridLayoutManager) mRootView.getLayoutManager(); if (null == adapter || adapter.getItemCount() == 0) { return true; } else { /** * This check should really just be: * mRootView.getFirstVisiblePosition() == 0, but PtRListView * internally use a HeaderView which messes the positions up. For * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ int[] into = {0,0}; if (mLayoutmanager != null) into[0] = mLayoutmanager.findFirstVisibleItemPosition(); if (into.length > 0 && into.length > 0 && into[0] <= 1) { final View firstVisibleChild = mRootView.getChildAt(0); if (firstVisibleChild != null) { return firstVisibleChild.getTop() >= mRootView.getTop(); } } } } return false; }
Example 3
Source File: LuRecyclerViewUtils.java From LRecyclerView with Apache License 2.0 | 5 votes |
/** * 请使用本方法替代RecyclerView.ViewHolder的getLayoutPosition()方法 * * @param recyclerView * @param holder * @return */ public static int getLayoutPosition(RecyclerView recyclerView, RecyclerView.ViewHolder holder) { RecyclerView.Adapter outerAdapter = recyclerView.getAdapter(); if (outerAdapter != null && outerAdapter instanceof LuRecyclerViewAdapter) { int headerViewCounter = ((LuRecyclerViewAdapter) outerAdapter).getHeaderViewsCount(); if (headerViewCounter > 0) { return holder.getLayoutPosition() - headerViewCounter; } } return holder.getLayoutPosition(); }
Example 4
Source File: RecyclerViewStateUtils.java From GankGirl with GNU Lesser General Public License v2.1 | 5 votes |
/** * 设置当前RecyclerView.FooterView的状态 * * @param recyclerView * @param state */ public static void setFooterViewState(RecyclerView recyclerView, LoadingFooter.State state) { RecyclerView.Adapter outerAdapter = recyclerView.getAdapter(); if (outerAdapter != null && outerAdapter instanceof HeaderAndFooterRecyclerViewAdapter) { if (((HeaderAndFooterRecyclerViewAdapter) outerAdapter).getFooterViewsCount() > 0) { LoadingFooter footerView = (LoadingFooter) ((HeaderAndFooterRecyclerViewAdapter) outerAdapter).getFooterView(); footerView.setState(state); } } }
Example 5
Source File: PullRecyclerViewGroup.java From Bailan with Apache License 2.0 | 5 votes |
/** * 判断是否可以上拉 * @return */ private boolean isCanPullUp() { if(childView instanceof RecyclerView) { final RecyclerView.Adapter adapter = ((RecyclerView) childView).getAdapter(); if (null == adapter) { return true; } final int lastItemPosition = adapter.getItemCount() - 1; final int lastVisiblePosition = ((LinearLayoutManager) ((RecyclerView) childView).getLayoutManager()).findLastVisibleItemPosition(); if (lastVisiblePosition >= lastItemPosition) { final int childIndex = lastVisiblePosition - ((LinearLayoutManager) ((RecyclerView) childView).getLayoutManager()).findFirstVisibleItemPosition(); final int childCount = ((RecyclerView) childView).getChildCount(); final int index = Math.min(childIndex, childCount - 1); final View lastVisibleChild = ((RecyclerView) childView).getChildAt(index); if (lastVisibleChild != null) { return lastVisibleChild.getBottom() <= childView.getBottom() - childView.getTop(); } } return false; }else if(childView instanceof ScrollView){ return ((ScrollView) childView).getChildAt(0).getHeight() <= getHeight() + getScrollY(); } return false ; }
Example 6
Source File: RecyclerSwipeHelper.java From SupportSwipeLoadmore with GNU General Public License v3.0 | 5 votes |
public RecyclerSwipeHelper(SwipeRefreshLayout swipe, RecyclerView recycler) { this.mSwipe = swipe; this.mRecycler = recycler; // 刷新监听 if (mSwipe != null) { mSwipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mHandler.sendEmptyMessage(WHAT_ON_REFRESH); } }); } // 滑动监听 mRecycler.addOnScrollListener(WrapperScrollListener); // 包装数据源 mAdapterWrapper = new RecyclerFooterAdapterWrapper(recycler) { @Override public void setAdapter(RecyclerView.Adapter adapter) { if (getRealAdapter() != null) { unregisterAdapterDataObserver(mDataObserver); } super.setAdapter(adapter); if (getRealAdapter() != null) { registerAdapterDataObserver(mDataObserver); } } }; mAdapterWrapper.registerAdapterDataObserver(mDataObserver); // For GridLayoutManager use separate/customisable span lookup for loading row if (mRecycler.getLayoutManager() instanceof GridLayoutManager) { mSpanSizeLookup = new SpanSizeLookupWrapper((GridLayoutManager) mRecycler.getLayoutManager(), mAdapterWrapper); ((GridLayoutManager) mRecycler.getLayoutManager()).setSpanSizeLookup(mSpanSizeLookup); } }
Example 7
Source File: MultiCheckHelper.java From CheckHelper with Apache License 2.0 | 5 votes |
/** * 取消全部选中(指定数据) * * @param adapter * @param list 需要取消选择的列表,该列表中如果有选中的item将会置为非选中 */ @SuppressWarnings("unchecked") public <T> void unCheckAll(RecyclerView.Adapter adapter, Class<T> clazz, List<T> list) { Set<T> set = (Set<T>) mMap.get(clazz); if (set == null) { return; } set.removeAll(list); if (set.isEmpty()) { mMap.remove(clazz); } adapter.notifyDataSetChanged(); }
Example 8
Source File: CloudUploadingFragment.java From tysq-android with GNU General Public License v3.0 | 4 votes |
@Override protected RecyclerView.Adapter getAdapter() { return new CloudUploadingAdapter(getContext(), mData, this); }
Example 9
Source File: AdmobRecyclerAdapterWrapper.java From admobadapter with Apache License 2.0 | 4 votes |
public void setAdapter(RecyclerView.Adapter<RecyclerView.ViewHolder> adapter) { mAdapter = adapter; mAdapter.registerAdapterDataObserver(new AdapterWrapperObserver(this, getAdapterCalculator(), adFetcher)); notifyDataSetChanged(); }
Example 10
Source File: TallChipsFactory.java From ChipsLayoutManager with Apache License 2.0 | 4 votes |
@Override public RecyclerView.Adapter<? extends RecyclerView.ViewHolder> createAdapter(List<ChipsEntity> chipsEntities, OnRemoveListener onRemoveListener) { return new ChipsAdapter(chipsEntities, onRemoveListener); }
Example 11
Source File: EmptyWrapper.java From CoordinatorLayoutExample with Apache License 2.0 | 4 votes |
public EmptyWrapper(RecyclerView.Adapter adapter) { mInnerAdapter = adapter; }
Example 12
Source File: ExtendedListFragment.java From Cirrus_depricated with GNU General Public License v2.0 | 4 votes |
protected void setListAdapter(RecyclerView.Adapter listAdapter) { mCurrentListView.setAdapter(listAdapter); mCurrentListView.invalidate(); }
Example 13
Source File: ChipsFactory.java From ChipsLayoutManager with Apache License 2.0 | 4 votes |
@Override public RecyclerView.Adapter<? extends RecyclerView.ViewHolder> createAdapter(List<ChipsEntity> chipsEntities, OnRemoveListener onRemoveListener) { return new ChipsAdapter(chipsEntities, onRemoveListener); }
Example 14
Source File: ScrollUtils.java From SlyceMessaging with MIT License | 4 votes |
public static void scrollToTopAfterDelay(RecyclerView mRecyclerView, RecyclerView.Adapter mRecyclerAdapter) { scrollToPositionAfterDelay(0, mRecyclerView, mRecyclerAdapter); }
Example 15
Source File: WrapperAdapter.java From NoPaginate with Apache License 2.0 | 4 votes |
WrapperAdapter(RecyclerView.Adapter userAdapter, LoadingItem loadingItem, ErrorItem errorItem) { this.userAdapter = userAdapter; this.loadingItem = loadingItem; this.errorItem = errorItem; }
Example 16
Source File: FragmentBugs.java From Saiy-PS with GNU Affero General Public License v3.0 | 2 votes |
/** * Get the current adapter * * @return the current adapter */ public RecyclerView.Adapter getAdapter() { return mAdapter; }
Example 17
Source File: RecyclerViewFragment.java From COCOFramework with Apache License 2.0 | 2 votes |
/** * If you need to wrap the adpter, this is the interface you are looking for * * @param adapter * @return */ protected RecyclerView.Adapter wrapperAdapter(RecyclerView.Adapter adapter) { return adapter; }
Example 18
Source File: IItemsFacade.java From ChipsLayoutManager with Apache License 2.0 | votes |
RecyclerView.Adapter<? extends RecyclerView.ViewHolder> createAdapter(List<Item> chipsEntities, OnRemoveListener onRemoveListener);
Example 19
Source File: BaseAdapterCallback.java From recyclerview-multistate-section-endless-adapter with Apache License 2.0 | votes |
List<RecyclerView.Adapter> getBaseAdapters();
Example 20
Source File: IRecyclerView.java From tenor-android-core with Apache License 2.0 | votes |
void swapAdapter(RecyclerView.Adapter adapter, boolean removeAndRecycleExistingViews);