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
031a27fa
Commit
031a27fa
authored
Oct 01, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the logic to render multiple mentions to the same user and
@all
or @here
parent
123d05d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
8 deletions
+4
-8
MessageParser.kt
...src/main/java/chat/rocket/android/helper/MessageParser.kt
+4
-8
No files found.
app/src/main/java/chat/rocket/android/helper/MessageParser.kt
View file @
031a27fa
...
...
@@ -143,23 +143,19 @@ class MessageParser @Inject constructor(
override
fun
visit
(
document
:
Document
)
{
val
text
=
builder
.
text
()
val
mentionsList
=
mentions
.
toMutableList
().
also
{
it
.
add
(
"@all"
)
it
.
add
(
"@here"
)
}.
distinct
()
mentionsList
.
forEach
{
var
offset
=
0
mentions
.
forEach
{
val
mentionMe
=
it
==
currentUser
||
it
==
"@all"
||
it
==
"@here"
var
offset
=
text
.
indexOf
(
string
=
it
,
startIndex
=
0
,
ignoreCase
=
false
)
offset
=
text
.
indexOf
(
string
=
it
,
startIndex
=
offset
,
ignoreCase
=
false
)
while
(
offset
>
-
1
)
{
val
textColor
=
if
(
mentionMe
)
myselfTextColor
else
othersTextColor
val
backgroundColor
=
if
(
mentionMe
)
myselfBackgroundColor
else
othersBackgroundColor
val
usernameSpan
=
MentionSpan
(
backgroundColor
,
textColor
,
radius
,
padding
,
mentionMe
)
// Add 1 to end offset to include the @.
val
end
=
offset
+
it
.
length
builder
.
setSpan
(
usernameSpan
,
offset
,
end
,
Spannable
.
SPAN_EXCLUSIVE_EXCLUSIVE
)
offset
=
text
.
indexOf
(
string
=
"@$it"
,
startIndex
=
end
,
ignoreCase
=
false
)
offset
=
text
.
indexOf
(
string
=
it
,
startIndex
=
end
,
ignoreCase
=
false
)
}
}
}
...
...
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