Reorganise sample into debug/release flavours
Summary: This makes use of the new no-op package and also structures the app into release and debug flavours that can be built with and without Flipper part of the APK. This was a pretty tedious adventure. I may have missed some corner cases and also restructured a bunch of seemingly unrelated stuff that was necessary to respect buck module boundaries. Reviewed By: jknoxville Differential Revision: D15148004 fbshipit-source-id: bf81f45105f5f16d17daccb3e8050ee00d69fc35
This commit is contained in:
committed by
Facebook Github Bot
parent
b1c674f6f9
commit
2e65ab7133
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.flipper.android.diagnostics;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
|
||||||
|
public class FlipperDiagnosticActivity extends Activity {}
|
||||||
@@ -64,5 +64,6 @@ dependencies {
|
|||||||
testImplementation deps.hamcrest
|
testImplementation deps.hamcrest
|
||||||
testImplementation deps.junit
|
testImplementation deps.junit
|
||||||
|
|
||||||
implementation project(':android')
|
debugImplementation project(':android')
|
||||||
|
releaseImplementation project(':noop')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package com.facebook.flipper.connectivitytest;
|
package com.facebook.flipper.connectivitytest;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -6,9 +13,6 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
import com.facebook.flipper.android.AndroidFlipperClient;
|
||||||
import com.facebook.flipper.core.FlipperClient;
|
import com.facebook.flipper.core.FlipperClient;
|
||||||
import com.facebook.flipper.plugins.example.ExampleFlipperPlugin;
|
import com.facebook.flipper.plugins.example.ExampleFlipperPlugin;
|
||||||
import com.facebook.flipper.sample.RootComponent;
|
|
||||||
import com.facebook.litho.ComponentContext;
|
|
||||||
import com.facebook.litho.LithoView;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Oh hai! This is probably not the kinda sample you want to copy to your application; we're just
|
* Oh hai! This is probably not the kinda sample you want to copy to your application; we're just
|
||||||
@@ -20,9 +24,6 @@ public class ConnectionTestActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
final ComponentContext c = new ComponentContext(this);
|
|
||||||
setContentView(LithoView.create(c, RootComponent.create(c).build()));
|
|
||||||
|
|
||||||
final FlipperClient client = AndroidFlipperClient.getInstanceIfInitialized();
|
final FlipperClient client = AndroidFlipperClient.getInstanceIfInitialized();
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
// As we're re-using the identifier, get rid of the default plugin first.
|
// As we're re-using the identifier, get rid of the default plugin first.
|
||||||
@@ -16,6 +16,7 @@ import com.facebook.flipper.core.FlipperPlugin;
|
|||||||
import com.facebook.flipper.core.FlipperReceiver;
|
import com.facebook.flipper.core.FlipperReceiver;
|
||||||
import com.facebook.flipper.core.FlipperResponder;
|
import com.facebook.flipper.core.FlipperResponder;
|
||||||
import com.facebook.flipper.sample.ExampleActions;
|
import com.facebook.flipper.sample.ExampleActions;
|
||||||
|
import com.facebook.flipper.sample.network.NetworkClient;
|
||||||
|
|
||||||
public class ConnectionTestPlugin implements FlipperPlugin {
|
public class ConnectionTestPlugin implements FlipperPlugin {
|
||||||
|
|
||||||
@@ -63,8 +64,9 @@ public class ConnectionTestPlugin implements FlipperPlugin {
|
|||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ExampleActions.sendGetRequest();
|
final NetworkClient networkClient = NetworkClient.getInstance();
|
||||||
ExampleActions.sendPostRequest();
|
ExampleActions.sendGetRequest(networkClient.getOkHttpClient());
|
||||||
|
ExampleActions.sendPostRequest(networkClient.getOkHttpClient());
|
||||||
// We want Flipper to properly disconnect at this point and actually shut down the app.
|
// We want Flipper to properly disconnect at this point and actually shut down the app.
|
||||||
mActivity.finish();
|
mActivity.finish();
|
||||||
android.os.Process.sendSignal(android.os.Process.myPid(), 15);
|
android.os.Process.sendSignal(android.os.Process.myPid(), 15);
|
||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
package com.facebook.flipper.sample;
|
package com.facebook.flipper.sample;
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -8,13 +15,14 @@ import java.io.IOException;
|
|||||||
import okhttp3.Call;
|
import okhttp3.Call;
|
||||||
import okhttp3.Callback;
|
import okhttp3.Callback;
|
||||||
import okhttp3.FormBody;
|
import okhttp3.FormBody;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
public final class ExampleActions {
|
public final class ExampleActions {
|
||||||
|
|
||||||
public static void sendPostRequest() {
|
public static void sendPostRequest(OkHttpClient client) {
|
||||||
final RequestBody formBody =
|
final RequestBody formBody =
|
||||||
new FormBody.Builder().add("app", "Flipper").add("remarks", "Its awesome").build();
|
new FormBody.Builder().add("app", "Flipper").add("remarks", "Its awesome").build();
|
||||||
|
|
||||||
@@ -24,7 +32,7 @@ public final class ExampleActions {
|
|||||||
.post(formBody)
|
.post(formBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
FlipperSampleApplication.sOkHttpClient
|
client
|
||||||
.newCall(request)
|
.newCall(request)
|
||||||
.enqueue(
|
.enqueue(
|
||||||
new Callback() {
|
new Callback() {
|
||||||
@@ -45,9 +53,10 @@ public final class ExampleActions {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sendGetRequest() {
|
public static void sendGetRequest(OkHttpClient client) {
|
||||||
final Request request = new Request.Builder().url("https://api.github.com/repos/facebook/yoga").get().build();
|
final Request request =
|
||||||
FlipperSampleApplication.sOkHttpClient
|
new Request.Builder().url("https://api.github.com/repos/facebook/yoga").get().build();
|
||||||
|
client
|
||||||
.newCall(request)
|
.newCall(request)
|
||||||
.enqueue(
|
.enqueue(
|
||||||
new Callback() {
|
new Callback() {
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.flipper.sample;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import com.facebook.flipper.core.FlipperClient;
|
||||||
|
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
|
||||||
|
import com.facebook.flipper.plugins.example.ExampleFlipperPlugin;
|
||||||
|
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.plugins.leakcanary.LeakCanaryFlipperPlugin;
|
||||||
|
import com.facebook.flipper.plugins.litho.LithoFlipperDescriptors;
|
||||||
|
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
||||||
|
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
||||||
|
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
|
||||||
|
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin.SharedPreferencesDescriptor;
|
||||||
|
import com.facebook.litho.config.ComponentsConfiguration;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
public final class FlipperInitializer {
|
||||||
|
public interface IntializationResult {
|
||||||
|
OkHttpClient getOkHttpClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntializationResult initFlipperPlugins(Context context, FlipperClient client) {
|
||||||
|
final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
|
||||||
|
|
||||||
|
final NetworkFlipperPlugin networkPlugin = new NetworkFlipperPlugin();
|
||||||
|
final FlipperOkhttpInterceptor interceptor = new FlipperOkhttpInterceptor(networkPlugin);
|
||||||
|
|
||||||
|
// Normally, you would want to make this dependent on a BuildConfig flag, but
|
||||||
|
// for this demo application we can safely assume that you always want to debug.
|
||||||
|
ComponentsConfiguration.isDebugModeEnabled = true;
|
||||||
|
LithoFlipperDescriptors.add(descriptorMapping);
|
||||||
|
client.addPlugin(new InspectorFlipperPlugin(context, descriptorMapping));
|
||||||
|
client.addPlugin(networkPlugin);
|
||||||
|
client.addPlugin(
|
||||||
|
new SharedPreferencesFlipperPlugin(
|
||||||
|
context,
|
||||||
|
Arrays.asList(
|
||||||
|
new SharedPreferencesDescriptor("sample", Context.MODE_PRIVATE),
|
||||||
|
new SharedPreferencesDescriptor("other_sample", Context.MODE_PRIVATE))));
|
||||||
|
client.addPlugin(new LeakCanaryFlipperPlugin());
|
||||||
|
client.addPlugin(new FrescoFlipperPlugin());
|
||||||
|
client.addPlugin(new ExampleFlipperPlugin());
|
||||||
|
client.addPlugin(CrashReporterPlugin.getInstance());
|
||||||
|
client.start();
|
||||||
|
|
||||||
|
final OkHttpClient okHttpClient =
|
||||||
|
new OkHttpClient.Builder()
|
||||||
|
.addNetworkInterceptor(interceptor)
|
||||||
|
.connectTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(10, TimeUnit.MINUTES)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return new IntializationResult() {
|
||||||
|
@Override
|
||||||
|
public OkHttpClient getOkHttpClient() {
|
||||||
|
return okHttpClient;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
*
|
*
|
||||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||||
@@ -8,31 +8,13 @@ package com.facebook.flipper.sample;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
import com.facebook.flipper.android.AndroidFlipperClient;
|
||||||
import com.facebook.flipper.core.FlipperClient;
|
import com.facebook.flipper.core.FlipperClient;
|
||||||
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
|
import com.facebook.flipper.sample.network.NetworkClient;
|
||||||
import com.facebook.flipper.plugins.example.ExampleFlipperPlugin;
|
|
||||||
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.plugins.leakcanary.LeakCanaryFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.litho.LithoFlipperDescriptors;
|
|
||||||
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
|
|
||||||
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin.SharedPreferencesDescriptor;
|
|
||||||
import com.facebook.litho.config.ComponentsConfiguration;
|
|
||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
|
|
||||||
public class FlipperSampleApplication extends Application {
|
public class FlipperSampleApplication extends Application {
|
||||||
|
|
||||||
@Nullable public static OkHttpClient sOkHttpClient = null;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
@@ -40,36 +22,11 @@ public class FlipperSampleApplication extends Application {
|
|||||||
Fresco.initialize(this);
|
Fresco.initialize(this);
|
||||||
|
|
||||||
final FlipperClient client = AndroidFlipperClient.getInstance(this);
|
final FlipperClient client = AndroidFlipperClient.getInstance(this);
|
||||||
final DescriptorMapping descriptorMapping = DescriptorMapping.withDefaults();
|
|
||||||
|
|
||||||
final NetworkFlipperPlugin networkPlugin = new NetworkFlipperPlugin();
|
final FlipperInitializer.IntializationResult initializationResult =
|
||||||
final FlipperOkhttpInterceptor interceptor = new FlipperOkhttpInterceptor(networkPlugin);
|
FlipperInitializer.initFlipperPlugins(this, client);
|
||||||
|
|
||||||
sOkHttpClient =
|
NetworkClient.getInstance().setOkHttpClient(initializationResult.getOkHttpClient());
|
||||||
new OkHttpClient.Builder()
|
|
||||||
.addNetworkInterceptor(interceptor)
|
|
||||||
.connectTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.readTimeout(60, TimeUnit.SECONDS)
|
|
||||||
.writeTimeout(10, TimeUnit.MINUTES)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Normally, you would want to make this dependent on a BuildConfig flag, but
|
|
||||||
// for this demo application we can safely assume that you always want to debug.
|
|
||||||
ComponentsConfiguration.isDebugModeEnabled = true;
|
|
||||||
LithoFlipperDescriptors.add(descriptorMapping);
|
|
||||||
client.addPlugin(new InspectorFlipperPlugin(this, descriptorMapping));
|
|
||||||
client.addPlugin(networkPlugin);
|
|
||||||
client.addPlugin(
|
|
||||||
new SharedPreferencesFlipperPlugin(
|
|
||||||
this,
|
|
||||||
Arrays.asList(
|
|
||||||
new SharedPreferencesDescriptor("sample", Context.MODE_PRIVATE),
|
|
||||||
new SharedPreferencesDescriptor("other_sample", Context.MODE_PRIVATE))));
|
|
||||||
client.addPlugin(new LeakCanaryFlipperPlugin());
|
|
||||||
client.addPlugin(new FrescoFlipperPlugin());
|
|
||||||
client.addPlugin(new ExampleFlipperPlugin());
|
|
||||||
client.addPlugin(CrashReporterPlugin.getInstance());
|
|
||||||
client.start();
|
|
||||||
|
|
||||||
getSharedPreferences("sample", Context.MODE_PRIVATE).edit().putString("Hello", "world").apply();
|
getSharedPreferences("sample", Context.MODE_PRIVATE).edit().putString("Hello", "world").apply();
|
||||||
getSharedPreferences("other_sample", Context.MODE_PRIVATE)
|
getSharedPreferences("other_sample", Context.MODE_PRIVATE)
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import android.content.Intent;
|
|||||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||||
import com.facebook.drawee.interfaces.DraweeController;
|
import com.facebook.drawee.interfaces.DraweeController;
|
||||||
import com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity;
|
import com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity;
|
||||||
|
import com.facebook.flipper.sample.network.NetworkClient;
|
||||||
import com.facebook.litho.ClickEvent;
|
import com.facebook.litho.ClickEvent;
|
||||||
import com.facebook.litho.Column;
|
import com.facebook.litho.Column;
|
||||||
import com.facebook.litho.Component;
|
import com.facebook.litho.Component;
|
||||||
@@ -23,6 +24,7 @@ import com.facebook.litho.annotations.OnUpdateState;
|
|||||||
import com.facebook.litho.annotations.State;
|
import com.facebook.litho.annotations.State;
|
||||||
import com.facebook.litho.fresco.FrescoImage;
|
import com.facebook.litho.fresco.FrescoImage;
|
||||||
import com.facebook.litho.widget.Text;
|
import com.facebook.litho.widget.Text;
|
||||||
|
|
||||||
@LayoutSpec
|
@LayoutSpec
|
||||||
public class RootComponentSpec {
|
public class RootComponentSpec {
|
||||||
|
|
||||||
@@ -67,12 +69,12 @@ public class RootComponentSpec {
|
|||||||
|
|
||||||
@OnEvent(ClickEvent.class)
|
@OnEvent(ClickEvent.class)
|
||||||
static void hitGetRequest(final ComponentContext c) {
|
static void hitGetRequest(final ComponentContext c) {
|
||||||
ExampleActions.sendGetRequest();
|
ExampleActions.sendGetRequest(NetworkClient.getInstance().getOkHttpClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(ClickEvent.class)
|
@OnEvent(ClickEvent.class)
|
||||||
static void hitPostRequest(final ComponentContext c) {
|
static void hitPostRequest(final ComponentContext c) {
|
||||||
ExampleActions.sendPostRequest();
|
ExampleActions.sendPostRequest(NetworkClient.getInstance().getOkHttpClient());
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnEvent(ClickEvent.class)
|
@OnEvent(ClickEvent.class)
|
||||||
@@ -82,7 +84,7 @@ public class RootComponentSpec {
|
|||||||
|
|
||||||
@OnEvent(ClickEvent.class)
|
@OnEvent(ClickEvent.class)
|
||||||
static void openDiagnostics(final ComponentContext c) {
|
static void openDiagnostics(final ComponentContext c) {
|
||||||
Intent intent = new Intent(c.getAndroidContext(), FlipperDiagnosticActivity.class);
|
final Intent intent = new Intent(c.getAndroidContext(), FlipperDiagnosticActivity.class);
|
||||||
c.getAndroidContext().startActivity(intent);
|
c.getAndroidContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.flipper.sample.network;
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
public class NetworkClient {
|
||||||
|
private OkHttpClient mOkHttpClient;
|
||||||
|
|
||||||
|
private NetworkClient() {}
|
||||||
|
|
||||||
|
private static class Singleton {
|
||||||
|
private static final NetworkClient INSTANCE = new NetworkClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NetworkClient getInstance() {
|
||||||
|
return Singleton.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OkHttpClient getOkHttpClient() {
|
||||||
|
return mOkHttpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOkHttpClient(OkHttpClient okHttpClient) {
|
||||||
|
mOkHttpClient = okHttpClient;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.flipper.plugins.example;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import com.facebook.flipper.core.FlipperPlugin;
|
||||||
|
|
||||||
|
// No-Op implementation to satisfy the interface.
|
||||||
|
public class ExampleFlipperPlugin implements FlipperPlugin {
|
||||||
|
public void setActivity(Activity a) {
|
||||||
|
// no-op
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.flipper.sample;
|
||||||
|
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
public final class ExampleActions {
|
||||||
|
|
||||||
|
public static void sendPostRequest(OkHttpClient client) {}
|
||||||
|
|
||||||
|
public static void sendGetRequest(OkHttpClient client) {}
|
||||||
|
|
||||||
|
public static void sendNotification() {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the LICENSE
|
||||||
|
* file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.facebook.flipper.sample;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import com.facebook.flipper.core.FlipperClient;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
|
public final class FlipperInitializer {
|
||||||
|
public interface IntializationResult {
|
||||||
|
OkHttpClient getOkHttpClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntializationResult initFlipperPlugins(Context context, FlipperClient client) {
|
||||||
|
final OkHttpClient okHttpClient =
|
||||||
|
new OkHttpClient.Builder()
|
||||||
|
.connectTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(60, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(10, TimeUnit.MINUTES)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
return new IntializationResult() {
|
||||||
|
@Override
|
||||||
|
public OkHttpClient getOkHttpClient() {
|
||||||
|
return okHttpClient;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user