@Override public void onBindHeaderViewHolder(RecyclerView.ViewHolder holder, int position) { View view = holder.itemView; TextView headerTextView = (TextView) view.findViewById(R.id.header_date_textview); CombinationMessage combinationMessage = getItem(position); headerTextView.setText( DateUtils.toTodayYesterdayFullMonthDate(combinationMessage.getCreatedDate())); }
protected int getItemViewType(CombinationMessage combinationMessage) { boolean ownMessage = !combinationMessage.isIncoming(currentUser.getId()); if (combinationMessage.getNotificationType() == null) { if (ownMessage) { return TYPE_OWN_MESSAGE; } else { return TYPE_OPPONENT_MESSAGE; } } else { return TYPE_REQUEST_MESSAGE; } }
@Override public long getHeaderId(int position) { CombinationMessage combinationMessage = getItem(position); return DateUtils.toShortDateLong(combinationMessage.getCreatedDate()); }