Skip to content

Commit 36f0d8c

Browse files
oprisnikfacebook-github-bot
authored andcommitted
Added KFrescoController support for DrawableResImageSource
Reviewed By: kartavya-ramnani Differential Revision: D73671067 fbshipit-source-id: 929ef97a48208debf7b50f6677eda33159ac4b55
1 parent aa108fb commit 36f0d8c

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

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

+30-16
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import com.facebook.fresco.vito.renderer.DrawableImageDataModel
3838
import com.facebook.fresco.vito.renderer.ImageDataModel
3939
import com.facebook.fresco.vito.source.BitmapImageSource
4040
import com.facebook.fresco.vito.source.DrawableImageSource
41+
import com.facebook.fresco.vito.source.DrawableResImageSource
4142
import com.facebook.imagepipeline.image.CloseableBitmap
4243
import com.facebook.imagepipeline.image.CloseableImage
4344
import com.facebook.imagepipeline.image.CloseableStaticBitmap
@@ -161,22 +162,12 @@ class KFrescoController(
161162
}
162163
// Direct Drawable available
163164
is DrawableImageSource -> {
164-
val extras = drawable.obtainExtras(null, null)
165-
drawable.actualImageLayer.setActualImageDrawable(
166-
imageRequest.imageOptions, source.drawable)
167-
drawable.listenerManager.onFinalImageSet(
168-
imageId,
169-
imageRequest,
170-
ImageOrigin.LOCAL,
171-
ImageInfoImpl(
172-
source.drawable.intrinsicWidth,
173-
source.drawable.intrinsicHeight,
174-
0,
175-
ImmutableQualityInfo.FULL_QUALITY,
176-
extras.imageExtras ?: emptyMap()),
177-
extras,
178-
drawable.actualImageDrawable)
179-
debugOverlayHandler?.update(drawable)
165+
setDrawableAsActualImage(drawable, source.drawable, imageRequest, imageId)
166+
return true
167+
}
168+
is DrawableResImageSource -> {
169+
setDrawableAsActualImage(
170+
drawable, imageRequest.resources.getDrawable(source.resId), imageRequest, imageId)
180171
return true
181172
}
182173
}
@@ -223,6 +214,29 @@ class KFrescoController(
223214
}
224215
}
225216

217+
private fun setDrawableAsActualImage(
218+
drawable: KFrescoVitoDrawable,
219+
actualImageDrawable: Drawable,
220+
imageRequest: VitoImageRequest,
221+
imageId: Long
222+
) {
223+
val extras = drawable.obtainExtras(null, null)
224+
drawable.actualImageLayer.setActualImageDrawable(imageRequest.imageOptions, actualImageDrawable)
225+
drawable.listenerManager.onFinalImageSet(
226+
imageId,
227+
imageRequest,
228+
ImageOrigin.LOCAL,
229+
ImageInfoImpl(
230+
actualImageDrawable.intrinsicWidth,
231+
actualImageDrawable.intrinsicHeight,
232+
0,
233+
ImmutableQualityInfo.FULL_QUALITY,
234+
extras.imageExtras ?: emptyMap()),
235+
extras,
236+
drawable.actualImageDrawable)
237+
debugOverlayHandler?.update(drawable)
238+
}
239+
226240
override fun releaseDelayed(drawable: FrescoDrawableInterface) {
227241
traceSection("KFrescoController#releaseDelayed") {
228242
if (drawable !is KFrescoVitoDrawable) {

0 commit comments

Comments
 (0)