Commit 2188241b authored by Shailesh Baldaniya's avatar Shailesh Baldaniya

fix: Drawable tinting

parent 98812bdf
...@@ -6,6 +6,7 @@ import android.content.Intent ...@@ -6,6 +6,7 @@ import android.content.Intent
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.os.Bundle import android.os.Bundle
import android.support.v4.app.Fragment import android.support.v4.app.Fragment
import android.support.v7.app.AppCompatActivity
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.util.extensions.addFragment import chat.rocket.android.util.extensions.addFragment
import chat.rocket.android.util.extensions.textContent import chat.rocket.android.util.extensions.textContent
......
...@@ -3,6 +3,7 @@ package chat.rocket.android.chatrooms.ui ...@@ -3,6 +3,7 @@ package chat.rocket.android.chatrooms.ui
import DateTimeHelper import DateTimeHelper
import DrawableHelper import DrawableHelper
import android.content.Context import android.content.Context
import android.graphics.drawable.Drawable
import android.support.v4.content.ContextCompat import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
import android.view.View import android.view.View
...@@ -70,18 +71,30 @@ class ChatRoomsAdapter(private val context: Context, ...@@ -70,18 +71,30 @@ class ChatRoomsAdapter(private val context: Context,
} }
private fun bindName(chatRoom: ChatRoom, textView: TextView) { private fun bindName(chatRoom: ChatRoom, textView: TextView) {
textView.textContent = chatRoom.name
var drawable: Drawable? = null
when (chatRoom.type) { when (chatRoom.type) {
is RoomType.Channel -> { is RoomType.Channel -> {
DrawableHelper.compoundDrawable(textView, DrawableHelper.getDrawableFromId(R.drawable.ic_room_channel, context)) drawable = DrawableHelper.getDrawableFromId(R.drawable.ic_room_channel, context)
} }
is RoomType.PrivateGroup -> { is RoomType.PrivateGroup -> {
DrawableHelper.compoundDrawable(textView, DrawableHelper.getDrawableFromId(R.drawable.ic_room_lock, context)) drawable = DrawableHelper.getDrawableFromId(R.drawable.ic_room_lock, context)
} }
is RoomType.DirectMessage -> { is RoomType.DirectMessage -> {
DrawableHelper.compoundDrawable(textView, DrawableHelper.getDrawableFromId(R.drawable.ic_room_dm, context)) drawable = DrawableHelper.getDrawableFromId(R.drawable.ic_room_dm, context)
} }
} }
textView.textContent = chatRoom.name
drawable?.let {
DrawableHelper.wrapDrawable(it)
DrawableHelper.tintDrawable(it, context,
when (chatRoom.alert || chatRoom.unread > 0) {
true -> R.color.colorPrimaryText
false -> R.color.colorSecondaryText
})
DrawableHelper.compoundDrawable(textView, it)
}
} }
private fun bindLastMessageDateTime(chatRoom: ChatRoom, textView: TextView) { private fun bindLastMessageDateTime(chatRoom: ChatRoom, textView: TextView) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment