how to group recyclerview by date in android studio code example

Example 1: group recyclerview list by date in android studio

public class DateObject extends ListObject {
        private String date;

        public String getDate() {
            return date;
        }

        public void setDate(String date) {
            this.date = date;
        }

        @Override
        public int getType(int userId) {
            return TYPE_DATE;
        }
    }

Example 2: group recyclerview list by date in android studio

public abstract class ListObject {
        public static final int TYPE_DATE = 0;
        public static final int TYPE_GENERAL_RIGHT = 1;
        public static final int TYPE_GENERAL_LEFT = 2;

        abstract public int getType(int userId);
    }

Example 3: group recyclerview list by date in android studio

public class ChatLeftViewHolder extends RecyclerView.ViewHolder {
        private final String TAG = ChatRightViewHolder.class.getSimpleName();

        public ChatLeftViewHolder(View itemView) {
            super(itemView);
            //TODO initialize your xml views
        }

        public void bind(final ChatModel chatModel) {
            //TODO set data to xml view via textivew.setText();
        }
    }

Tags:

Java Example