@@ -17,66 +18,49 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
...
@@ -17,66 +18,49 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
itemView.setOnClickListener(view->{
itemView.setOnClickListener(view->{
Objectobject=view.getTag();
Objectobject=view.getTag();
if(objectinstanceofRoom){
if(objectinstanceofRoomSidebar){
listener.onItemClick((Room)object);
listener.onItemClick((RoomSidebar)object);
}elseif(objectinstanceofSpotlight){
}elseif(objectinstanceofSpotlight){
listener.onItemClick((Spotlight)object);
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){
StringroomType=roomSidebar.getType();
itemView
if(roomType.equals(Room.TYPE_DIRECT_MESSAGE)){
.setRoomId(room.getRoomId())
showUserStatusIcon(roomSidebar.getUserStatus());
.setRoomName(room.getName())
}else{
.setAlert(room.isAlert())
showRoomIcon(roomType);
.setUnreadCount(room.getUnread())
}
.setTag(room);
showRoomIcon(room.getType());
}
}
publicvoidbind(Spotlightspotlight){
publicvoidbind(Spotlightspotlight){
itemView
itemView.setRoomId(spotlight.getId());
.setRoomId(spotlight.getId())
itemView.setRoomName(spotlight.getName());
.setRoomName(spotlight.getName())
itemView.setAlert(false);
.setAlert(false)
itemView.setUnreadCount(0);
.setUnreadCount(0)
itemView.setTag(spotlight);
.setTag(spotlight);
showRoomIcon(spotlight.getType());
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.
* 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
* @see User
*/
*/
publicvoidbind(Useruser){
privatevoidshowUserStatusIcon(StringuserStatus){
StringuserStatus=user.getStatus();
if(userStatus==null){
if(userStatus==null){
itemView.showOfflineUserStatusIcon();
itemView.showOfflineUserStatusIcon();
}else{
}else{
switch(user.getStatus()){
switch(userStatus){
caseUser.STATUS_ONLINE:
caseUser.STATUS_ONLINE:
itemView.showOnlineUserStatusIcon();
itemView.showOnlineUserStatusIcon();
break;
break;
...
@@ -92,4 +76,20 @@ public class RoomListItemViewHolder extends RecyclerView.ViewHolder {
...
@@ -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.