Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AloqaIM-Android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
AloqaIM-Android
Commits
067f81a3
Commit
067f81a3
authored
Nov 21, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show room icon accordingly with its type (when DM, show the user status icon).
parent
c1203c35
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
9 deletions
+29
-9
ChatListAdapter.kt
.../java/chat/rocket/android/app/chatlist/ChatListAdapter.kt
+29
-9
No files found.
app/src/main/java/chat/rocket/android/app/chatlist/ChatListAdapter.kt
View file @
067f81a3
package
chat.rocket.android.app.chatlist
import
DrawableHelper
import
android.content.Context
import
android.support.v7.widget.RecyclerView
import
android.view.LayoutInflater
...
...
@@ -10,7 +11,10 @@ import chat.rocket.android.R
import
com.facebook.drawee.view.SimpleDraweeView
import
kotlinx.android.synthetic.main.item_chat.view.*
class
ChatListAdapter
(
private
var
dataSet
:
List
<
Chat
>,
private
val
context
:
Context
)
:
RecyclerView
.
Adapter
<
ChatListAdapter
.
ViewHolder
>()
{
/**
* @author Filipe de Lima Brito (filipedelimabrito@gmail.com)
*/
class
ChatListAdapter
(
private
var
dataSet
:
MutableList
<
Chat
>,
private
val
context
:
Context
)
:
RecyclerView
.
Adapter
<
ChatListAdapter
.
ViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
item_chat
,
parent
,
false
)
...
...
@@ -19,22 +23,38 @@ class ChatListAdapter(private var dataSet: List<Chat>, private val context: Cont
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
val
chat
=
dataSet
[
position
]
holder
.
userAvatar
.
setImageURI
(
chat
.
userAvatarUri
)
holder
.
roomName
.
text
=
chat
.
roomN
ame
holder
.
chatName
.
text
=
chat
.
n
ame
holder
.
lastMessage
.
text
=
chat
.
lastMessage
holder
.
lastMessageTimestamp
.
text
=
chat
.
lastMessageTimestamp
val
unreadMessage
=
chat
.
unreadMessage
when
(
chat
.
type
)
{
"p"
->
DrawableHelper
.
compoundDrawable
(
holder
.
chatName
,
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_lock_outline_black
,
context
))
"c"
->
DrawableHelper
.
compoundDrawable
(
holder
.
chatName
,
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_hashtag_black
,
context
))
"d"
->
{
val
userStatusDrawable
=
DrawableHelper
.
getDrawableFromId
(
R
.
drawable
.
ic_user_status_black
,
context
).
mutate
()
DrawableHelper
.
wrapDrawable
(
userStatusDrawable
)
when
(
chat
.
userStatus
)
{
"online"
->
DrawableHelper
.
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusOnline
)
"busy"
->
DrawableHelper
.
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusBusy
)
"away"
->
DrawableHelper
.
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusAway
)
"offline"
->
DrawableHelper
.
tintDrawable
(
userStatusDrawable
,
context
,
R
.
color
.
colorUserStatusOffline
)
}
DrawableHelper
.
compoundDrawable
(
holder
.
chatName
,
userStatusDrawable
)
}
}
val
totalUnreadMessage
=
chat
.
totalUnreadMessages
when
{
u
nreadMessage
in
1
..
99
->
{
holder
.
unreadMessage
.
text
=
u
nreadMessage
.
toString
()
totalU
nreadMessage
in
1
..
99
->
{
holder
.
unreadMessage
.
text
=
totalU
nreadMessage
.
toString
()
holder
.
unreadMessage
.
visibility
=
View
.
VISIBLE
}
u
nreadMessage
>
99
->
{
totalU
nreadMessage
>
99
->
{
holder
.
unreadMessage
.
text
=
context
.
getString
(
R
.
string
.
msg_more_than_ninety_nine_unread_messages
)
holder
.
unreadMessage
.
visibility
=
View
.
VISIBLE
}
else
->
holder
.
unreadMessage
.
visibility
=
View
.
GONE
}
}
...
...
@@ -42,9 +62,9 @@ class ChatListAdapter(private var dataSet: List<Chat>, private val context: Cont
class
ViewHolder
(
itemView
:
View
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
val
userAvatar
:
SimpleDraweeView
=
itemView
.
image_user_avatar
val
roomName
:
TextView
=
itemView
.
text_room
_name
val
chatName
:
TextView
=
itemView
.
text_chat
_name
val
lastMessage
:
TextView
=
itemView
.
text_last_message
val
lastMessageTimestamp
:
TextView
=
itemView
.
text_last_message_timestamp
val
unreadMessage
:
TextView
=
itemView
.
text_
unread_message
val
unreadMessage
:
TextView
=
itemView
.
text_
total_unread_messages
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment