Commit 2d798567 authored by justin's avatar justin

Merge branch 'task/task_v1.12.13_support_hotfixes' of...

Merge branch 'task/task_v1.12.13_support_hotfixes' of github.com:alibaba/flutter_boost into task/task_v1.12.13_support_hotfixes
parents 415c37f9 09ee4859
......@@ -17,3 +17,4 @@ example/android/app/.classpath
example/android/app/.project
example/android/.project
flutter_boost
.flutter-plugins-dependencies
......@@ -29,8 +29,8 @@ public class XPlatformPlugin {
public static final int DEFAULT_SYSTEM_UI = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
private Activity activity;
private PlatformChannel platformChannel;
private Activity activity;
private PlatformChannel platformChannel;
private PlatformChannel.SystemChromeStyle currentTheme;
private int mEnabledOverlays;
......@@ -96,26 +96,25 @@ public class XPlatformPlugin {
}
};
public XPlatformPlugin( PlatformChannel platformChannel) {
public XPlatformPlugin(PlatformChannel platformChannel) {
this.platformChannel = platformChannel;
this.platformChannel.setPlatformMessageHandler(mPlatformMessageHandler);
mEnabledOverlays = DEFAULT_SYSTEM_UI;
}
public void attachToActivity(Activity activity ){
this.activity = activity;
this.platformChannel.setPlatformMessageHandler(mPlatformMessageHandler);
}
/**
* Releases all resources held by this {@code PlatformPlugin}.
* <p>
* Do not invoke any methods on a {@code PlatformPlugin} after invoking this method.
*/
public void detachActivity() {
this.activity=null;
this.mPlatformMessageHandler=null;
public void detachActivity(Activity activity) {
if (activity == this.activity) {
this.activity = null;
}
}
private void playSystemSound(PlatformChannel.SoundType soundType) {
......
......@@ -56,6 +56,7 @@ public class BoostFlutterActivity extends Activity
// Default configuration.
protected static final String DEFAULT_BACKGROUND_MODE = BackgroundMode.opaque.name();
private static XPlatformPlugin sXPlatformPlugin;
public static Intent createDefaultIntent(@NonNull Context launchContext) {
return withNewEngine().build(launchContext);
......@@ -440,8 +441,8 @@ public class BoostFlutterActivity extends Activity
@Nullable
@Override
public XPlatformPlugin providePlatformPlugin( @NonNull FlutterEngine flutterEngine) {
return new XPlatformPlugin( flutterEngine.getPlatformChannel());
public XPlatformPlugin providePlatformPlugin(@NonNull FlutterEngine flutterEngine) {
return BoostViewUtils.getPlatformPlugin(flutterEngine.getPlatformChannel());
}
/**
......
package com.idlefish.flutterboost.containers;
import com.idlefish.flutterboost.XPlatformPlugin;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
class BoostViewUtils {
private static volatile XPlatformPlugin mInstance;
private BoostViewUtils() {
}
public static XPlatformPlugin getPlatformPlugin(PlatformChannel channel) {
if (mInstance == null) {
synchronized (BoostViewUtils.class) {
if (mInstance == null) {
mInstance = new XPlatformPlugin(channel);
}
}
}
return mInstance;
}
}
......@@ -228,7 +228,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
// Null out the platformPlugin to avoid a possible retain cycle between the plugin, this Fragment,
// and this Fragment's Activity.
if (platformPlugin != null) {
platformPlugin.detachActivity();
platformPlugin.detachActivity(getContextActivity());
platformPlugin = null;
}
......
......@@ -2,8 +2,6 @@ package com.idlefish.flutterboost.containers;
import android.app.Activity;
import android.arch.lifecycle.Lifecycle;
import android.graphics.Color;
import android.view.*;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
......@@ -17,13 +15,11 @@ import android.view.View;
import android.view.ViewGroup;
import com.idlefish.flutterboost.FlutterBoost;
import com.idlefish.flutterboost.Utils;
import com.idlefish.flutterboost.XFlutterView;
import com.idlefish.flutterboost.XPlatformPlugin;
import io.flutter.embedding.android.*;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.plugin.platform.PlatformPlugin;
import java.util.HashMap;
import java.util.Map;
......@@ -472,8 +468,7 @@ public class FlutterFragment extends Fragment implements FlutterActivityAndFragm
@Nullable
@Override
public XPlatformPlugin providePlatformPlugin( @NonNull FlutterEngine flutterEngine) {
return new XPlatformPlugin(flutterEngine.getPlatformChannel());
return BoostViewUtils.getPlatformPlugin(flutterEngine.getPlatformChannel());
}
/**
......
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