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
123d9aeb
Commit
123d9aeb
authored
Aug 30, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RoomListItemView.kt
parent
dc6b0bea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
129 additions
and
0 deletions
+129
-0
RoomListItemView.kt
...a/chat/rocket/android/widget/internal/RoomListItemView.kt
+129
-0
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/internal/RoomListItemView.kt
0 → 100644
View file @
123d9aeb
package
chat.rocket.android.widget.internal
import
android.annotation.TargetApi
import
android.content.Context
import
android.content.res.TypedArray
import
android.graphics.drawable.Drawable
import
android.os.Build
import
android.support.annotation.ColorRes
import
android.support.annotation.StringRes
import
android.support.graphics.drawable.VectorDrawableCompat
import
android.util.AttributeSet
import
android.view.View
import
android.widget.FrameLayout
import
android.widget.ImageView
import
android.widget.LinearLayout
import
android.widget.TextView
import
chat.rocket.android.widget.R
import
chat.rocket.android.widget.helper.DrawableHelper
/**
* Room list-item view used in sidebar.
*/
class
RoomListItemView
:
FrameLayout
{
lateinit
private
var
roomId
:
String
lateinit
private
var
roomTypeImage
:
ImageView
lateinit
private
var
userStatusImage
:
ImageView
lateinit
private
var
roomNameText
:
TextView
lateinit
private
var
alertCountText
:
TextView
lateinit
private
var
privateChannelDrawable
:
Drawable
lateinit
private
var
publicChannelDrawable
:
Drawable
lateinit
private
var
userStatusDrawable
:
Drawable
constructor
(
context
:
Context
)
:
super
(
context
)
{
initialize
(
context
)
}
constructor
(
context
:
Context
,
attrs
:
AttributeSet
)
:
super
(
context
,
attrs
)
{
initialize
(
context
)
}
constructor
(
context
:
Context
,
attrs
:
AttributeSet
,
defStyleAttr
:
Int
)
:
super
(
context
,
attrs
,
defStyleAttr
)
{
initialize
(
context
)
}
@TargetApi
(
Build
.
VERSION_CODES
.
LOLLIPOP
)
constructor
(
context
:
Context
,
attrs
:
AttributeSet
,
defStyleAttr
:
Int
,
defStyleRes
:
Int
)
:
super
(
context
,
attrs
,
defStyleAttr
,
defStyleRes
)
{
initialize
(
context
)
}
private
fun
initialize
(
context
:
Context
)
{
layoutParams
=
LinearLayout
.
LayoutParams
(
FrameLayout
.
LayoutParams
.
MATCH_PARENT
,
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
)
val
array
=
context
.
theme
.
obtainStyledAttributes
(
intArrayOf
(
R
.
attr
.
selectableItemBackground
))
background
=
array
.
getDrawable
(
0
)
array
.
recycle
()
View
.
inflate
(
context
,
R
.
layout
.
room_list_item
,
this
)
roomTypeImage
=
findViewById
(
R
.
id
.
image_room_type
)
userStatusImage
=
findViewById
(
R
.
id
.
image_user_status
)
roomNameText
=
findViewById
(
R
.
id
.
text_room_name
)
alertCountText
=
findViewById
(
R
.
id
.
text_alert_count
)
privateChannelDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_lock_white_24dp
,
null
)
!!
publicChannelDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_hashtag_white_24dp
,
null
)
!!
userStatusDrawable
=
VectorDrawableCompat
.
create
(
resources
,
R
.
drawable
.
ic_user_status_black_24dp
,
null
)
!!
}
fun
setRoomId
(
roomId
:
String
)
{
this
.
roomId
=
roomId
}
fun
setUnreadCount
(
count
:
Int
)
{
if
(
count
>
0
)
{
alertCountText
.
text
=
count
.
toString
()
alertCountText
.
visibility
=
View
.
VISIBLE
}
else
{
alertCountText
.
visibility
=
View
.
GONE
}
}
fun
setAlert
(
alert
:
Boolean
)
{
alpha
=
if
(
alert
)
1.0f
else
0.62f
}
fun
setRoomName
(
roomName
:
String
)
{
roomNameText
.
text
=
roomName
}
fun
showPrivateChannelIcon
()
{
roomTypeImage
.
setImageDrawable
(
privateChannelDrawable
)
userStatusImage
.
visibility
=
View
.
GONE
roomTypeImage
.
visibility
=
View
.
VISIBLE
}
fun
showPublicChannelIcon
()
{
roomTypeImage
.
setImageDrawable
(
publicChannelDrawable
)
userStatusImage
.
visibility
=
View
.
GONE
roomTypeImage
.
visibility
=
View
.
VISIBLE
}
fun
showOnlineUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_online
)
}
fun
showBusyUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_busy
)
}
fun
showAwayUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_away
)
}
fun
showOfflineUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_offline
)
}
private
fun
prepareDrawableAndShow
(
@ColorRes
resId
:
Int
)
{
DrawableHelper
.
wrapDrawable
(
userStatusDrawable
)
DrawableHelper
.
tintDrawable
(
userStatusDrawable
,
context
,
resId
)
userStatusImage
.
setImageDrawable
(
userStatusDrawable
)
roomTypeImage
.
visibility
=
View
.
GONE
userStatusImage
.
visibility
=
View
.
VISIBLE
}
}
\ 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