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
defea92a
Commit
defea92a
authored
Oct 02, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into feature/db-save-messages
parents
ac348b69
067edc43
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 @
defea92a
...
...
@@ -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