androidx.recyclerview.widget.RecyclerView.Adapter Java Examples
The following examples show how to use
androidx.recyclerview.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: SettingsActivity.java From AppOpsX with MIT License | 5 votes |
@Override protected Adapter onCreateAdapter(PreferenceScreen preferenceScreen) { return new PreferenceGroupAdapter(preferenceScreen){ @SuppressLint("RestrictedApi") public void onPreferenceHierarchyChange(Preference preference){ setAllPreferencesToAvoidHavingExtraSpace(preference); super.onPreferenceHierarchyChange(preference); } }; }
Example #2
Source File: RecyclerViewActions.java From android-test with Apache License 2.0 | 5 votes |
/** * Finds positions of items in {@link RecyclerView} which is matching given viewHolderMatcher. * This is similar to positionMatching(RecyclerView, Matcher<VH>), except that it returns list of * multiple positions if there are, rather than throwing Ambiguous view error exception. * * @param recyclerView recycler view which is hosting items. * @param viewHolderMatcher a <a * href="http://hamcrest.org/JavaHamcrest/javadoc/1.3/org/hamcrest/Matcher.html"><code>Matcher * </code></a> that matches an item view in {@link RecyclerView} * @return list of MatchedItem which contains position and description of items in recyclerView. * @throws RuntimeException if more than one item or item could not be found. */ @SuppressWarnings("unchecked") private static <T extends VH, VH extends ViewHolder> List<MatchedItem> itemsMatching( final RecyclerView recyclerView, final Matcher<VH> viewHolderMatcher, int max) { final Adapter<T> adapter = recyclerView.getAdapter(); SparseArray<VH> viewHolderCache = new SparseArray<VH>(); List<MatchedItem> matchedItems = new ArrayList<MatchedItem>(); for (int position = 0; position < adapter.getItemCount(); position++) { int itemType = adapter.getItemViewType(position); VH cachedViewHolder = viewHolderCache.get(itemType); // Create a view holder per type if not exists if (null == cachedViewHolder) { cachedViewHolder = adapter.createViewHolder(recyclerView, itemType); viewHolderCache.put(itemType, cachedViewHolder); } // Bind data to ViewHolder and apply matcher to view descendants. adapter.bindViewHolder((T) cachedViewHolder, position); if (viewHolderMatcher.matches(cachedViewHolder)) { matchedItems.add( new MatchedItem( position, HumanReadables.getViewHierarchyErrorMessage( cachedViewHolder.itemView, null, "\n\n*** Matched ViewHolder item at position: " + position + " ***", null))); adapter.onViewRecycled((T) cachedViewHolder); if (matchedItems.size() == max) { break; } } else { adapter.onViewRecycled((T) cachedViewHolder); } } return matchedItems; }
Example #3
Source File: DiffResult.java From epoxy with Apache License 2.0 | 4 votes |
public void dispatchTo(Adapter adapter) { dispatchTo(new AdapterListUpdateCallback(adapter)); }