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
77610e63
Unverified
Commit
77610e63
authored
Dec 15, 2017
by
Filipe de Lima Brito
Committed by
GitHub
Dec 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #642 from filipedelimabrito/feature/support-viewing-image
[Feature] Support viewing image
parents
7313b7bc
3e1cd538
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
14 deletions
+67
-14
build.gradle
app/build.gradle
+4
-2
Message.kt
...src/main/java/chat/rocket/android/app/chatroom/Message.kt
+4
-1
MessageFragment.kt
.../java/chat/rocket/android/app/chatroom/MessageFragment.kt
+18
-5
MessageListAdapter.kt
...va/chat/rocket/android/app/chatroom/MessageListAdapter.kt
+26
-3
item_message.xml
app/src/main/res/layout/item_message.xml
+9
-0
dependencies.gradle
dependencies.gradle
+6
-3
No files found.
app/build.gradle
View file @
77610e63
...
...
@@ -63,13 +63,15 @@ dependencies {
implementation
libraries
.
okhttp
implementation
libraries
.
okhttpLogger
implementation
libraries
.
timber
implementation
libraries
.
threeTenABP
implementation
libraries
.
fresco
implementation
libraries
.
frescoAnimatedGif
implementation
libraries
.
frescoWebP
implementation
libraries
.
frescoAnimatedWebP
implementation
libraries
.
timber
implementation
libraries
.
threeTenABP
implementation
libraries
.
frescoImageViewer
implementation
libraries
.
floatingSearchView
...
...
app/src/main/java/chat/rocket/android/app/chatroom/Message.kt
View file @
77610e63
...
...
@@ -3,4 +3,7 @@ package chat.rocket.android.app.chatroom
import
chat.rocket.android.app.User
import
org.threeten.bp.LocalDateTime
data class
Message
(
val
user
:
User
,
val
content
:
String
,
val
localDatetime
:
LocalDateTime
)
\ No newline at end of file
data class
Message
(
val
user
:
User
,
val
textContent
:
String
?,
val
imageAttachmentUri
:
String
?,
val
localDatetime
:
LocalDateTime
)
\ No newline at end of file
app/src/main/java/chat/rocket/android/app/chatroom/MessageFragment.kt
View file @
77610e63
...
...
@@ -22,11 +22,24 @@ class MessageFragment : Fragment() {
// This is just a sample showing 2 messages in the chat room. We need to get it rid in a real word. REMARK: remove this comment and this method.
private
fun
createDumpData
():
List
<
Message
>
{
val
user1
=
User
(
"1"
,
"Filipe Brito"
,
"filipe.brito"
,
"online"
,
"https://open.rocket.chat/avatar/filipe.brito"
)
val
user2
=
User
(
"2"
,
"Lucio Maciel"
,
"Lucio Maciel"
,
"busy"
,
"https://open.rocket.chat/avatar/lucio.maciel"
)
val
user1
=
User
(
"1"
,
"Filipe Brito"
,
"filipe.brito"
,
"online"
,
"https://open.rocket.chat/avatar/filipe.brito"
)
val
user2
=
User
(
"2"
,
"Lucio Maciel"
,
"Lucio Maciel"
,
"busy"
,
"https://open.rocket.chat/avatar/lucio.maciel"
)
val
message1
=
Message
(
user1
,
"This is a multiline chat message from Bertie that will take more than just one line of text. I have sure that everything is amazing!"
,
LocalDateTime
.
now
())
val
message2
=
Message
(
user2
,
"Great!"
,
LocalDateTime
.
now
().
plusHours
(
1
))
val
message1
=
Message
(
user1
,
"This is a multiline chat message from Bertie that will take more than just one line of text. I have sure that everything is amazing!"
,
"https://rocket.chat/images/index/livechat.png"
,
LocalDateTime
.
now
())
val
message2
=
Message
(
user2
,
"Great!"
,
"https://rocket.chat/images/index/screenshot.png"
,
LocalDateTime
.
now
().
plusHours
(
1
))
return
listOf
(
message1
,
message2
)
}
...
...
@@ -34,7 +47,7 @@ class MessageFragment : Fragment() {
private
fun
showMessageList
(
dataSet
:
List
<
Message
>)
{
activity
?.
apply
{
recycler_view
.
layoutManager
=
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
)
recycler_view
.
adapter
=
MessageListAdapter
(
dataSet
.
toMutableList
())
recycler_view
.
adapter
=
MessageListAdapter
(
this
,
dataSet
.
toMutableList
())
{}
}
}
}
\ No newline at end of file
app/src/main/java/chat/rocket/android/app/chatroom/MessageListAdapter.kt
View file @
77610e63
package
chat.rocket.android.app.chatroom
import
DateTimeHelper
import
android.content.Context
import
android.support.v7.widget.RecyclerView
import
android.view.LayoutInflater
import
android.view.View
...
...
@@ -8,9 +9,10 @@ import android.view.ViewGroup
import
android.widget.TextView
import
chat.rocket.android.R
import
com.facebook.drawee.view.SimpleDraweeView
import
com.stfalcon.frescoimageviewer.ImageViewer
import
kotlinx.android.synthetic.main.item_message.view.*
class
MessageListAdapter
(
private
va
r
dataSet
:
MutableList
<
Message
>
)
:
RecyclerView
.
Adapter
<
MessageListAdapter
.
ViewHolder
>()
{
class
MessageListAdapter
(
private
va
l
context
:
Context
,
private
var
dataSet
:
MutableList
<
Message
>,
private
val
listener
:
(
Message
)
->
Unit
)
:
RecyclerView
.
Adapter
<
MessageListAdapter
.
ViewHolder
>()
{
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
val
view
=
LayoutInflater
.
from
(
parent
.
context
).
inflate
(
R
.
layout
.
item_message
,
parent
,
false
)
...
...
@@ -23,7 +25,25 @@ class MessageListAdapter(private var dataSet: MutableList<Message>) : RecyclerVi
holder
.
userAvatar
.
setImageURI
(
message
.
user
.
avatarUri
)
holder
.
userName
.
text
=
message
.
user
.
name
holder
.
time
.
text
=
DateTimeHelper
.
getTime
(
message
.
localDatetime
)
holder
.
content
.
text
=
message
.
content
val
textContent
=
message
.
textContent
if
(
textContent
.
isNullOrBlank
())
{
holder
.
textContent
.
visibility
=
View
.
GONE
}
else
{
holder
.
textContent
.
text
=
textContent
}
val
imageAttachmentUri
=
message
.
imageAttachmentUri
if
(
imageAttachmentUri
.
isNullOrBlank
())
{
holder
.
imageAttachment
.
visibility
=
View
.
GONE
}
else
{
holder
.
imageAttachment
.
setImageURI
(
imageAttachmentUri
)
holder
.
imageAttachment
.
setOnClickListener
({
ImageViewer
.
Builder
(
context
,
listOf
(
imageAttachmentUri
))
.
hideStatusBar
(
false
)
.
show
()
})
}
}
override
fun
getItemCount
():
Int
=
dataSet
.
size
...
...
@@ -32,6 +52,9 @@ class MessageListAdapter(private var dataSet: MutableList<Message>) : RecyclerVi
val
userAvatar
:
SimpleDraweeView
=
itemView
.
image_user_avatar
val
userName
:
TextView
=
itemView
.
text_user_name
val
time
:
TextView
=
itemView
.
text_message_time
val
content
:
TextView
=
itemView
.
text_content
val
textContent
:
TextView
=
itemView
.
text_content
val
imageAttachment
:
SimpleDraweeView
=
itemView
.
image_attachment
}
}
\ No newline at end of file
app/src/main/res/layout/item_message.xml
View file @
77610e63
...
...
@@ -54,4 +54,13 @@
app:layout_constraintTop_toBottomOf=
"@+id/top_container"
tools:text=
"This is a multiline chat message from Bertie that will take more than just one line of text. I have sure that everything is amazing!"
/>
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/image_attachment"
android:layout_width=
"0dp"
android:layout_height=
"150dp"
android:layout_marginTop=
"5dp"
app:layout_constraintLeft_toLeftOf=
"@id/top_container"
app:layout_constraintRight_toRightOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/text_content"
/>
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
dependencies.gradle
View file @
77610e63
...
...
@@ -20,9 +20,10 @@ ext {
rxandroid
:
'2.0.1'
,
moshi
:
'1.6.0-SNAPSHOT'
,
okhttp
:
'3.9.0'
,
fresco
:
'1.5.0'
,
timber
:
'4.5.1'
,
threeTenABP
:
'1.0.5'
,
fresco
:
'1.5.0'
,
frescoImageViewer
:
'0.5.0'
,
floatingSearchView:
'2.1.1'
,
androidSvg
:
'1.2.1'
,
...
...
@@ -63,13 +64,15 @@ ext {
okhttp
:
"com.squareup.okhttp3:okhttp:${versions.okhttp}"
,
okhttpLogger
:
"com.squareup.okhttp3:logging-interceptor:${versions.okhttp}"
,
timber
:
"com.jakewharton.timber:timber:${versions.timber}"
,
threeTenABP
:
"com.jakewharton.threetenabp:threetenabp:${versions.threeTenABP}"
,
fresco
:
"com.facebook.fresco:fresco:${versions.fresco}"
,
frescoAnimatedGif
:
"com.facebook.fresco:animated-gif:${versions.fresco}"
,
frescoWebP
:
"com.facebook.fresco:webpsupport:${versions.fresco}"
,
frescoAnimatedWebP
:
"com.facebook.fresco:animated-webp:${versions.fresco}"
,
timber
:
"com.jakewharton.timber:timber:${versions.timber}"
,
threeTenABP
:
"com.jakewharton.threetenabp:threetenabp:${versions.threeTenABP}"
,
frescoImageViewer
:
"com.github.stfalcon:frescoimageviewer:${versions.frescoImageViewer}"
,
floatingSearchView
:
"com.github.arimorty:floatingsearchview:${versions.floatingSearchView}"
,
...
...
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