android.support.v7.widget.util.SortedListAdapterCallback Java Examples
The following examples show how to use
android.support.v7.widget.util.SortedListAdapterCallback.
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: SortedAdapterDataStructure.java From AutoAdapter with Apache License 2.0 | 6 votes |
public SortedAdapterDataStructure(@NonNull final SortedAutoAdapter autoAdapter) { super(OrderableRenderer.class, new SortedListAdapterCallback<OrderableRenderer>(autoAdapter) { @Override public int compare(OrderableRenderer o1, OrderableRenderer o2) { return autoAdapter.compare(o1, o2); } @Override public boolean areContentsTheSame(OrderableRenderer oldItem, OrderableRenderer newItem) { return autoAdapter.areContentsTheSame(oldItem, newItem); } @Override public boolean areItemsTheSame(OrderableRenderer item1, OrderableRenderer item2) { return autoAdapter.areItemsTheSame(item1, item2); } }); }
Example #2
Source File: SortedMessageCollection.java From Game-of-Thrones with Apache License 2.0 | 6 votes |
public SortedMessageCollection(RecyclerView.Adapter adapter) { messageList = new SortedList<Message>(Message.class, new SortedListAdapterCallback<Message>(adapter) { @Override public int compare(Message o1, Message o2) { return o1.compareTo(o2); } @Override public boolean areContentsTheSame(Message oldItem, Message newItem) { return oldItem.equals(newItem); } @Override public boolean areItemsTheSame(Message item1, Message item2) { return item1.getId().equals(item2.getId()); } }); }
Example #3
Source File: FilteredSortedListAdapter.java From materialize with GNU General Public License v3.0 | 6 votes |
public FilteredSortedListAdapter(Class<T> type, FilteredSortedList.Filter<T> filter) { this.data = new FilteredSortedList<>(type, new SortedListAdapterCallback<T>(this) { @Override public int compare(T lhs, T rhs) { return FilteredSortedListAdapter.this.compare(lhs, rhs); } @Override public boolean areContentsTheSame(T oldItem, T newItem) { return FilteredSortedListAdapter.this.areContentsTheSame(oldItem, newItem); } @Override public boolean areItemsTheSame(T item1, T item2) { return FilteredSortedListAdapter.this.areItemsTheSame(item1, item2); } }, filter); }
Example #4
Source File: FeedAdapter.java From dev-summit-architecture-demo with Apache License 2.0 | 5 votes |
public FeedAdapter(Context context) { mLayoutInflater = LayoutInflater.from(context); mList = new SortedList<>(FeedItem.class, new SortedListAdapterCallback<FeedItem>(this) { @Override public int compare(FeedItem o1, FeedItem o2) { Post p2 = o2.getPost(); Post p1 = o1.getPost(); if (p1.isPending() != p2.isPending()) { return p1.isPending() ? -1 : 1; } return (int) (p2.getCreated() - p1.getCreated()); } @SuppressWarnings("SimplifiableIfStatement") @Override public boolean areContentsTheSame(FeedItem oldItem, FeedItem newItem) { Post oldPost = oldItem.getPost(); Post newPost = newItem.getPost(); if (oldPost.getId() != newPost.getId()) { return false; } if (!oldPost.getText().equals(newPost.getText())) { return false; } if (!oldItem.getUser().getName().equals(newItem.getUser().getName())) { return false; } return oldItem.getPost().isPending() == newItem.getPost().isPending(); } @Override public boolean areItemsTheSame(FeedItem item1, FeedItem item2) { return item1.getPost().getId() == item2.getPost().getId(); } }); }