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
4b4c84f7
Commit
4b4c84f7
authored
Aug 29, 2017
by
Filipe de Lima Brito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update RoomListItemView.java
parent
d407dfb8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
32 deletions
+63
-32
RoomListItemView.java
...chat/rocket/android/widget/internal/RoomListItemView.java
+63
-32
No files found.
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/internal/RoomListItemView.java
View file @
4b4c84f7
...
...
@@ -3,29 +3,31 @@ 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.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
java.util.HashMap
;
import
chat.rocket.android.widget.R
;
import
chat.rocket.android.widget.helper.DrawableHelper
;
/**
* Room list-item view used in sidebar.
*/
public
class
RoomListItemView
extends
FrameLayout
{
private
static
HashMap
<
String
,
Integer
>
ICON_TABLE
=
new
HashMap
<
String
,
Integer
>()
{
{
put
(
"c"
,
R
.
string
.
fa_hashtag
);
put
(
"p"
,
R
.
string
.
fa_lock
);
put
(
"d"
,
R
.
string
.
fa_at
);
}
};
private
String
roomId
;
private
String
roomName
;
private
ImageView
roomTypeImage
;
private
ImageView
userStatusImage
;
private
TextView
roomNameText
;
private
TextView
alertCountText
;
private
Drawable
privateChannelDrawable
;
private
Drawable
publicChannelDrawable
;
private
Drawable
userStatusDrawable
;
public
RoomListItemView
(
Context
context
)
{
super
(
context
);
...
...
@@ -49,8 +51,7 @@ public class RoomListItemView extends FrameLayout {
}
private
void
initialize
(
Context
context
)
{
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
LayoutParams
.
WRAP_CONTENT
));
setLayoutParams
(
new
LinearLayout
.
LayoutParams
(
LayoutParams
.
MATCH_PARENT
,
LayoutParams
.
WRAP_CONTENT
));
TypedArray
array2
=
context
.
getTheme
().
obtainStyledAttributes
(
new
int
[]{
R
.
attr
.
selectableItemBackground
...
...
@@ -59,6 +60,15 @@ public class RoomListItemView extends FrameLayout {
array2
.
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
(
getResources
(),
R
.
drawable
.
ic_lock_white_24dp
,
null
);
publicChannelDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_hashtag_white_24dp
,
null
);
userStatusDrawable
=
VectorDrawableCompat
.
create
(
getResources
(),
R
.
drawable
.
ic_user_status_black_24dp
,
null
);
}
public
String
getRoomId
()
{
...
...
@@ -70,43 +80,64 @@ public class RoomListItemView extends FrameLayout {
return
this
;
}
public
RoomListItemView
setRoomType
(
String
type
)
{
if
(
ICON_TABLE
.
containsKey
(
type
))
{
TextView
icon
=
(
TextView
)
findViewById
(
R
.
id
.
icon
);
icon
.
setText
(
ICON_TABLE
.
get
(
type
));
}
return
this
;
}
public
RoomListItemView
setUnreadCount
(
int
count
)
{
View
alertCountContainer
=
findViewById
(
R
.
id
.
alert_count_container
);
TextView
alertCount
=
(
TextView
)
findViewById
(
R
.
id
.
alert_count
);
if
(
count
>
0
)
{
alertCount
.
setText
(
Integer
.
toString
(
count
));
alertCount
Container
.
setVisibility
(
View
.
VISIBLE
);
alertCount
Text
.
setText
(
String
.
valueOf
(
count
));
alertCount
Text
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
alertCount
Container
.
setVisibility
(
View
.
GONE
);
alertCount
Text
.
setVisibility
(
View
.
GONE
);
}
return
this
;
}
public
RoomListItemView
setAlert
(
boolean
alert
)
{
setAlpha
(
alert
?
1.0f
:
0.62f
);
return
this
;
}
public
String
getRoomName
()
{
return
roomName
;
return
roomName
Text
.
toString
()
;
}
public
RoomListItemView
setRoomName
(
String
roomName
)
{
this
.
roomName
=
roomName
;
TextView
text
=
(
TextView
)
findViewById
(
R
.
id
.
text
)
;
text
.
setText
(
roomName
);
roomNameText
.
setText
(
roomName
)
;
return
this
;
}
public
RoomListItemView
showPrivateChannelIcon
()
{
roomTypeImage
.
setImageDrawable
(
privateChannelDrawable
);
roomTypeImage
.
setVisibility
(
VISIBLE
);
return
this
;
}
}
public
RoomListItemView
showPublicChannelIcon
()
{
roomTypeImage
.
setImageDrawable
(
publicChannelDrawable
);
roomTypeImage
.
setVisibility
(
VISIBLE
);
return
this
;
}
public
RoomListItemView
showOnlineUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_online
);
return
this
;
}
public
RoomListItemView
showBusyUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_busy
);
return
this
;
}
public
RoomListItemView
showAwayUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_away
);
return
this
;
}
public
RoomListItemView
showOfflineUserStatusIcon
()
{
prepareDrawableAndShow
(
R
.
color
.
color_user_status_offline
);
return
this
;
}
private
void
prepareDrawableAndShow
(
int
colorResId
)
{
DrawableHelper
.
INSTANCE
.
wrapDrawable
(
userStatusDrawable
);
DrawableHelper
.
INSTANCE
.
tintDrawable
(
userStatusDrawable
,
getContext
(),
colorResId
);
userStatusImage
.
setImageDrawable
(
userStatusDrawable
);
userStatusImage
.
setVisibility
(
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