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
4d1976d1
Commit
4d1976d1
authored
Feb 04, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace PopupMenu for SheetMenu
parent
66883be9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
ChatRoomAdapter.kt
...n/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
+23
-14
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
View file @
4d1976d1
...
...
@@ -2,10 +2,10 @@ package chat.rocket.android.chatroom.ui
import
android.support.v7.widget.RecyclerView
import
android.text.method.LinkMovementMethod
import
android.view.MenuItem
import
android.view.View
import
android.view.ViewGroup
import
android.widget.ImageView
import
android.widget.PopupMenu
import
android.widget.TextView
import
chat.rocket.android.R
import
chat.rocket.android.chatroom.presentation.ChatRoomPresenter
...
...
@@ -21,6 +21,7 @@ import com.stfalcon.frescoimageviewer.ImageViewer
import
kotlinx.android.synthetic.main.avatar.view.*
import
kotlinx.android.synthetic.main.item_message.view.*
import
kotlinx.android.synthetic.main.message_attachment.view.*
import
ru.whalemare.sheetmenu.SheetMenu
class
ChatRoomAdapter
(
private
val
serverUrl
:
String
,
private
val
roomType
:
String
,
...
...
@@ -81,9 +82,12 @@ class ChatRoomAdapter(private val serverUrl: String,
val
serverUrl
:
String
,
val
roomType
:
String
,
val
roomName
:
String
,
val
presenter
:
ChatRoomPresenter
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
val
presenter
:
ChatRoomPresenter
)
:
RecyclerView
.
ViewHolder
(
itemView
),
MenuItem
.
OnMenuItemClickListener
{
private
lateinit
var
messageViewModel
:
MessageViewModel
fun
bind
(
message
:
MessageViewModel
)
=
with
(
itemView
)
{
messageViewModel
=
message
bindUserAvatar
(
message
,
image_avatar
,
image_unknown_avatar
)
text_user_name
.
content
=
message
.
sender
text_message_time
.
content
=
message
.
time
...
...
@@ -95,20 +99,25 @@ class ChatRoomAdapter(private val serverUrl: String,
text_content
.
setOnClickListener
{
if
(!
message
.
systemMessage
)
{
val
popup
=
PopupMenu
(
it
.
context
,
it
)
popup
.
menuInflater
.
inflate
(
R
.
menu
.
message_actions
,
popup
.
menu
)
popup
.
setOnMenuItemClickListener
{
when
(
it
.
itemId
)
{
R
.
id
.
action_menu_msg_delete
->
presenter
.
deleteMessage
(
message
.
roomId
,
message
.
id
)
R
.
id
.
action_menu_msg_quote
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
message
.
id
,
""
,
false
)
R
.
id
.
action_menu_msg_reply
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
message
.
id
,
""
,
true
)
else
->
TODO
(
"Not implemented"
)
SheetMenu
().
apply
{
click
=
this
@ViewHolder
menu
=
R
.
menu
.
message_actions
}.
show
(
it
.
context
)
}
}
true
}
popup
.
show
()
override
fun
onMenuItemClick
(
item
:
MenuItem
):
Boolean
{
messageViewModel
.
apply
{
when
(
item
.
itemId
)
{
R
.
id
.
action_menu_msg_delete
->
presenter
.
deleteMessage
(
roomId
,
id
)
R
.
id
.
action_menu_msg_quote
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
id
,
""
,
false
)
R
.
id
.
action_menu_msg_reply
->
presenter
.
citeMessage
(
serverUrl
,
roomType
,
roomName
,
id
,
""
,
true
)
else
->
TODO
(
"Not implemented"
)
}
}
return
true
}
private
fun
bindAttachment
(
message
:
MessageViewModel
,
...
...
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