Java Code Examples for com.facebook.flipper.android.utils.FlipperUtils#shouldEnableFlipper()

The following examples show how to use com.facebook.flipper.android.utils.FlipperUtils#shouldEnableFlipper() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlutterFlipperkitPlugin.java    From flutter_flipperkit with MIT License 6 votes vote down vote up
private void setupChannel(BinaryMessenger messenger, Context context) {
    this.context = context;
    SoLoader.init(context.getApplicationContext(), false);
    if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(context)) {
        flipperClient = AndroidFlipperClient.getInstance(context);
        networkFlipperPlugin = new NetworkFlipperPlugin();
        sharedPreferencesFlipperPlugin = new SharedPreferencesFlipperPlugin(context, "FlutterSharedPreferences");

        flipperDatabaseBrowserPlugin = new FlipperDatabaseBrowserPlugin();
        flipperReduxInspectorPlugin = new FlipperReduxInspectorPlugin();
    }

    this.channel = new MethodChannel(messenger, CHANNEL_NAME);
    this.channel.setMethodCallHandler(this);

    this.eventChannel = new EventChannel(messenger, EVENT_CHANNEL_NAME);
    this.eventChannel.setStreamHandler(this);
}
 
Example 2
Source File: LithoSampleApplication.java    From litho with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate() {
  super.onCreate();

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

  if (FlipperUtils.shouldEnableFlipper(this)) {
    final FlipperClient client = AndroidFlipperClient.getInstance(this);
    final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
    LithoFlipperDescriptors.add(descriptorMapping);
    client.addPlugin(new InspectorFlipperPlugin(this, descriptorMapping));
    client.addPlugin(new SectionsFlipperPlugin(true));
    client.start();
  }
}
 
Example 3
Source File: FlutterFlipperkitPlugin.java    From flutter_flipperkit with MIT License 5 votes vote down vote up
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
    if (!FlipperUtils.shouldEnableFlipper(context)) {
        result.success(true);
        return;
    }

    final String method = call.method;

    if (method.startsWith("pluginDatabaseBrowser")) {
        flipperDatabaseBrowserPlugin.handleMethodCall(call, result);
        return;
    } else if (method.startsWith("pluginReduxInspector")) {
        flipperReduxInspectorPlugin.handleMethodCall(call, result);
        return;
    }

    switch (method) {
        case "clientAddPlugin":
            this.clientAddPlugin(call, result);
            break;
        case "clientStart":
            this.clientStart(call, result);
            break;
        case "clientStop":
            this.clientStop(call, result);
            break;
        case "pluginNetworkReportRequest":
            this.pluginNetworkReportRequest(call, result);
            break;
        case "pluginNetworkReportResponse":
            this.pluginNetworkReportResponse(call, result);
            break;
        default:
            result.notImplemented();
    }
}