package chat.rocket.android.layouthelper.chatroom.roomlist;

import android.support.v7.widget.RecyclerView;

import chat.rocket.android.widget.internal.RoomListItemView;
import chat.rocket.core.models.Room;
import chat.rocket.core.models.Spotlight;

public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
  public RoomListItemViewHolder(RoomListItemView itemView,
                                RoomListAdapter.OnItemClickListener listener) {
    super(itemView);

    itemView.setOnClickListener(view -> {
      if (listener != null) {
        Object tag = view.getTag();

        if (tag instanceof Room) {
          listener.onItemClick((Room) view.getTag());
        } else if (tag instanceof Spotlight) {
          listener.onItemClick((Spotlight) view.getTag());
        }
      }
    });
  }

  public void bind(Room room) {
    ((RoomListItemView) itemView)
        .setRoomId(room.getRoomId())
        .setRoomName(room.getName())
        .setRoomType(room.getType())
        .setAlert(room.isAlert())
        .setUnreadCount(room.getUnread())
        .setTag(room);
  }

  public void bind(Spotlight spotlight) {
    ((RoomListItemView) itemView)
        .setRoomId(spotlight.getId())
        .setRoomName(spotlight.getName())
        .setRoomType(spotlight.getType())
        .setAlert(false)
        .setUnreadCount(0)
        .setTag(spotlight);
  }
}

@@ -241,16 +241,53 @@
 otlight;
+%0Aimport chat.rocket.core.models.User;
 %0A%0Apublic
@@ -350,16 +350,54 @@
 older %7B%0A
+  private RoomListItemView itemView;%0A%0A
   public
@@ -450,40 +450,8 @@
 iew,
-%0A                               
  Roo
@@ -513,24 +513,55 @@
 itemView);%0A%0A
+    this.itemView = itemView;%0A%0A
     itemView
@@ -594,40 +594,8 @@
 %3E %7B%0A
-      if (listener != null) %7B%0A  
     
@@ -603,19 +603,22 @@
  Object 
-tag
+object
  = view.
@@ -631,24 +631,24 @@
 ();%0A
-%0A 
       
- 
 if (
-tag
+object
  ins
@@ -659,26 +659,24 @@
 eof Room) %7B%0A
-  
         list
@@ -698,35 +698,25 @@
 k((Room)
- view.getTag()
+object
 );%0A
-  
       %7D 
@@ -728,11 +728,14 @@
 if (
-tag
+object
  ins
@@ -751,26 +751,24 @@
 potlight) %7B%0A
-  
         list
@@ -799,34 +799,16 @@
 ght)
- view.getTag());%0A        %7D
+object);
 %0A   
@@ -817,32 +817,33 @@
  %7D%0A    %7D);%0A  %7D%0A%0A
+%0A
   public void bi
@@ -861,36 +861,16 @@
 m) %7B%0A   
- ((RoomListItemView)
  itemVie
@@ -862,33 +862,32 @@
 ) %7B%0A    itemView
-)
 %0A        .setRoo
@@ -949,45 +949,8 @@
 ())%0A
-        .setRoomType(room.getType())%0A
     
@@ -1043,16 +1043,53 @@
 g(room);
+%0A%0A      showRoomIcon(room.getType());
 %0A  %7D%0A%0A  
@@ -1135,28 +1135,8 @@
 %0A   
- ((RoomListItemView)
  ite
@@ -1140,17 +1140,16 @@
 itemView
-)
 %0A       
@@ -1225,50 +1225,8 @@
 ())%0A
-        .setRoomType(spotlight.getType())%0A
     
@@ -1304,11 +1304,1280 @@
 ht);
+%0A%0A    showRoomIcon(spotlight.getType());%0A  %7D%0A%0A  /**%0A   * Only shows the room icon if it is a PRIVATE CHANNEL or PUBLIC CHANNEL, otherwise you should use %7B@link #bind(User)%7D to show the correct icon.%0A   * @param roomType The type of Room.%0A   * @see Room%0A   */%0A  private void showRoomIcon(String roomType) %7B%0A    if(!roomType.equals(Room.TYPE_DIRECT_MESSAGE)) %7B%0A      switch (roomType) %7B%0A        case Room.TYPE_CHANNEL:%0A          itemView.showPublicChannelIcon();%0A          break;%0A        case Room.TYPE_PRIVATE:%0A          itemView.showPrivateChannelIcon();%0A          break;%0A      %7D%0A    %7D%0A  %7D%0A%0A  /**%0A   * Shows the user status icon.%0A   * @param user The user to show its status.%0A   * @see User%0A   */%0A  public void bind(User user) %7B%0A    String userStatus = user.getStatus();%0A    if (userStatus == null) %7B%0A      itemView.showOfflineUserStatusIcon();%0A    %7D else %7B%0A      switch (user.getStatus()) %7B%0A        case User.STATUS_ONLINE:%0A          itemView.showOnlineUserStatusIcon();%0A          break;%0A        case User.STATUS_BUSY:%0A          itemView.showBusyUserStatusIcon();%0A          break;%0A        case User.STATUS_AWAY:%0A          itemView.showAwayUserStatusIcon();%0A          break;%0A        default:%0A          itemView.showOfflineUserStatusIcon();%0A          break;%0A      %7D%0A    %7D
 %0A  %7D%0A%7D
-%0A

Update RoomListItemViewHolder.java