@@ -17,66 +18,49 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
itemView.setOnClickListener(view->{
Objectobject=view.getTag();
if(objectinstanceofRoom){
listener.onItemClick((Room)object);
if(objectinstanceofRoomSidebar){
listener.onItemClick((RoomSidebar)object);
}elseif(objectinstanceofSpotlight){
listener.onItemClick((Spotlight)object);
}
});
}
publicvoidbind(RoomSidebarroomSidebar){
itemView.setRoomId(roomSidebar.getRoomId());
itemView.setRoomName(roomSidebar.getRoomName());
itemView.setAlert(roomSidebar.isAlert());
itemView.setUnreadCount(roomSidebar.getUnread());
itemView.setTag(roomSidebar);
publicvoidbind(Roomroom){
itemView
.setRoomId(room.getRoomId())
.setRoomName(room.getName())
.setAlert(room.isAlert())
.setUnreadCount(room.getUnread())
.setTag(room);
showRoomIcon(room.getType());
StringroomType=roomSidebar.getType();
if(roomType.equals(Room.TYPE_DIRECT_MESSAGE)){
showUserStatusIcon(roomSidebar.getUserStatus());
}else{
showRoomIcon(roomType);
}
}
publicvoidbind(Spotlightspotlight){
itemView
.setRoomId(spotlight.getId())
.setRoomName(spotlight.getName())
.setAlert(false)
.setUnreadCount(0)
.setTag(spotlight);
itemView.setRoomId(spotlight.getId());
itemView.setRoomName(spotlight.getName());
itemView.setAlert(false);
itemView.setUnreadCount(0);
itemView.setTag(spotlight);
showRoomIcon(spotlight.getType());
}
/**
* Only shows the room icon if it is a PRIVATE CHANNEL or PUBLIC CHANNEL, otherwise you should use {@link #bind(User)} to show the correct icon.
* @param roomType The type of Room.
* @see Room
*/
privatevoidshowRoomIcon(StringroomType){
if(!roomType.equals(Room.TYPE_DIRECT_MESSAGE)){
switch(roomType){
caseRoom.TYPE_CHANNEL:
itemView.showPublicChannelIcon();
break;
caseRoom.TYPE_PRIVATE:
itemView.showPrivateChannelIcon();
break;
}
}
}
/**
* Shows the user status icon.
* @param user The user to show its status.
* @param userStatus The user status to show the correspondent icon.
* @see User
*/
publicvoidbind(Useruser){
StringuserStatus=user.getStatus();
privatevoidshowUserStatusIcon(StringuserStatus){
if(userStatus==null){
itemView.showOfflineUserStatusIcon();
}else{
switch(user.getStatus()){
switch(userStatus){
caseUser.STATUS_ONLINE:
itemView.showOnlineUserStatusIcon();
break;
...
...
@@ -92,4 +76,20 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
}
}
}
/**
* Only shows the room icon if it is a PRIVATE CHANNEL or PUBLIC CHANNEL, otherwise you should use {@link #showUserStatusIcon(String)} to show the icon.