Skip to content

Commit d7db121

Browse files
Iliyas Zhanatulyfacebook-github-bot
Iliyas Zhanatuly
authored andcommitted
Fixing a crash in HierarcherImpl.kt when drawable resource is not found
Reviewed By: oprisnik Differential Revision: D73655148 fbshipit-source-id: 37bfb472891b9394054407a1b4a9de3bb387b358
1 parent 2495088 commit d7db121

File tree

1 file changed

+10
-2
lines changed
  • vito/core-java-impl/src/main/java/com/facebook/fresco/vito/core/impl

1 file changed

+10
-2
lines changed

vito/core-java-impl/src/main/java/com/facebook/fresco/vito/core/impl/HierarcherImpl.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ package com.facebook.fresco.vito.core.impl
1010
import android.content.res.Resources
1111
import android.graphics.drawable.ColorDrawable
1212
import android.graphics.drawable.Drawable
13+
import com.facebook.common.logging.FLog
1314
import com.facebook.common.references.CloseableReference
1415
import com.facebook.drawee.drawable.ForwardingDrawable
1516
import com.facebook.drawee.drawable.ScaleTypeDrawable
@@ -22,6 +23,8 @@ import com.facebook.imagepipeline.systrace.FrescoSystrace
2223

2324
open class HierarcherImpl(private val drawableFactory: ImageOptionsDrawableFactory) : Hierarcher {
2425

26+
private val TAG = "HierarcherImpl"
27+
2528
override fun buildActualImageDrawable(
2629
resources: Resources,
2730
imageOptions: ImageOptions,
@@ -41,8 +44,13 @@ open class HierarcherImpl(private val drawableFactory: ImageOptionsDrawableFacto
4144
return try {
4245
var placeholderDrawable = imageOptions.placeholderDrawable
4346
if (placeholderDrawable == null && imageOptions.placeholderRes != 0) {
44-
placeholderDrawable = resources.getDrawable(imageOptions.placeholderRes)
45-
} else if (placeholderDrawable == null) {
47+
try {
48+
placeholderDrawable = resources.getDrawable(imageOptions.placeholderRes)
49+
} catch (e: Resources.NotFoundException) {
50+
FLog.e(TAG, "Placeholder drawable not found in Resources", e)
51+
}
52+
}
53+
if (placeholderDrawable == null) {
4654
placeholderDrawable = imageOptions.placeholderColor?.let(::ColorDrawable)
4755
}
4856

0 commit comments

Comments
 (0)