Commit 7d8390a7 authored by Lucio Maciel's avatar Lucio Maciel Committed by GitHub

Merge pull request #523 from RocketChat/fix/crash-on-drawable-mutate

[FIX] Fix crash on Android versions 4.1.x when a bug on the mutate() method causes a NPE
parents 86fba9d0 f6be3525
...@@ -16,8 +16,8 @@ ext { ...@@ -16,8 +16,8 @@ ext {
okHTTP : "com.squareup.okhttp3:okhttp:3.8.0", okHTTP : "com.squareup.okhttp3:okhttp:3.8.0",
rxJava : "io.reactivex.rxjava2:rxjava:2.1.0", rxJava : "io.reactivex.rxjava2:rxjava:2.1.0",
boltTask : "com.parse.bolts:bolts-tasks:1.4.0", boltTask : "com.parse.bolts:bolts-tasks:1.4.0",
textDrawable : "com.amulyakhare:com.amulyakhare.textdrawable:1.0.1", rxAndroid : "io.reactivex.rxjava2:rxandroid:2.0.1",
rxAndroid : "io.reactivex.rxjava2:rxandroid:2.0.1" textDrawable : "com.github.rocketchat:textdrawable:1.0.2"
] ]
rxbindingDependencies = [ rxbindingDependencies = [
rxBinding : "com.jakewharton.rxbinding2:rxbinding:${rxbindingVersion}", rxBinding : "com.jakewharton.rxbinding2:rxbinding:${rxbindingVersion}",
......
...@@ -44,13 +44,13 @@ ext { ...@@ -44,13 +44,13 @@ ext {
} }
dependencies { dependencies {
compile project(':rocket-chat-core') compile project(':rocket-chat-core')
compile extraDependencies.okHTTP; compile extraDependencies.okHTTP
compile extraDependencies.textDrawable
compile supportDependencies.annotation compile supportDependencies.annotation
compile supportDependencies.cardView compile supportDependencies.cardView
compile supportDependencies.designSupportLibrary compile supportDependencies.designSupportLibrary
compile supportDependencies.constrainLayout compile supportDependencies.constrainLayout
compile supportDependencies.kotlin compile supportDependencies.kotlin
compile extraDependencies.textDrawable
compile rxbindingDependencies.rxBinding compile rxbindingDependencies.rxBinding
compile rxbindingDependencies.rxBindingSupport compile rxbindingDependencies.rxBindingSupport
compile "com.android.support:support-v13:$rootProject.ext.supportLibraryVersion" compile "com.android.support:support-v13:$rootProject.ext.supportLibraryVersion"
......
...@@ -16,11 +16,13 @@ import android.view.View; ...@@ -16,11 +16,13 @@ import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import chat.rocket.android.widget.helper.DrawableHelper;
import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.TextDrawable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import chat.rocket.android.widget.helper.DrawableHelper;
public class RoomToolbar extends Toolbar { public class RoomToolbar extends Toolbar {
private TextView toolbarText; private TextView toolbarText;
private ImageView roomTypeImage; private ImageView roomTypeImage;
......
...@@ -6,7 +6,6 @@ import android.graphics.Typeface ...@@ -6,7 +6,6 @@ import android.graphics.Typeface
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import chat.rocket.android.widget.AbsoluteUrl import chat.rocket.android.widget.AbsoluteUrl
import com.amulyakhare.textdrawable.TextDrawable import com.amulyakhare.textdrawable.TextDrawable
import java.net.URLEncoder import java.net.URLEncoder
/** /**
......
package chat.rocket.android.widget.helper package chat.rocket.android.widget.helper
import android.graphics.Rect
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import android.graphics.drawable.ShapeDrawable
import android.net.Uri import android.net.Uri
import android.support.graphics.drawable.VectorDrawableCompat import android.support.graphics.drawable.VectorDrawableCompat
import chat.rocket.android.widget.R import chat.rocket.android.widget.R
...@@ -14,6 +16,10 @@ import com.facebook.drawee.view.SimpleDraweeView ...@@ -14,6 +16,10 @@ import com.facebook.drawee.view.SimpleDraweeView
object FrescoHelper { object FrescoHelper {
fun loadImage(simpleDraweeView: SimpleDraweeView, imageUri: String, placeholderDrawable: Drawable) { fun loadImage(simpleDraweeView: SimpleDraweeView, imageUri: String, placeholderDrawable: Drawable) {
// ref: https://github.com/facebook/fresco/issues/501
if (placeholderDrawable is ShapeDrawable) {
placeholderDrawable.setPadding(Rect())
}
simpleDraweeView.hierarchy.setPlaceholderImage(placeholderDrawable) simpleDraweeView.hierarchy.setPlaceholderImage(placeholderDrawable)
simpleDraweeView.controller = Fresco.newDraweeControllerBuilder().setUri(imageUri).setAutoPlayAnimations(true).build() simpleDraweeView.controller = Fresco.newDraweeControllerBuilder().setUri(imageUri).setAutoPlayAnimations(true).build()
} }
......
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