Unverified Commit 9e846b7f authored by Leonardo Aramaki's avatar Leonardo Aramaki Committed by GitHub

Merge pull request #616 from RocketChat/fix/image-loading

[FIX] Image not loading when changing rooms
parents 13e6026e 4cca8edf
......@@ -21,6 +21,7 @@ import chat.rocket.core.models.Settings;
import chat.rocket.core.models.User;
import chat.rocket.core.repositories.RoomRepository;
import chat.rocket.core.repositories.UserRepository;
import io.reactivex.Flowable;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
......@@ -66,7 +67,6 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
getRoomHistoryStateInfo();
getMessages();
getUserPreferences();
getAbsoluteUrl();
}
@Override
......@@ -134,7 +134,7 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
@Override
public void replyMessage(@NonNull Message message, boolean justQuote) {
this.absoluteUrlHelper.getRocketChatAbsoluteUrl()
final Disposable subscription = this.absoluteUrlHelper.getRocketChatAbsoluteUrl()
.cache()
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
......@@ -333,14 +333,21 @@ public class RoomPresenter extends BasePresenter<RoomContract.View>
}
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)
.map(Optional::get)
.flatMap(messageInteractor::getAllFrom)
.subscribeOn(AndroidSchedulers.from(BackgroundLooper.get()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
messages -> view.showMessages(messages),
view::showMessages,
Logger::report
);
......
......@@ -12,7 +12,8 @@ ext {
constraintLayout : "com.android.support.constraint:constraint-layout:${constraintLayoutVersion}",
cardView : "com.android.support:cardview-v7:${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 = [
okHTTP : "com.squareup.okhttp3:okhttp:${okHttpVersion}",
......
......@@ -39,6 +39,7 @@ dependencies {
compile supportDependencies.designSupportLibrary
compile supportDependencies.constraintLayout
compile supportDependencies.supportV13
compile supportDependencies.customTabs
compile rxbindingDependencies.rxBinding
compile rxbindingDependencies.rxBindingSupport
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$rootProject.ext.kotlinVersion"
......
......@@ -10,7 +10,6 @@ import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.drawee.drawable.ProgressBarDrawable
import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.drawee.generic.GenericDraweeHierarchy
import com.facebook.drawee.generic.RoundingParams
import com.facebook.drawee.view.SimpleDraweeView
object FrescoHelper {
......@@ -39,7 +38,6 @@ object FrescoHelper {
val hierarchy: GenericDraweeHierarchy = draweeView.hierarchy
hierarchy.setPlaceholderImage(VectorDrawableCompat.create(draweeView.resources, R.drawable.image_dummy, 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.setProgressBarImage(ProgressBarDrawable())
......
......@@ -100,15 +100,15 @@
android:id="@+id/image_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="start"
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
android:id="@+id/image"
android:layout_width="200dp"
android:layout_height="200dp"/>
android:layout_height="200dp" />
<TextView
android:id="@+id/image_load"
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<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_icon_composer">#FFA8A8A8</color>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment