androidx.recyclerview.widget.SortedListAdapterCallback Java Examples

The following examples show how to use androidx.recyclerview.widget.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: ItemsAdapter.java    From appbarsyncedfab with Apache License 2.0 6 votes vote down vote up
ItemsAdapter(OnItemClickListener onItemClickListener) {
    this.onItemClickListener = onItemClickListener;
    dataset = new SortedList<>(Long.class, new SortedListAdapterCallback<Long>(this) { // yes, we're leaking half-constructed this. Currently, it's fine.
        @Override
        public int compare(Long left, Long right) {
            return Long.compare(left, right);
        }

        @Override
        public boolean areContentsTheSame(Long oldItem, Long newItem) {
            return Objects.equals(oldItem, newItem);
        }

        @Override
        public boolean areItemsTheSame(Long item1, Long item2) {
            return Objects.equals(item1, item2);
        }
    });
    setHasStableIds(true);
}