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
717824a7
Commit
717824a7
authored
Mar 13, 2018
by
Lucio Maciel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Guggy gif attachments
parent
dc3ed63a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
10 deletions
+37
-10
ImageAttachmentViewHolder.kt
...ket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
+12
-1
ViewModelMapper.kt
...chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
+23
-7
dependencies.gradle
dependencies.gradle
+2
-2
No files found.
app/src/main/java/chat/rocket/android/chatroom/adapter/ImageAttachmentViewHolder.kt
View file @
717824a7
...
...
@@ -2,6 +2,8 @@ package chat.rocket.android.chatroom.adapter
import
android.view.View
import
chat.rocket.android.chatroom.viewmodel.ImageAttachmentViewModel
import
com.facebook.drawee.backends.pipeline.Fresco
import
com.facebook.drawee.interfaces.DraweeController
import
com.stfalcon.frescoimageviewer.ImageViewer
import
kotlinx.android.synthetic.main.message_attachment.view.*
...
...
@@ -17,12 +19,21 @@ class ImageAttachmentViewHolder(itemView: View, listener: ActionsListener)
override
fun
bindViews
(
data
:
ImageAttachmentViewModel
)
{
with
(
itemView
)
{
image_attachment
.
setImageURI
(
data
.
attachmentUrl
)
val
controller
=
Fresco
.
newDraweeControllerBuilder
().
apply
{
setUri
(
data
.
attachmentUrl
)
autoPlayAnimations
=
true
oldController
=
image_attachment
.
controller
}.
build
()
image_attachment
.
controller
=
controller
file_name
.
text
=
data
.
attachmentTitle
image_attachment
.
setOnClickListener
{
view
->
// TODO - implement a proper image viewer with a proper Transition
val
builder
=
ImageViewer
.
createPipelineDraweeControllerBuilder
()
.
setAutoPlayAnimations
(
true
)
ImageViewer
.
Builder
(
view
.
context
,
listOf
(
data
.
attachmentUrl
))
.
setStartPosition
(
0
)
.
hideStatusBar
(
false
)
.
setCustomDraweeControllerBuilder
(
builder
)
.
show
()
}
}
...
...
app/src/main/java/chat/rocket/android/chatroom/viewmodel/ViewModelMapper.kt
View file @
717824a7
...
...
@@ -94,16 +94,20 @@ class ViewModelMapper @Inject constructor(private val context: Context,
}
private
fun
mapFileAttachment
(
message
:
Message
,
attachment
:
FileAttachment
):
BaseViewModel
<
*
>?
{
val
attachmentUrl
=
attachmentUrl
(
"$baseUrl${attachment.url}"
)
val
attachmentTitle
=
attachment
.
title
val
id
=
"${message.id}_${attachment.titleLink}"
.
hashCode
().
toLong
()
val
attachmentUrl
=
if
(
attachment
.
url
.
startsWith
(
"http"
))
{
attachment
.
url
}
else
{
attachmentUrl
(
"$baseUrl${attachment.url}"
)
}
val
attachmentTitle
=
attachment
.
attachmentTitle
val
id
=
"${message.id}_${attachment.url}"
.
hashCode
().
toLong
()
return
when
(
attachment
)
{
is
ImageAttachment
->
ImageAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
?:
""
,
id
)
attachmentUrl
,
attachmentTitle
,
id
)
is
VideoAttachment
->
VideoAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
?:
""
,
id
)
attachmentUrl
,
attachmentTitle
,
id
)
is
AudioAttachment
->
AudioAttachmentViewModel
(
message
,
attachment
,
message
.
id
,
attachmentUrl
,
attachmentTitle
?:
""
,
id
)
attachmentUrl
,
attachmentTitle
,
id
)
else
->
null
}
}
...
...
@@ -281,4 +285,16 @@ class ViewModelMapper @Inject constructor(private val context: Context,
})
}
}
}
\ No newline at end of file
}
internal
val
FileAttachment
.
attachmentTitle
:
String
get
()
{
title
?.
let
{
return
it
}
val
fileUrl
=
HttpUrl
.
parse
(
url
)
fileUrl
?.
let
{
return
it
.
pathSegments
().
last
()
}
return
""
}
\ No newline at end of file
dependencies.gradle
View file @
717824a7
...
...
@@ -25,7 +25,7 @@ ext {
rxBinding
:
'2.0.0'
,
fresco
:
'1.8.1'
,
kotshi
:
'0.3.0'
,
frescoImageViewer
:
'0.5.
0
'
,
frescoImageViewer
:
'0.5.
1
'
,
androidSvg
:
'master-SNAPSHOT'
,
markwon
:
'1.0.3'
,
sheetMenu
:
'1.3.3'
,
...
...
@@ -84,7 +84,7 @@ ext {
kotshiApi
:
"se.ansman.kotshi:api:${versions.kotshi}"
,
kotshiCompiler
:
"se.ansman.kotshi:compiler:${versions.kotshi}"
,
frescoImageViewer
:
"com.github.
stfalcon:frescoimagev
iewer:${versions.frescoImageViewer}"
,
frescoImageViewer
:
"com.github.
luciofm:FrescoImageV
iewer:${versions.frescoImageViewer}"
,
androidSvg
:
"com.github.BigBadaboom:androidsvg:${versions.androidSvg}"
,
markwon
:
"ru.noties:markwon:${versions.markwon}"
,
...
...
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