Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate flipper samples to use Fresco Vito #4861

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions android/sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ dependencies {
implementation deps.soloader
implementation deps.okhttp3
implementation deps.fresco
implementation deps.frescoUiCommon
implementation deps.frescoVito
implementation deps.frescoVitoLitho
debugImplementation deps.flipperFrescoPlugin

// Integration test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.facebook.flipper.android.AndroidFlipperClient;
import com.facebook.flipper.core.FlipperClient;
import com.facebook.flipper.sample.network.NetworkClient;
import com.facebook.fresco.vito.init.FrescoVito;
import com.facebook.soloader.SoLoader;

public class FlipperSampleApplication extends Application {
Expand All @@ -22,6 +23,7 @@ public void onCreate() {
super.onCreate();
SoLoader.init(this, false);
Fresco.initialize(this);
FrescoVito.initialize();

final FlipperClient client = AndroidFlipperClient.getInstance(this);
assert client != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
package com.facebook.flipper.sample;

import android.content.Intent;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import android.net.Uri;
import com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity;
import com.facebook.flipper.sample.network.NetworkClient;
import com.facebook.fresco.vito.litho.FrescoVitoImage2;
import com.facebook.litho.ClickEvent;
import com.facebook.litho.Column;
import com.facebook.litho.Component;
Expand All @@ -22,7 +22,6 @@
import com.facebook.litho.annotations.OnEvent;
import com.facebook.litho.annotations.OnUpdateState;
import com.facebook.litho.annotations.State;
import com.facebook.litho.fresco.FrescoImage;
import com.facebook.litho.widget.Text;
import com.facebook.litho.widget.VerticalScroll;
import com.facebook.yoga.YogaEdge;
Expand All @@ -32,9 +31,6 @@ public class RootComponentSpec {

@OnCreateLayout
static Component onCreateLayout(final ComponentContext c, @State boolean displayImage) {
final DraweeController controller =
Fresco.newDraweeControllerBuilder().setUri("https://fbflipper.com/img/icon.png").build();

Column col =
Column.create(c)
.child(
Expand Down Expand Up @@ -129,8 +125,8 @@ static Component onCreateLayout(final ComponentContext c, @State boolean display
.textSizeSp(20)
.clickHandler(RootComponent.triggerCrash(c)))
.child(
FrescoImage.create(c)
.controller(controller)
FrescoVitoImage2.create(c)
.uri(Uri.parse("https://fbflipper.com/img/icon.png"))
.marginDip(YogaEdge.ALL, 10)
.widthDip(150)
.heightDip(150))
Expand Down
4 changes: 4 additions & 0 deletions android/tutorial/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ dependencies {
implementation deps.lithoSectionsDebug
implementation deps.lithoSectionsWidget
implementation deps.fresco
implementation deps.frescoUiCommon
implementation deps.frescoVito
implementation deps.frescoVitoCore
implementation deps.frescoVitoLitho
kapt deps.lithoProcessor
kapt deps.lithoSectionsProcessor
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin
import com.facebook.flipper.plugins.inspector.DescriptorMapping
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin
import com.facebook.flipper.sample.tutorial.plugin.SeaMammalFlipperPlugin
import com.facebook.fresco.vito.init.FrescoVito
import com.facebook.litho.config.ComponentsConfiguration
import com.facebook.litho.editor.flipper.LithoFlipperDescriptors
import com.facebook.soloader.SoLoader
Expand All @@ -24,6 +25,7 @@ class TutorialApplication : Application() {

SoLoader.init(this, false)
Fresco.initialize(this)
FrescoVito.initialize()

// Normally, you would want to make these dependent on BuildConfig.DEBUG.
ComponentsConfiguration.isDebugModeEnabled = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
package com.facebook.flipper.sample.tutorial.ui

import android.net.Uri
import com.facebook.drawee.backends.pipeline.Fresco
import com.facebook.fresco.vito.litho.FrescoVitoImage2
import com.facebook.litho.Component
import com.facebook.litho.ComponentContext
import com.facebook.litho.annotations.LayoutSpec
import com.facebook.litho.annotations.OnCreateLayout
import com.facebook.litho.annotations.Prop
import com.facebook.litho.annotations.PropDefault
import com.facebook.litho.fresco.FrescoImage

@LayoutSpec
object SingleImageComponentSpec {
Expand All @@ -27,8 +26,5 @@ object SingleImageComponentSpec {
c: ComponentContext,
@Prop image: Uri,
@Prop(optional = true) imageAspectRatio: Float
): Component =
Fresco.newDraweeControllerBuilder().setUri(image).build().let {
FrescoImage.create(c).controller(it).imageAspectRatio(imageAspectRatio).build()
}
): Component = FrescoVitoImage2.create(c).uri(image).imageAspectRatio(imageAspectRatio).build()
}
10 changes: 7 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ ext.deps = [
testCore : 'androidx.test:core:1.4.0',
testRules : 'androidx.test:rules:1.5.0',
// Plugin dependencies
flipperFrescoPlugin: 'com.facebook.flipper:flipper-fresco-plugin:0.182.0',
flipperFrescoPlugin: 'com.facebook.fresco:flipper-fresco-plugin:3.0.0',
frescoFlipper : 'com.facebook.fresco:flipper:3.0.0',
frescoStetho : 'com.facebook.fresco:stetho:2.6.0',
fresco : 'com.facebook.fresco:fresco:2.6.0',
frescoStetho : 'com.facebook.fresco:stetho:3.0.0',
fresco : 'com.facebook.fresco:fresco:3.0.0',
frescoUiCommon : 'com.facebook.fresco:ui-common:3.0.0',
frescoVito : 'com.facebook.fresco:vito:3.0.0',
frescoVitoCore : 'com.facebook.fresco:vito-core:3.0.0',
frescoVitoLitho : 'com.facebook.fresco:vito-litho:3.0.0',
]