VitoView: Add config to simplify fetch logic
@@ -29,11 +29,16 @@ import com.facebook.infer.annotation.Nullsafe;
public class VitoViewImpl2 {
private static Supplier<Boolean> sUseVisibilityCallbacks = Suppliers.BOOLEAN_TRUE;
+ private static Supplier<Boolean> sUseSimpleFetchLogic = Suppliers.BOOLEAN_FALSE;
public static void setUseVisibilityCallbacks(Supplier<Boolean> useVisibilityCallbacks) {
sUseVisibilityCallbacks = useVisibilityCallbacks;
}
+ public static void setUseSimpleFetchLogic(Supplier<Boolean> useSimpleFetchLogic) {
+ sUseSimpleFetchLogic = useSimpleFetchLogic;
+ }
+
private static final View.OnAttachStateChangeListener mOnAttachStateChangeListenerCallback =
new View.OnAttachStateChangeListener() {
@Override
@@ -73,7 +78,9 @@ public class VitoViewImpl2 {
frescoDrawable.setImageRequest(imageRequest);
frescoDrawable.setCallerContext(callerContext);
frescoDrawable.setImageListener(imageListener);
-
+ if (sUseSimpleFetchLogic.get()) {
+ maybeFetchImage(frescoDrawable);
+ } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// If the view is already attached to the window, immediately fetch the image.
// Otherwise, the fetch will be submitted later when then View is attached.
@@ -85,6 +92,7 @@ public class VitoViewImpl2 {
// Normally we expect the view to be already attached, thus we always fetch the image.
maybeFetchImage(frescoDrawable);
}
+ }
// `addOnAttachStateChangeListener` is not idempotent
target.removeOnAttachStateChangeListener(mOnAttachStateChangeListenerCallback);
