Add getPluginByClass interface
Summary: This deprecates the `getPlugin(String)` method and introduces a `getPluginByClass(Class<T>)` instead which avoids having to `instanceof`-check and then cast the result, which provides a nicer experience for Java users. Reviewed By: jknoxville Differential Revision: D13277568 fbshipit-source-id: fb7b5b8c0180470ef0ad322559b5b7424520848b
This commit is contained in:
committed by
Facebook Github Bot
parent
606d689cae
commit
214f112c14
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004-present, Facebook, Inc.
|
||||
* Copyright (c) Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the LICENSE
|
||||
* file in the root directory of this source tree.
|
||||
@@ -11,7 +11,6 @@ import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
||||
import com.facebook.flipper.core.FlipperClient;
|
||||
import com.facebook.flipper.core.FlipperPlugin;
|
||||
import com.facebook.flipper.plugins.example.ExampleFlipperPlugin;
|
||||
import com.facebook.litho.ComponentContext;
|
||||
import com.facebook.litho.LithoView;
|
||||
@@ -26,10 +25,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
final FlipperClient client = AndroidFlipperClient.getInstanceIfInitialized();
|
||||
if (client != null) {
|
||||
final FlipperPlugin samplePlugin = client.getPlugin(ExampleFlipperPlugin.ID);
|
||||
if (samplePlugin instanceof ExampleFlipperPlugin) {
|
||||
((ExampleFlipperPlugin) samplePlugin).setActivity(this);
|
||||
}
|
||||
final ExampleFlipperPlugin samplePlugin = client.getPluginByClass(ExampleFlipperPlugin.class);
|
||||
samplePlugin.setActivity(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user