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
9e846b7f
Unverified
Commit
9e846b7f
authored
Dec 04, 2017
by
Leonardo Aramaki
Committed by
GitHub
Dec 04, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #616 from RocketChat/fix/image-loading
[FIX] Image not loading when changing rooms
parents
13e6026e
4cca8edf
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
240 additions
and
218 deletions
+240
-218
RoomPresenter.java
.../chat/rocket/android/fragment/chatroom/RoomPresenter.java
+11
-4
dependencies.gradle
dependencies.gradle
+2
-1
build.gradle
rocket-chat-android-widgets/build.gradle
+1
-0
FrescoHelper.kt
...in/java/chat/rocket/android/widget/helper/FrescoHelper.kt
+0
-2
RocketChatMessageAttachmentsLayout.java
...id/widget/message/RocketChatMessageAttachmentsLayout.java
+220
-207
message_inline_attachment.xml
...widgets/src/main/res/layout/message_inline_attachment.xml
+4
-4
colors.xml
rocket-chat-android-widgets/src/main/res/values/colors.xml
+2
-0
No files found.
app/src/main/java/chat/rocket/android/fragment/chatroom/RoomPresenter.java
View file @
9e846b7f
...
@@ -21,6 +21,7 @@ import chat.rocket.core.models.Settings;
...
@@ -21,6 +21,7 @@ import chat.rocket.core.models.Settings;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.models.User
;
import
chat.rocket.core.repositories.RoomRepository
;
import
chat.rocket.core.repositories.RoomRepository
;
import
chat.rocket.core.repositories.UserRepository
;
import
chat.rocket.core.repositories.UserRepository
;
import
io.reactivex.Flowable
;
import
io.reactivex.Single
;
import
io.reactivex.Single
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.android.schedulers.AndroidSchedulers
;
import
io.reactivex.disposables.Disposable
;
import
io.reactivex.disposables.Disposable
;
...
@@ -66,7 +67,6 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -66,7 +67,6 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
getRoomHistoryStateInfo
();
getRoomHistoryStateInfo
();
getMessages
();
getMessages
();
getUserPreferences
();
getUserPreferences
();
getAbsoluteUrl
();
}
}
@Override
@Override
...
@@ -134,7 +134,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -134,7 +134,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
@Override
@Override
public
void
replyMessage
(
@NonNull
Message
message
,
boolean
justQuote
)
{
public
void
replyMessage
(
@NonNull
Message
message
,
boolean
justQuote
)
{
this
.
absoluteUrlHelper
.
getRocketChatAbsoluteUrl
()
final
Disposable
subscription
=
this
.
absoluteUrlHelper
.
getRocketChatAbsoluteUrl
()
.
cache
()
.
cache
()
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
...
@@ -333,14 +333,21 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
...
@@ -333,14 +333,21 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
}
}
private
void
getMessages
()
{
private
void
getMessages
()
{
final
Disposable
subscription
=
roomRepository
.
getById
(
roomId
)
final
Disposable
subscription
=
Flowable
.
zip
(
roomRepository
.
getById
(
roomId
),
absoluteUrlHelper
.
getRocketChatAbsoluteUrl
().
toFlowable
().
cache
(),
Pair:
:
new
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
map
(
pair
->
{
view
.
setupWith
(
pair
.
second
.
orNull
());
return
pair
.
first
;
})
.
filter
(
Optional:
:
isPresent
)
.
filter
(
Optional:
:
isPresent
)
.
map
(
Optional:
:
get
)
.
map
(
Optional:
:
get
)
.
flatMap
(
messageInteractor:
:
getAllFrom
)
.
flatMap
(
messageInteractor:
:
getAllFrom
)
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
subscribeOn
(
AndroidSchedulers
.
from
(
BackgroundLooper
.
get
()))
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
.
subscribe
(
messages
->
view
.
showMessages
(
messages
)
,
view:
:
showMessages
,
Logger:
:
report
Logger:
:
report
);
);
...
...
dependencies.gradle
View file @
9e846b7f
...
@@ -12,7 +12,8 @@ ext {
...
@@ -12,7 +12,8 @@ ext {
constraintLayout
:
"com.android.support.constraint:constraint-layout:${constraintLayoutVersion}"
,
constraintLayout
:
"com.android.support.constraint:constraint-layout:${constraintLayoutVersion}"
,
cardView
:
"com.android.support:cardview-v7:${supportLibraryVersion}"
,
cardView
:
"com.android.support:cardview-v7:${supportLibraryVersion}"
,
supportV13
:
"com.android.support:support-v13:${supportLibraryVersion}"
,
supportV13
:
"com.android.support:support-v13:${supportLibraryVersion}"
,
multidex
:
"com.android.support:multidex:1.0.2"
multidex
:
"com.android.support:multidex:1.0.2"
,
customTabs
:
"com.android.support:customtabs:${supportLibraryVersion}"
]
]
extraDependencies
=
[
extraDependencies
=
[
okHTTP
:
"com.squareup.okhttp3:okhttp:${okHttpVersion}"
,
okHTTP
:
"com.squareup.okhttp3:okhttp:${okHttpVersion}"
,
...
...
rocket-chat-android-widgets/build.gradle
View file @
9e846b7f
...
@@ -39,6 +39,7 @@ dependencies {
...
@@ -39,6 +39,7 @@ dependencies {
compile
supportDependencies
.
designSupportLibrary
compile
supportDependencies
.
designSupportLibrary
compile
supportDependencies
.
constraintLayout
compile
supportDependencies
.
constraintLayout
compile
supportDependencies
.
supportV13
compile
supportDependencies
.
supportV13
compile
supportDependencies
.
customTabs
compile
rxbindingDependencies
.
rxBinding
compile
rxbindingDependencies
.
rxBinding
compile
rxbindingDependencies
.
rxBindingSupport
compile
rxbindingDependencies
.
rxBindingSupport
compile
"org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion"
compile
"org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion"
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/helper/FrescoHelper.kt
View file @
9e846b7f
...
@@ -10,7 +10,6 @@ import com.facebook.drawee.backends.pipeline.Fresco
...
@@ -10,7 +10,6 @@ import com.facebook.drawee.backends.pipeline.Fresco
import
com.facebook.drawee.drawable.ProgressBarDrawable
import
com.facebook.drawee.drawable.ProgressBarDrawable
import
com.facebook.drawee.drawable.ScalingUtils
import
com.facebook.drawee.drawable.ScalingUtils
import
com.facebook.drawee.generic.GenericDraweeHierarchy
import
com.facebook.drawee.generic.GenericDraweeHierarchy
import
com.facebook.drawee.generic.RoundingParams
import
com.facebook.drawee.view.SimpleDraweeView
import
com.facebook.drawee.view.SimpleDraweeView
object
FrescoHelper
{
object
FrescoHelper
{
...
@@ -39,7 +38,6 @@ object FrescoHelper {
...
@@ -39,7 +38,6 @@ object FrescoHelper {
val
hierarchy
:
GenericDraweeHierarchy
=
draweeView
.
hierarchy
val
hierarchy
:
GenericDraweeHierarchy
=
draweeView
.
hierarchy
hierarchy
.
setPlaceholderImage
(
VectorDrawableCompat
.
create
(
draweeView
.
resources
,
R
.
drawable
.
image_dummy
,
null
))
hierarchy
.
setPlaceholderImage
(
VectorDrawableCompat
.
create
(
draweeView
.
resources
,
R
.
drawable
.
image_dummy
,
null
))
hierarchy
.
setFailureImage
(
VectorDrawableCompat
.
create
(
draweeView
.
resources
,
R
.
drawable
.
image_error
,
null
))
hierarchy
.
setFailureImage
(
VectorDrawableCompat
.
create
(
draweeView
.
resources
,
R
.
drawable
.
image_error
,
null
))
hierarchy
.
roundingParams
=
RoundingParams
().
setCornersRadii
(
5F
,
5F
,
5F
,
5F
)
hierarchy
.
actualImageScaleType
=
ScalingUtils
.
ScaleType
.
FIT_CENTER
hierarchy
.
actualImageScaleType
=
ScalingUtils
.
ScaleType
.
FIT_CENTER
hierarchy
.
setProgressBarImage
(
ProgressBarDrawable
())
hierarchy
.
setProgressBarImage
(
ProgressBarDrawable
())
...
...
rocket-chat-android-widgets/src/main/java/chat/rocket/android/widget/message/RocketChatMessageAttachmentsLayout.java
View file @
9e846b7f
...
@@ -7,6 +7,7 @@ import android.graphics.Color;
...
@@ -7,6 +7,7 @@ import android.graphics.Color;
import
android.graphics.drawable.Drawable
;
import
android.graphics.drawable.Drawable
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Build
;
import
android.support.customtabs.CustomTabsIntent
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.content.ContextCompat
;
import
android.support.v4.widget.TextViewCompat
;
import
android.support.v4.widget.TextViewCompat
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -17,8 +18,12 @@ import android.view.ViewGroup;
...
@@ -17,8 +18,12 @@ import android.view.ViewGroup;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
com.facebook.cache.common.CacheKey
;
import
com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
;
import
com.facebook.drawee.generic.GenericDraweeHierarchyBuilder
;
import
com.facebook.drawee.view.SimpleDraweeView
;
import
com.facebook.drawee.view.SimpleDraweeView
;
import
com.facebook.imagepipeline.cache.DefaultCacheKeyFactory
;
import
com.facebook.imagepipeline.core.ImagePipelineFactory
;
import
com.facebook.imagepipeline.request.ImageRequest
;
import
java.util.List
;
import
java.util.List
;
...
@@ -131,7 +136,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -131,7 +136,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
FrescoHelper
.
INSTANCE
.
loadImageWithCustomization
((
SimpleDraweeView
)
attachmentView
.
findViewById
(
R
.
id
.
author_icon
),
absolutize
(
author
.
getIconUrl
()));
FrescoHelper
.
INSTANCE
.
loadImageWithCustomization
((
SimpleDraweeView
)
attachmentView
.
findViewById
(
R
.
id
.
author_icon
),
absolutize
(
author
.
getIconUrl
()));
final
TextView
authorName
=
(
TextView
)
attachmentView
.
findViewById
(
R
.
id
.
author_name
);
final
TextView
authorName
=
attachmentView
.
findViewById
(
R
.
id
.
author_name
);
authorName
.
setText
(
author
.
getName
());
authorName
.
setText
(
author
.
getName
());
final
String
link
=
absolutize
(
author
.
getLink
());
final
String
link
=
absolutize
(
author
.
getLink
());
...
@@ -148,7 +153,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -148,7 +153,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
}
}
private
void
showTitleAttachment
(
Attachment
attachment
,
View
attachmentView
)
{
private
void
showTitleAttachment
(
Attachment
attachment
,
View
attachmentView
)
{
TextView
titleView
=
(
TextView
)
attachmentView
.
findViewById
(
R
.
id
.
title
);
TextView
titleView
=
attachmentView
.
findViewById
(
R
.
id
.
title
);
AttachmentTitle
title
=
attachment
.
getAttachmentTitle
();
AttachmentTitle
title
=
attachment
.
getAttachmentTitle
();
if
(
title
==
null
||
title
.
getTitle
()
==
null
)
{
if
(
title
==
null
||
title
.
getTitle
()
==
null
)
{
titleView
.
setVisibility
(
View
.
GONE
);
titleView
.
setVisibility
(
View
.
GONE
);
...
@@ -166,13 +171,10 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -166,13 +171,10 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
titleView
.
setOnClickListener
(
new
OnClickListener
()
{
titleView
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
@Override
public
void
onClick
(
View
view
)
{
public
void
onClick
(
View
view
)
{
final
Intent
intent
=
new
Intent
(
Intent
.
ACTION_VIEW
,
Uri
.
parse
(
link
));
new
CustomTabsIntent
.
Builder
()
intent
.
setFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
.
setToolbarColor
(
ContextCompat
.
getColor
(
getContext
(),
R
.
color
.
colorPrimary
))
.
build
()
final
Context
context
=
view
.
getContext
();
.
launchUrl
(
getContext
(),
Uri
.
parse
(
link
));
if
(
intent
.
resolveActivity
(
context
.
getPackageManager
())
!=
null
)
{
context
.
startActivity
(
intent
);
}
}
}
});
});
TextViewCompat
.
setTextAppearance
(
titleView
,
TextViewCompat
.
setTextAppearance
(
titleView
,
...
@@ -189,7 +191,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -189,7 +191,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
refBox
.
setVisibility
(
VISIBLE
);
refBox
.
setVisibility
(
VISIBLE
);
final
SimpleDraweeView
thumbImage
=
(
SimpleDraweeView
)
refBox
.
findViewById
(
R
.
id
.
thumb
);
final
SimpleDraweeView
thumbImage
=
refBox
.
findViewById
(
R
.
id
.
thumb
);
final
String
thumbUrl
=
attachment
.
getThumbUrl
();
final
String
thumbUrl
=
attachment
.
getThumbUrl
();
if
(
TextUtils
.
isEmpty
(
thumbUrl
))
{
if
(
TextUtils
.
isEmpty
(
thumbUrl
))
{
...
@@ -199,7 +201,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -199,7 +201,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
FrescoHelper
.
INSTANCE
.
loadImageWithCustomization
(
thumbImage
,
absolutize
(
thumbUrl
));
FrescoHelper
.
INSTANCE
.
loadImageWithCustomization
(
thumbImage
,
absolutize
(
thumbUrl
));
}
}
final
TextView
refText
=
(
TextView
)
refBox
.
findViewById
(
R
.
id
.
text
);
final
TextView
refText
=
refBox
.
findViewById
(
R
.
id
.
text
);
final
String
refString
=
attachment
.
getText
();
final
String
refString
=
attachment
.
getText
();
if
(
TextUtils
.
isEmpty
(
refString
))
{
if
(
TextUtils
.
isEmpty
(
refString
))
{
...
@@ -242,8 +244,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -242,8 +244,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
return
;
return
;
}
}
final
ViewGroup
attachmentContent
=
final
ViewGroup
attachmentContent
=
attachmentView
.
findViewById
(
R
.
id
.
attachment_content
);
(
ViewGroup
)
attachmentView
.
findViewById
(
R
.
id
.
attachment_content
);
for
(
int
i
=
0
,
size
=
fields
.
size
();
i
<
size
;
i
++)
{
for
(
int
i
=
0
,
size
=
fields
.
size
();
i
<
size
;
i
++)
{
final
AttachmentField
attachmentField
=
fields
.
get
(
i
);
final
AttachmentField
attachmentField
=
fields
.
get
(
i
);
...
@@ -268,7 +269,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -268,7 +269,7 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
private
void
loadImage
(
final
String
url
,
final
SimpleDraweeView
drawee
,
final
View
load
,
private
void
loadImage
(
final
String
url
,
final
SimpleDraweeView
drawee
,
final
View
load
,
boolean
autoloadImage
)
{
boolean
autoloadImage
)
{
if
(
autoloadImage
)
{
if
(
autoloadImage
||
isCached
(
Uri
.
parse
(
url
))
)
{
load
.
setVisibility
(
GONE
);
load
.
setVisibility
(
GONE
);
FrescoHelper
.
INSTANCE
.
loadImageWithCustomization
(
drawee
,
url
);
FrescoHelper
.
INSTANCE
.
loadImageWithCustomization
(
drawee
,
url
);
return
;
return
;
...
@@ -283,4 +284,16 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
...
@@ -283,4 +284,16 @@ public class RocketChatMessageAttachmentsLayout extends LinearLayout {
}
}
});
});
}
}
private
boolean
isCached
(
Uri
loadUri
)
{
if
(
loadUri
==
null
)
{
return
false
;
}
ImageRequest
imageRequest
=
ImageRequest
.
fromUri
(
loadUri
);
CacheKey
cacheKey
=
DefaultCacheKeyFactory
.
getInstance
()
.
getEncodedCacheKey
(
imageRequest
,
null
);
return
ImagePipelineFactory
.
getInstance
()
.
getMainFileCache
().
hasKey
(
cacheKey
);
}
}
}
rocket-chat-android-widgets/src/main/res/layout/message_inline_attachment.xml
View file @
9e846b7f
...
@@ -100,15 +100,15 @@
...
@@ -100,15 +100,15 @@
android:id=
"@+id/image_container"
android:id=
"@+id/image_container"
android:layout_width=
"wrap_content"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_gravity=
"
center
"
android:layout_gravity=
"
start
"
android:layout_marginTop=
"8dp"
android:layout_marginTop=
"8dp"
android:
padding=
"5dp
"
android:
background=
"@drawable/inline_attachment_background
"
android:
background=
"@drawable/inline_attachment_background
"
>
android:
padding=
"5dp
"
>
<com.facebook.drawee.view.SimpleDraweeView
<com.facebook.drawee.view.SimpleDraweeView
android:id=
"@+id/image"
android:id=
"@+id/image"
android:layout_width=
"200dp"
android:layout_width=
"200dp"
android:layout_height=
"200dp"
/>
android:layout_height=
"200dp"
/>
<TextView
<TextView
android:id=
"@+id/image_load"
android:id=
"@+id/image_load"
...
...
rocket-chat-android-widgets/src/main/res/values/colors.xml
View file @
9e846b7f
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<resources>
<color
name=
"color_accent"
>
#FF2D91FA
</color>
<color
name=
"color_accent"
>
#FF2D91FA
</color>
<color
name=
"colorPrimary"
>
#044b76
</color>
<color
name=
"colorPrimaryDark"
>
#FFF
</color>
<color
name=
"color_shadow"
>
#FFE6E6E7
</color>
<color
name=
"color_shadow"
>
#FFE6E6E7
</color>
<color
name=
"color_icon_composer"
>
#FFA8A8A8
</color>
<color
name=
"color_icon_composer"
>
#FFA8A8A8
</color>
...
...
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