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
24ca7547
Commit
24ca7547
authored
Feb 04, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create and show a popup when clicking on a message
parent
9f22aed7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
10 deletions
+20
-10
ChatRoomAdapter.kt
...n/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
+20
-10
No files found.
app/src/main/java/chat/rocket/android/chatroom/ui/ChatRoomAdapter.kt
View file @
24ca7547
...
...
@@ -23,6 +23,8 @@ import kotlinx.android.synthetic.main.item_message.view.*
import
kotlinx.android.synthetic.main.message_attachment.view.*
class
ChatRoomAdapter
(
private
val
serverUrl
:
String
,
private
val
roomType
:
String
,
private
val
roomName
:
String
,
private
val
presenter
:
ChatRoomPresenter
)
:
RecyclerView
.
Adapter
<
ChatRoomAdapter
.
ViewHolder
>()
{
init
{
...
...
@@ -32,7 +34,7 @@ class ChatRoomAdapter(private val serverUrl: String,
val
dataSet
=
ArrayList
<
MessageViewModel
>()
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
=
ViewHolder
(
parent
.
inflate
(
R
.
layout
.
item_message
),
serverUrl
,
presenter
)
ViewHolder
(
parent
.
inflate
(
R
.
layout
.
item_message
),
serverUrl
,
roomType
,
roomName
,
presenter
)
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
=
holder
.
bind
(
dataSet
[
position
])
...
...
@@ -75,7 +77,11 @@ class ChatRoomAdapter(private val serverUrl: String,
return
dataSet
[
position
].
id
.
hashCode
().
toLong
()
}
class
ViewHolder
(
itemView
:
View
,
val
serverUrl
:
String
,
val
presenter
:
ChatRoomPresenter
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
class
ViewHolder
(
itemView
:
View
,
val
serverUrl
:
String
,
val
roomType
:
String
,
val
roomName
:
String
,
val
presenter
:
ChatRoomPresenter
)
:
RecyclerView
.
ViewHolder
(
itemView
)
{
fun
bind
(
message
:
MessageViewModel
)
=
with
(
itemView
)
{
bindUserAvatar
(
message
,
image_avatar
,
image_unknown_avatar
)
...
...
@@ -88,16 +94,20 @@ class ChatRoomAdapter(private val serverUrl: String,
file_name
)
text_content
.
setOnClickListener
{
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
)
else
->
TODO
(
"Not implemented"
)
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"
)
}
true
}
true
popup
.
show
()
}
popup
.
show
()
}
}
...
...
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