Skip to content

Commit

Permalink
Uses original URL for Dynamic Size if FrescoVitoImage2Spec OnPrepare …
Browse files Browse the repository at this point in the history
…is on Main Thread

Reviewed By: defHLT

Differential Revision: D63713017

fbshipit-source-id: cf3f4576ff646a873493135bf32f933ae4ffc249
  • Loading branch information
Veeren Mandalia authored and facebook-github-bot committed Oct 3, 2024
1 parent 0db9de3 commit 767bdc5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ package com.facebook.fresco.vito.core

import com.facebook.common.internal.Supplier
import com.facebook.common.internal.Suppliers
import com.facebook.fresco.vito.core.DefaultFrescoVitoConfig.DefaultPrefetchConfig

open class DefaultFrescoVitoConfig
@JvmOverloads
Expand Down Expand Up @@ -46,6 +45,8 @@ constructor(override val prefetchConfig: PrefetchConfig = DefaultPrefetchConfig(

override fun experimentalDynamicSizeWithCacheFallbackVito2(): Boolean = false

override fun experimentalDynamicSizeOnPrepareMainThreadVito2(): Boolean = false

open class DefaultPrefetchConfig : PrefetchConfig {
override fun prefetchInOnPrepare(): Boolean = true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ interface FrescoVitoConfig {
fun experimentalDynamicSizeVito2(): Boolean

fun experimentalDynamicSizeWithCacheFallbackVito2(): Boolean

fun experimentalDynamicSizeOnPrepareMainThreadVito2(): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ object FrescoVitoImage2Spec {
}
if (experimentalDynamicSizeVito2() && experimentalDynamicSizeWithCacheFallbackVito2()) {
if (Looper.myLooper() == Looper.getMainLooper()) {
// we don't want to check cache if we are running on the main thread
forceKeepOriginalSize.set(false)
// We don't want to check cache if we are running on the main thread
// By default uses the original URL
forceKeepOriginalSize.set(!experimentalDynamicSizeOnPrepareMainThreadVito2())
} else {
forceKeepOriginalSize.set(
FrescoVitoProvider.getImagePipeline().isInDiskCacheSync(requestCachedValue))
Expand Down Expand Up @@ -436,6 +437,9 @@ object FrescoVitoImage2Spec {
private fun experimentalDynamicSizeWithCacheFallbackVito2(): Boolean =
FrescoVitoProvider.getConfig().experimentalDynamicSizeWithCacheFallbackVito2()

private fun experimentalDynamicSizeOnPrepareMainThreadVito2(): Boolean =
FrescoVitoProvider.getConfig().experimentalDynamicSizeOnPrepareMainThreadVito2()

enum class Prefetch {
AUTO,
YES,
Expand Down

0 comments on commit 767bdc5

Please sign in to comment.