androidx.recyclerview.widget.SortedList Java Examples

The following examples show how to use androidx.recyclerview.widget.SortedList. 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);
}
 
Example #2
Source File: QiscusBaseChatAdapter.java    From qiscus-sdk-android with Apache License 2.0 4 votes vote down vote up
public QiscusBaseChatAdapter(Context context, boolean groupChat, boolean channelRoom) {
    this.context = context;
    this.groupChat = groupChat;
    this.channelRoom = channelRoom;
    data = new SortedList<>(getItemClass(), new SortedList.Callback<E>() {
        @Override
        public int compare(E lhs, E rhs) {
            return QiscusBaseChatAdapter.this.compare(lhs, rhs);
        }

        @Override
        public void onInserted(int position, int count) {
            checkChaining(position);
        }

        @Override
        public void onRemoved(int position, int count) {
        }

        @Override
        public void onMoved(int fromPosition, int toPosition) {
            notifyItemMoved(fromPosition, toPosition);
            notifyItemChanged(toPosition);
        }

        @Override
        public void onChanged(int position, int count) {
            checkChaining(position);
        }

        @Override
        public boolean areContentsTheSame(E oldE, E newE) {
            return oldE.equals(newE);
        }

        @Override
        public boolean areItemsTheSame(E oldE, E newE) {
            return oldE.equals(newE);
        }
    });
    qiscusAccount = Qiscus.getQiscusAccount();
    members = new HashMap<>();
}
 
Example #3
Source File: QiscusBaseChatAdapter.java    From qiscus-sdk-android with Apache License 2.0 4 votes vote down vote up
public SortedList<E> getData() {
    return data;
}
 
Example #4
Source File: StoryRecyclerViewAdapter.java    From materialistic with Apache License 2.0 4 votes vote down vote up
public SortedList<Item> getItems() {
    return mItems;
}
 
Example #5
Source File: ObservableSortedList.java    From deagle with Apache License 2.0 4 votes vote down vote up
public ObservableSortedList(final Class<T> clazz) {
	mList = new SortedList<>(clazz, new CallbackWrapper());
}
 
Example #6
Source File: ObservableSortedList.java    From deagle with Apache License 2.0 votes vote down vote up
@Override public boolean contains(final Object object) { return indexOf(object) != SortedList.INVALID_POSITION; }