Commit 8d103553 authored by Yacumima's avatar Yacumima

improve

parent a84df93a
...@@ -37,11 +37,10 @@ dependencies { ...@@ -37,11 +37,10 @@ dependencies {
implementation 'com.alibaba:fastjson:1.2.41' implementation 'com.alibaba:fastjson:1.2.41'
implementation 'com.android.support:support-v4:26.1.0' implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support:appcompat-v7:26.1.0'
provided rootProject.findProject(":xservice_kit")
} }
ext { ext {
groupId = 'com.taobao.fleamarket' groupId = 'com.taobao.fleamarket'
artifactId = "FlutterBoostPlugin" artifactId = "FlutterBoost"
} }
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taobao.idlefish.flutterboost"> package="com.taobao.idlefish.flutterboost">
<application <application android:allowBackup="false">
android:allowBackup="false">
<activity
android:name="com.taobao.idlefish.flutterboost.BoostFlutterActivity"
android:launchMode="standard"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"/>
</application> </application>
</manifest> </manifest>
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.idlefish.flutterboost.interfaces.IStateListener;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import io.flutter.plugin.common.EventChannel;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
public class BoostChannel { public class BoostChannel {
private static BoostChannel sInstance;
private final MethodChannel mMethodChannel; private final MethodChannel mMethodChannel;
private final Set<MethodChannel.MethodCallHandler> mMethodCallHandlers = new HashSet<>(); private final Set<MethodChannel.MethodCallHandler> mMethodCallHandlers = new HashSet<>();
private final Map<String,Set<EventListener>> mEventListeners = new HashMap<>(); private final Map<String,Set<EventListener>> mEventListeners = new HashMap<>();
BoostChannel(MethodChannel methodChannel){ private static final Set<ActionAfterRegistered> sActions = new HashSet<>();
mMethodChannel = methodChannel;
public static BoostChannel singleton() {
if (sInstance == null) {
throw new RuntimeException("BoostChannel not register yet");
}
return sInstance;
}
public static void addActionAfterRegistered(ActionAfterRegistered action) {
if(action == null) return;
if(sInstance == null) {
sActions.add(action);
}else{
action.onChannelRegistered(sInstance);
}
}
public static void registerWith(PluginRegistry.Registrar registrar) {
sInstance = new BoostChannel(registrar);
for(ActionAfterRegistered a : sActions) {
a.onChannelRegistered(sInstance);
}
final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
if(stateListener != null) {
stateListener.onChannelRegistered(registrar,sInstance);
}
sActions.clear();
}
private BoostChannel(PluginRegistry.Registrar registrar){
mMethodChannel = new MethodChannel(registrar.messenger(), "flutter_boost");
mMethodChannel.setMethodCallHandler(new MethodChannel.MethodCallHandler() { mMethodChannel.setMethodCallHandler(new MethodChannel.MethodCallHandler() {
@Override @Override
...@@ -143,4 +182,8 @@ public class BoostChannel { ...@@ -143,4 +182,8 @@ public class BoostChannel {
public interface EventListener { public interface EventListener {
void onEvent(String name, Map args); void onEvent(String name, Map args);
} }
public interface ActionAfterRegistered {
void onChannelRegistered(BoostChannel channel);
}
} }
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.content.Context; import android.content.Context;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterEngineProvider; import com.idlefish.flutterboost.interfaces.IFlutterEngineProvider;
import com.taobao.idlefish.flutterboost.interfaces.IStateListener; import com.idlefish.flutterboost.interfaces.IStateListener;
import io.flutter.embedding.engine.FlutterShellArgs; import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.view.FlutterMain; import io.flutter.view.FlutterMain;
...@@ -50,7 +50,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider { ...@@ -50,7 +50,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
mEngine = new BoostFlutterEngine(context.getApplicationContext()); mEngine = new BoostFlutterEngine(context.getApplicationContext());
final IStateListener stateListener = FlutterBoostPlugin.sInstance.mStateListener; final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
if(stateListener != null) { if(stateListener != null) {
stateListener.onEngineCreated(mEngine); stateListener.onEngineCreated(mEngine);
} }
...@@ -64,7 +64,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider { ...@@ -64,7 +64,7 @@ public class BoostEngineProvider implements IFlutterEngineProvider {
} }
public static void assertEngineRunning(){ public static void assertEngineRunning(){
final BoostFlutterEngine engine = FlutterBoostPlugin.singleton().engineProvider().tryGetEngine(); final BoostFlutterEngine engine = FlutterBoost.singleton().engineProvider().tryGetEngine();
if(engine == null || !engine.isRunning()) { if(engine == null || !engine.isRunning()) {
throw new RuntimeException("engine is not running yet!"); throw new RuntimeException("engine is not running yet!");
} }
......
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord; import com.idlefish.flutterboost.interfaces.IContainerRecord;
import com.taobao.idlefish.flutterboost.interfaces.IStateListener; import com.idlefish.flutterboost.interfaces.IStateListener;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
...@@ -47,12 +47,12 @@ public class BoostFlutterEngine extends FlutterEngine { ...@@ -47,12 +47,12 @@ public class BoostFlutterEngine extends FlutterEngine {
"main"); "main");
getDartExecutor().executeDartEntrypoint(entryPoint); getDartExecutor().executeDartEntrypoint(entryPoint);
final IStateListener stateListener = FlutterBoostPlugin.sInstance.mStateListener; final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
if(stateListener != null) { if(stateListener != null) {
stateListener.onEngineStarted(this); stateListener.onEngineStarted(this);
} }
FlutterBoostPlugin.singleton().platform().registerPlugins(mBoostPluginRegistry); FlutterBoost.singleton().platform().registerPlugins(mBoostPluginRegistry);
} }
} }
...@@ -92,13 +92,13 @@ public class BoostFlutterEngine extends FlutterEngine { ...@@ -92,13 +92,13 @@ public class BoostFlutterEngine extends FlutterEngine {
Activity activity; Activity activity;
IContainerRecord record; IContainerRecord record;
record = FlutterBoostPlugin.singleton().containerManager().getCurrentTopRecord(); record = FlutterBoost.singleton().containerManager().getCurrentTopRecord();
if(record == null) { if(record == null) {
record = FlutterBoostPlugin.singleton().containerManager().getLastGenerateRecord(); record = FlutterBoost.singleton().containerManager().getLastGenerateRecord();
} }
if(record == null){ if(record == null){
activity = FlutterBoostPlugin.singleton().currentActivity(); activity = FlutterBoost.singleton().currentActivity();
}else{ }else{
activity = record.getContainer().getContextActivity(); activity = record.getContainer().getContextActivity();
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
...@@ -29,7 +29,6 @@ import android.content.Intent; ...@@ -29,7 +29,6 @@ import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.os.Bundle; import android.os.Bundle;
import android.os.SystemClock;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
...@@ -40,7 +39,7 @@ import android.widget.LinearLayout; ...@@ -40,7 +39,7 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.taobao.idlefish.flutterboost.interfaces.IStateListener; import com.idlefish.flutterboost.interfaces.IStateListener;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
...@@ -134,7 +133,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -134,7 +133,7 @@ public class BoostFlutterView extends FrameLayout {
mFlutterEngine.startRun((Activity)getContext()); mFlutterEngine.startRun((Activity)getContext());
final IStateListener stateListener = FlutterBoostPlugin.sInstance.mStateListener; final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
if(stateListener != null) { if(stateListener != null) {
stateListener.onFlutterViewInited(mFlutterEngine,this); stateListener.onFlutterViewInited(mFlutterEngine,this);
} }
...@@ -168,7 +167,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -168,7 +167,7 @@ public class BoostFlutterView extends FrameLayout {
} }
protected BoostFlutterEngine createFlutterEngine(Context context) { protected BoostFlutterEngine createFlutterEngine(Context context) {
return FlutterBoostPlugin.singleton().engineProvider().createEngine(context); return FlutterBoost.singleton().engineProvider().createEngine(context);
} }
public void addFirstFrameRendered(OnFirstFrameRenderedListener listener) { public void addFirstFrameRendered(OnFirstFrameRenderedListener listener) {
...@@ -224,7 +223,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -224,7 +223,7 @@ public class BoostFlutterView extends FrameLayout {
public void onAttach() { public void onAttach() {
Debuger.log("BoostFlutterView onAttach"); Debuger.log("BoostFlutterView onAttach");
final IStateListener stateListener = FlutterBoostPlugin.sInstance.mStateListener; final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
if(stateListener != null) { if(stateListener != null) {
stateListener.beforeEngineAttach(mFlutterEngine,this); stateListener.beforeEngineAttach(mFlutterEngine,this);
} }
...@@ -255,7 +254,7 @@ public class BoostFlutterView extends FrameLayout { ...@@ -255,7 +254,7 @@ public class BoostFlutterView extends FrameLayout {
} }
} }
final IStateListener stateListener = FlutterBoostPlugin.sInstance.mStateListener; final IStateListener stateListener = FlutterBoost.sInstance.mStateListener;
if(stateListener != null) { if(stateListener != null) {
stateListener.beforeEngineDetach(mFlutterEngine,this); stateListener.beforeEngineDetach(mFlutterEngine,this);
} }
...@@ -269,8 +268,6 @@ public class BoostFlutterView extends FrameLayout { ...@@ -269,8 +268,6 @@ public class BoostFlutterView extends FrameLayout {
Debuger.log("BoostFlutterView onDestroy"); Debuger.log("BoostFlutterView onDestroy");
mFlutterView.removeOnFirstFrameRenderedListener(mOnFirstFrameRenderedListener); mFlutterView.removeOnFirstFrameRenderedListener(mOnFirstFrameRenderedListener);
mPlatformPlugin = null;
mFlutterEngine = null;
} }
@Override @Override
......
...@@ -21,12 +21,12 @@ ...@@ -21,12 +21,12 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.content.Intent; import android.content.Intent;
import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord; import com.idlefish.flutterboost.interfaces.IContainerRecord;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer; import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -143,7 +143,7 @@ public class ContainerRecord implements IContainerRecord { ...@@ -143,7 +143,7 @@ public class ContainerRecord implements IContainerRecord {
map.put("name", mContainer.getContainerUrl()); map.put("name", mContainer.getContainerUrl());
map.put("uniqueId", mUniqueId); map.put("uniqueId", mUniqueId);
FlutterBoostPlugin.singleton().channel().sendEvent("lifecycle", map); FlutterBoost.singleton().channel().sendEvent("lifecycle", map);
mContainer.getBoostFlutterView().onBackPressed(); mContainer.getBoostFlutterView().onBackPressed();
} }
...@@ -241,7 +241,7 @@ public class ContainerRecord implements IContainerRecord { ...@@ -241,7 +241,7 @@ public class ContainerRecord implements IContainerRecord {
args.put("pageName", url); args.put("pageName", url);
args.put("params", params); args.put("params", params);
args.put("uniqueId", uniqueId); args.put("uniqueId", uniqueId);
FlutterBoostPlugin.singleton().channel().invokeMethod(method, args); FlutterBoost.singleton().channel().invokeMethod(method, args);
} }
public void invokeChannelUnsafe(String method, String url, Map params, String uniqueId) { public void invokeChannelUnsafe(String method, String url, Map params, String uniqueId) {
...@@ -249,7 +249,7 @@ public class ContainerRecord implements IContainerRecord { ...@@ -249,7 +249,7 @@ public class ContainerRecord implements IContainerRecord {
args.put("pageName", url); args.put("pageName", url);
args.put("params", params); args.put("params", params);
args.put("uniqueId", uniqueId); args.put("uniqueId", uniqueId);
FlutterBoostPlugin.singleton().channel().invokeMethodUnsafe(method, args); FlutterBoost.singleton().channel().invokeMethodUnsafe(method, args);
} }
} }
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.util.Log; import android.util.Log;
...@@ -60,7 +60,7 @@ public class Debuger { ...@@ -60,7 +60,7 @@ public class Debuger {
public static boolean isDebug(){ public static boolean isDebug(){
try { try {
return FlutterBoostPlugin.singleton().platform().isDebug(); return FlutterBoost.singleton().platform().isDebug();
}catch (Throwable t){ }catch (Throwable t){
return false; return false;
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.app.Application;
...@@ -29,28 +29,26 @@ import android.content.Intent; ...@@ -29,28 +29,26 @@ import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.taobao.idlefish.flutterboost.interfaces.IContainerManager; import com.idlefish.flutterboost.interfaces.IContainerManager;
import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord; import com.idlefish.flutterboost.interfaces.IContainerRecord;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterEngineProvider; import com.idlefish.flutterboost.interfaces.IFlutterEngineProvider;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer; import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import com.taobao.idlefish.flutterboost.interfaces.IPlatform; import com.idlefish.flutterboost.interfaces.IPlatform;
import com.taobao.idlefish.flutterboost.interfaces.IStateListener; import com.idlefish.flutterboost.interfaces.IStateListener;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.flutter.plugin.common.MethodCall; import io.flutter.plugin.common.MethodCall;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
import io.flutter.plugin.common.PluginRegistry;
public class FlutterBoost {
public class FlutterBoostPlugin { static FlutterBoost sInstance = null;
static FlutterBoostPlugin sInstance = null;
public static synchronized void init(IPlatform platform) { public static synchronized void init(IPlatform platform) {
if (sInstance == null) { if (sInstance == null) {
sInstance = new FlutterBoostPlugin(platform); sInstance = new FlutterBoost(platform);
} }
if (platform.whenEngineStart() == IPlatform.IMMEDIATELY) { if (platform.whenEngineStart() == IPlatform.IMMEDIATELY) {
...@@ -60,32 +58,33 @@ public class FlutterBoostPlugin { ...@@ -60,32 +58,33 @@ public class FlutterBoostPlugin {
} }
} }
public static FlutterBoostPlugin singleton() { public static FlutterBoost singleton() {
if (sInstance == null) { if (sInstance == null) {
Debuger.exception("FlutterBoostPlugin not init yet"); throw new RuntimeException("FlutterBoost not init yet");
} }
return sInstance; return sInstance;
} }
public static void registerWith(PluginRegistry.Registrar registrar) {
final MethodChannel method = new MethodChannel(registrar.messenger(), "flutter_boost");
singleton().registerChannel(method);
}
private final IPlatform mPlatform; private final IPlatform mPlatform;
private final IContainerManager mManager; private final IContainerManager mManager;
private final IFlutterEngineProvider mEngineProvider; private final IFlutterEngineProvider mEngineProvider;
IStateListener mStateListener; IStateListener mStateListener;
Activity mCurrentActiveActivity; Activity mCurrentActiveActivity;
BoostChannel mBoostChannel;
private FlutterBoostPlugin(IPlatform platform) { private FlutterBoost(IPlatform platform) {
mPlatform = platform; mPlatform = platform;
mManager = new FlutterViewContainerManager(); mManager = new FlutterViewContainerManager();
mEngineProvider = new BoostEngineProvider(); mEngineProvider = new BoostEngineProvider();
platform.getApplication().registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks()); platform.getApplication().registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks());
BoostChannel.addActionAfterRegistered(new BoostChannel.ActionAfterRegistered() {
@Override
public void onChannelRegistered(BoostChannel channel) {
channel.addMethodCallHandler(new BoostMethodHandler());
}
});
} }
public IFlutterEngineProvider engineProvider() { public IFlutterEngineProvider engineProvider() {
...@@ -101,10 +100,7 @@ public class FlutterBoostPlugin { ...@@ -101,10 +100,7 @@ public class FlutterBoostPlugin {
} }
public BoostChannel channel() { public BoostChannel channel() {
if(mBoostChannel == null) { return BoostChannel.singleton();
Debuger.exception("channel not register yet!");
}
return mBoostChannel;
} }
public Activity currentActivity() { public Activity currentActivity() {
...@@ -119,12 +115,6 @@ public class FlutterBoostPlugin { ...@@ -119,12 +115,6 @@ public class FlutterBoostPlugin {
mStateListener = listener; mStateListener = listener;
} }
private void registerChannel(MethodChannel method) {
mBoostChannel = new BoostChannel(method);
mBoostChannel.addMethodCallHandler(new BoostMethodHandler());
}
class ActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks { class ActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
@Override @Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) { public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
...@@ -143,7 +133,7 @@ public class FlutterBoostPlugin { ...@@ -143,7 +133,7 @@ public class FlutterBoostPlugin {
if (mEngineProvider.tryGetEngine() != null) { if (mEngineProvider.tryGetEngine() != null) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("type", "foreground"); map.put("type", "foreground");
mBoostChannel.sendEvent("lifecycle",map); channel().sendEvent("lifecycle",map);
} }
} }
mCurrentActiveActivity = activity; mCurrentActiveActivity = activity;
...@@ -167,7 +157,7 @@ public class FlutterBoostPlugin { ...@@ -167,7 +157,7 @@ public class FlutterBoostPlugin {
if (mEngineProvider.tryGetEngine() != null) { if (mEngineProvider.tryGetEngine() != null) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("type", "background"); map.put("type", "background");
mBoostChannel.sendEvent("lifecycle",map); channel().sendEvent("lifecycle",map);
} }
mCurrentActiveActivity = null; mCurrentActiveActivity = null;
} }
...@@ -186,7 +176,7 @@ public class FlutterBoostPlugin { ...@@ -186,7 +176,7 @@ public class FlutterBoostPlugin {
if (mEngineProvider.tryGetEngine() != null) { if (mEngineProvider.tryGetEngine() != null) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
map.put("type", "background"); map.put("type", "background");
mBoostChannel.sendEvent("lifecycle",map); channel().sendEvent("lifecycle",map);
} }
mCurrentActiveActivity = null; mCurrentActiveActivity = null;
} }
......
...@@ -21,21 +21,20 @@ ...@@ -21,21 +21,20 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.content.Context; import android.content.Context;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.SparseArray; import android.util.SparseArray;
import com.taobao.idlefish.flutterboost.interfaces.IContainerManager; import com.idlefish.flutterboost.interfaces.IContainerManager;
import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord; import com.idlefish.flutterboost.interfaces.IContainerRecord;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer; import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer; import com.idlefish.flutterboost.interfaces.IOperateSyncer;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
...@@ -103,9 +102,9 @@ public class FlutterViewContainerManager implements IContainerManager { ...@@ -103,9 +102,9 @@ public class FlutterViewContainerManager implements IContainerManager {
@Override @Override
public void openContainer(String url, Map<String, Object> urlParams, Map<String, Object> exts,OnResult onResult) { public void openContainer(String url, Map<String, Object> urlParams, Map<String, Object> exts,OnResult onResult) {
Context context = FlutterBoostPlugin.singleton().currentActivity(); Context context = FlutterBoost.singleton().currentActivity();
if(context == null) { if(context == null) {
context = FlutterBoostPlugin.singleton().platform().getApplication(); context = FlutterBoost.singleton().platform().getApplication();
} }
int requestCode = mRequestCode.addAndGet(3); int requestCode = mRequestCode.addAndGet(3);
...@@ -113,7 +112,7 @@ public class FlutterViewContainerManager implements IContainerManager { ...@@ -113,7 +112,7 @@ public class FlutterViewContainerManager implements IContainerManager {
mOnResults.put(requestCode,onResult); mOnResults.put(requestCode,onResult);
} }
FlutterBoostPlugin.singleton().platform().openContainer(context,url,urlParams,requestCode,exts); FlutterBoost.singleton().platform().openContainer(context,url,urlParams,requestCode,exts);
} }
@Override @Override
...@@ -130,7 +129,7 @@ public class FlutterViewContainerManager implements IContainerManager { ...@@ -130,7 +129,7 @@ public class FlutterViewContainerManager implements IContainerManager {
Debuger.exception("closeContainer can not find uniqueId:" + uniqueId); Debuger.exception("closeContainer can not find uniqueId:" + uniqueId);
} }
FlutterBoostPlugin.singleton().platform().closeContainer(targetRecord,result,exts); FlutterBoost.singleton().platform().closeContainer(targetRecord,result,exts);
return targetRecord; return targetRecord;
} }
......
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import com.taobao.idlefish.flutterboost.interfaces.IContainerRecord; import com.idlefish.flutterboost.interfaces.IContainerRecord;
import com.taobao.idlefish.flutterboost.interfaces.IPlatform; import com.idlefish.flutterboost.interfaces.IPlatform;
import java.util.Map; import java.util.Map;
......
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import com.taobao.idlefish.flutterboost.interfaces.IStateListener; import com.idlefish.flutterboost.interfaces.IStateListener;
import io.flutter.plugin.common.PluginRegistry;
public class StateListener implements IStateListener { public class StateListener implements IStateListener {
@Override @Override
...@@ -13,6 +15,11 @@ public class StateListener implements IStateListener { ...@@ -13,6 +15,11 @@ public class StateListener implements IStateListener {
Debuger.log(">>onEngineStarted"); Debuger.log(">>onEngineStarted");
} }
@Override
public void onChannelRegistered(PluginRegistry.Registrar registrar, BoostChannel channel) {
Debuger.log(">>onFlutterViewInited");
}
@Override @Override
public void onFlutterViewInited(BoostFlutterEngine engine, BoostFlutterView flutterView) { public void onFlutterViewInited(BoostFlutterEngine engine, BoostFlutterView flutterView) {
Debuger.log(">>onFlutterViewInited"); Debuger.log(">>onFlutterViewInited");
......
...@@ -21,17 +21,14 @@ ...@@ -21,17 +21,14 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost; package com.idlefish.flutterboost;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.Color; import android.graphics.Color;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;
public class Utils { public class Utils {
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.containers; package com.idlefish.flutterboost.containers;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
...@@ -40,11 +40,11 @@ import android.widget.LinearLayout; ...@@ -40,11 +40,11 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.taobao.idlefish.flutterboost.BoostFlutterEngine; import com.idlefish.flutterboost.BoostFlutterEngine;
import com.taobao.idlefish.flutterboost.BoostFlutterView; import com.idlefish.flutterboost.BoostFlutterView;
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin; import com.idlefish.flutterboost.FlutterBoost;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer; import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer; import com.idlefish.flutterboost.interfaces.IOperateSyncer;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.HashMap;
...@@ -65,7 +65,7 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV ...@@ -65,7 +65,7 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
configureWindowForTransparency(); configureWindowForTransparency();
mSyncer = FlutterBoostPlugin.singleton().containerManager().generateSyncer(this); mSyncer = FlutterBoost.singleton().containerManager().generateSyncer(this);
mFlutterEngine = createFlutterEngine(); mFlutterEngine = createFlutterEngine();
...@@ -98,14 +98,14 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV ...@@ -98,14 +98,14 @@ public abstract class BoostFlutterActivity extends Activity implements IFlutterV
} }
protected BoostFlutterEngine createFlutterEngine(){ protected BoostFlutterEngine createFlutterEngine(){
return FlutterBoostPlugin.singleton().engineProvider().createEngine(this); return FlutterBoost.singleton().engineProvider().createEngine(this);
} }
protected BoostFlutterView createFlutterView(BoostFlutterEngine engine){ protected BoostFlutterView createFlutterView(BoostFlutterEngine engine){
BoostFlutterView.Builder builder = new BoostFlutterView.Builder(this); BoostFlutterView.Builder builder = new BoostFlutterView.Builder(this);
return builder.flutterEngine(engine) return builder.flutterEngine(engine)
.renderMode(FlutterView.RenderMode.surface) .renderMode(FlutterView.RenderMode.texture)
.transparencyMode(isBackgroundTransparent() ? .transparencyMode(isBackgroundTransparent() ?
FlutterView.TransparencyMode.transparent : FlutterView.TransparencyMode.transparent :
FlutterView.TransparencyMode.opaque) FlutterView.TransparencyMode.opaque)
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.containers; package com.idlefish.flutterboost.containers;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
...@@ -32,11 +32,11 @@ import android.view.LayoutInflater; ...@@ -32,11 +32,11 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import com.taobao.idlefish.flutterboost.BoostFlutterEngine; import com.idlefish.flutterboost.BoostFlutterEngine;
import com.taobao.idlefish.flutterboost.BoostFlutterView; import com.idlefish.flutterboost.BoostFlutterView;
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin; import com.idlefish.flutterboost.FlutterBoost;
import com.taobao.idlefish.flutterboost.interfaces.IFlutterViewContainer; import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import com.taobao.idlefish.flutterboost.interfaces.IOperateSyncer; import com.idlefish.flutterboost.interfaces.IOperateSyncer;
import java.util.Map; import java.util.Map;
...@@ -51,7 +51,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV ...@@ -51,7 +51,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
@Nullable @Nullable
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mSyncer = FlutterBoostPlugin.singleton().containerManager().generateSyncer(this); mSyncer = FlutterBoost.singleton().containerManager().generateSyncer(this);
mFlutterEngine = createFlutterEngine(); mFlutterEngine = createFlutterEngine();
mFlutterView = createFlutterView(mFlutterEngine); mFlutterView = createFlutterView(mFlutterEngine);
...@@ -62,7 +62,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV ...@@ -62,7 +62,7 @@ abstract public class BoostFlutterFragment extends Fragment implements IFlutterV
} }
protected BoostFlutterEngine createFlutterEngine(){ protected BoostFlutterEngine createFlutterEngine(){
return FlutterBoostPlugin.singleton().engineProvider().createEngine(getContext()); return FlutterBoost.singleton().engineProvider().createEngine(getContext());
} }
protected BoostFlutterView createFlutterView(BoostFlutterEngine engine){ protected BoostFlutterView createFlutterView(BoostFlutterEngine engine){
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
import java.util.Map; import java.util.Map;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
/** /**
* a container record, which use map a flutter page * a container record, which use map a flutter page
......
...@@ -21,14 +21,11 @@ ...@@ -21,14 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
import android.content.Context; import android.content.Context;
import com.taobao.idlefish.flutterboost.BoostFlutterEngine; import com.idlefish.flutterboost.BoostFlutterEngine;
import com.taobao.idlefish.flutterboost.BoostFlutterView;
import io.flutter.embedding.engine.FlutterEngine;
/** /**
* a flutter engine provider * a flutter engine provider
*/ */
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
import android.app.Activity; import android.app.Activity;
import com.taobao.idlefish.flutterboost.BoostFlutterView; import com.idlefish.flutterboost.BoostFlutterView;
import java.util.Map; import java.util.Map;
......
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
import android.content.Intent; import android.content.Intent;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
......
package com.taobao.idlefish.flutterboost.interfaces; package com.idlefish.flutterboost.interfaces;
import com.taobao.idlefish.flutterboost.BoostFlutterEngine; import com.idlefish.flutterboost.BoostChannel;
import com.taobao.idlefish.flutterboost.BoostFlutterView; import com.idlefish.flutterboost.BoostFlutterEngine;
import com.idlefish.flutterboost.BoostFlutterView;
import io.flutter.plugin.common.PluginRegistry;
public interface IStateListener { public interface IStateListener {
void onEngineCreated(BoostFlutterEngine engine); void onEngineCreated(BoostFlutterEngine engine);
void onEngineStarted(BoostFlutterEngine engine); void onEngineStarted(BoostFlutterEngine engine);
void onChannelRegistered(PluginRegistry.Registrar registrar, BoostChannel channel);
void onFlutterViewInited(BoostFlutterEngine engine, BoostFlutterView flutterView); void onFlutterViewInited(BoostFlutterEngine engine, BoostFlutterView flutterView);
void beforeEngineAttach(BoostFlutterEngine engine, BoostFlutterView flutterView); void beforeEngineAttach(BoostFlutterEngine engine, BoostFlutterView flutterView);
void afterEngineAttached(BoostFlutterEngine engine, BoostFlutterView flutterView); void afterEngineAttached(BoostFlutterEngine engine, BoostFlutterView flutterView);
......
...@@ -3,14 +3,11 @@ package com.taobao.idlefish.flutterboostexample; ...@@ -3,14 +3,11 @@ package com.taobao.idlefish.flutterboostexample;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import com.taobao.idlefish.flutterboost.containers.BoostFlutterFragment; import com.idlefish.flutterboost.containers.BoostFlutterFragment;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class FlutterFragment extends BoostFlutterFragment { public class FlutterFragment extends BoostFlutterFragment {
@Override @Override
......
package com.taobao.idlefish.flutterboostexample; package com.taobao.idlefish.flutterboostexample;
import com.taobao.idlefish.flutterboost.containers.BoostFlutterActivity; import com.idlefish.flutterboost.containers.BoostFlutterActivity;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugins.GeneratedPluginRegistrant;
public class FlutterPageActivity extends BoostFlutterActivity { public class FlutterPageActivity extends BoostFlutterActivity {
/** /**
...@@ -15,7 +12,7 @@ public class FlutterPageActivity extends BoostFlutterActivity { ...@@ -15,7 +12,7 @@ public class FlutterPageActivity extends BoostFlutterActivity {
* 混合栈将会在flutter层根据这个名字,在注册的Route表中查找对应的Widget * 混合栈将会在flutter层根据这个名字,在注册的Route表中查找对应的Widget
* *
* 在flutter层有注册函数: * 在flutter层有注册函数:
* FlutterBoostPlugin.singleton.registerPageBuilders({ * FlutterBoost.singleton.registerPageBuilders({
* 'first': (pageName, params, _) => FirstRouteWidget(), * 'first': (pageName, params, _) => FirstRouteWidget(),
* 'second': (pageName, params, _) => SecondRouteWidget(), * 'second': (pageName, params, _) => SecondRouteWidget(),
* ... * ...
...@@ -34,7 +31,7 @@ public class FlutterPageActivity extends BoostFlutterActivity { ...@@ -34,7 +31,7 @@ public class FlutterPageActivity extends BoostFlutterActivity {
* 该方法返回的参数将会传递给上层的flutter对应的Widget * 该方法返回的参数将会传递给上层的flutter对应的Widget
* *
* 在flutter层有注册函数: * 在flutter层有注册函数:
* FlutterBoostPlugin.singleton.registerPageBuilders({ * FlutterBoost.singleton.registerPageBuilders({
* 'first': (pageName, params, _) => FirstRouteWidget(), * 'first': (pageName, params, _) => FirstRouteWidget(),
* 'second': (pageName, params, _) => SecondRouteWidget(), * 'second': (pageName, params, _) => SecondRouteWidget(),
* ... * ...
......
...@@ -3,8 +3,8 @@ package com.taobao.idlefish.flutterboostexample; ...@@ -3,8 +3,8 @@ package com.taobao.idlefish.flutterboostexample;
import android.app.Application; import android.app.Application;
import android.content.Context; import android.content.Context;
import com.taobao.idlefish.flutterboost.FlutterBoostPlugin; import com.idlefish.flutterboost.FlutterBoost;
import com.taobao.idlefish.flutterboost.Platform; import com.idlefish.flutterboost.Platform;
import java.util.Map; import java.util.Map;
...@@ -17,7 +17,7 @@ public class MyApplication extends FlutterApplication { ...@@ -17,7 +17,7 @@ public class MyApplication extends FlutterApplication {
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
FlutterBoostPlugin.init(new Platform() { FlutterBoost.init(new Platform() {
@Override @Override
public Application getApplication() { public Application getApplication() {
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
// //
#import "GeneratedPluginRegistrant.h" #import "GeneratedPluginRegistrant.h"
#import <flutter_boost/FlutterBoostPlugin.h> #import <flutter_boost/BoostChannel.h>
#import <xservice_kit/XserviceKitPlugin.h> #import <xservice_kit/XserviceKitPlugin.h>
@implementation GeneratedPluginRegistrant @implementation GeneratedPluginRegistrant
+ (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry { + (void)registerWithRegistry:(NSObject<FlutterPluginRegistry>*)registry {
[FlutterBoostPlugin registerWithRegistrar:[registry registrarForPlugin:@"FlutterBoostPlugin"]]; [BoostChannel registerWithRegistrar:[registry registrarForPlugin:@"BoostChannel"]];
[XserviceKitPlugin registerWithRegistrar:[registry registrarForPlugin:@"XserviceKitPlugin"]]; [XserviceKitPlugin registerWithRegistrar:[registry registrarForPlugin:@"XserviceKitPlugin"]];
} }
......
...@@ -11,8 +11,6 @@ dependencies: ...@@ -11,8 +11,6 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
xservice_kit: ^0.0.27
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec # following page: https://www.dartlang.org/tools/pub/pubspec
...@@ -20,8 +18,8 @@ dependencies: ...@@ -20,8 +18,8 @@ dependencies:
# The following section is specific to Flutter. # The following section is specific to Flutter.
flutter: flutter:
plugin: plugin:
androidPackage: com.taobao.idlefish.flutterboost androidPackage: com.idlefish.flutterboost
pluginClass: FlutterBoostPlugin pluginClass: BoostChannel
# To add assets to your plugin package, add an assets section, like this: # To add assets to your plugin package, add an assets section, like this:
# assets: # assets:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment