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
df9f1480
Commit
df9f1480
authored
Feb 07, 2018
by
Leonardo Aramaki
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'markdown-support' into message-actions
parents
f25e08a5
e0d9e0cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
MessageViewModelMapper.kt
...cket/android/chatroom/viewmodel/MessageViewModelMapper.kt
+5
-2
MessageParser.kt
...src/main/java/chat/rocket/android/helper/MessageParser.kt
+8
-9
No files found.
app/src/main/java/chat/rocket/android/chatroom/viewmodel/MessageViewModelMapper.kt
View file @
df9f1480
...
...
@@ -6,6 +6,8 @@ import chat.rocket.android.server.domain.MessagesRepository
import
chat.rocket.core.TokenRepository
import
chat.rocket.core.model.Message
import
chat.rocket.core.model.Value
import
kotlinx.coroutines.experimental.CommonPool
import
kotlinx.coroutines.experimental.launch
import
javax.inject.Inject
class
MessageViewModelMapper
@Inject
constructor
(
private
val
context
:
Context
,
...
...
@@ -13,8 +15,9 @@ class MessageViewModelMapper @Inject constructor(private val context: Context,
private
val
messageParser
:
MessageParser
,
private
val
messagesRepository
:
MessagesRepository
)
{
suspend
fun
mapToViewModel
(
message
:
Message
,
settings
:
Map
<
String
,
Value
<
Any
>>)
=
MessageViewModel
(
context
,
tokenRepository
.
get
(),
message
,
settings
,
messageParser
,
messagesRepository
)
suspend
fun
mapToViewModel
(
message
:
Message
,
settings
:
Map
<
String
,
Value
<
Any
>>)
=
launch
(
CommonPool
)
{
MessageViewModel
(
this
@MessageViewModelMapper
.
context
,
tokenRepository
.
get
(),
message
,
settings
,
messageParser
,
messagesRepository
)
}
suspend
fun
mapToViewModelList
(
messageList
:
List
<
Message
>,
settings
:
Map
<
String
,
Value
<
Any
>>):
List
<
MessageViewModel
>
{
return
messageList
.
map
{
MessageViewModel
(
context
,
tokenRepository
.
get
(),
it
,
settings
,
messageParser
,
messagesRepository
)
}
...
...
app/src/main/java/chat/rocket/android/helper/MessageParser.kt
View file @
df9f1480
...
...
@@ -128,12 +128,11 @@ class MessageParser @Inject constructor(val context: Application, private val co
}
}
class
QuoteMarginSpan
(
b
:
Drawable
,
pad
:
Int
)
:
LeadingMarginSpan
,
LineHeightSpan
{
private
var
mDrawable
:
Drawable
?
=
b
private
var
mPad
:
Int
=
pad
class
QuoteMarginSpan
(
quoteDrawable
:
Drawable
,
private
var
pad
:
Int
)
:
LeadingMarginSpan
,
LineHeightSpan
{
private
var
drawable
:
Drawable
=
quoteDrawable
override
fun
getLeadingMargin
(
first
:
Boolean
):
Int
{
return
mDrawable
!!
.
intrinsicWidth
+
mP
ad
return
drawable
.
intrinsicWidth
+
p
ad
}
override
fun
drawLeadingMargin
(
c
:
Canvas
,
p
:
Paint
,
x
:
Int
,
dir
:
Int
,
...
...
@@ -143,18 +142,18 @@ class MessageParser @Inject constructor(val context: Application, private val co
val
st
=
(
text
as
Spanned
).
getSpanStart
(
this
)
val
ix
=
x
val
itop
=
layout
.
getLineTop
(
layout
.
getLineForOffset
(
st
))
val
dw
=
mDrawable
!!
.
intrinsicWidth
val
dh
=
mDrawable
!!
.
intrinsicHeight
val
dw
=
drawable
.
intrinsicWidth
val
dh
=
drawable
.
intrinsicHeight
// XXX What to do about Paint?
mDrawable
!!
.
setBounds
(
ix
,
itop
,
ix
+
dw
,
itop
+
layout
.
height
)
mDrawable
!!
.
draw
(
c
)
drawable
.
setBounds
(
ix
,
itop
,
ix
+
dw
,
itop
+
layout
.
height
)
drawable
.
draw
(
c
)
}
override
fun
chooseHeight
(
text
:
CharSequence
,
start
:
Int
,
end
:
Int
,
istartv
:
Int
,
v
:
Int
,
fm
:
Paint
.
FontMetricsInt
)
{
if
(
end
==
(
text
as
Spanned
).
getSpanEnd
(
this
))
{
val
ht
=
mDrawable
!!
.
intrinsicHeight
val
ht
=
drawable
.
intrinsicHeight
var
need
=
ht
-
(
v
+
fm
.
descent
-
fm
.
ascent
-
istartv
)
if
(
need
>
0
)
fm
.
descent
+=
need
...
...
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