Commit 8dd58ee9 authored by 李增强's avatar 李增强

修复activity插件异常问题

parent 5d638134
......@@ -2,15 +2,19 @@ package com.idlefish.flutterboost.containers;
import android.annotation.SuppressLint;
import android.app.Activity;
import androidx.lifecycle.Lifecycle;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.os.Build;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.*;
import java.io.Serializable;
......@@ -23,12 +27,14 @@ import com.idlefish.flutterboost.FlutterBoost;
import com.idlefish.flutterboost.Utils;
import com.idlefish.flutterboost.interfaces.IFlutterViewContainer;
import com.idlefish.flutterboost.interfaces.IOperateSyncer;
import io.flutter.Log;
import io.flutter.app.FlutterActivity;
import io.flutter.embedding.android.*;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.FlutterShellArgs;
import io.flutter.embedding.engine.plugins.PluginRegistry;
import io.flutter.plugin.platform.PlatformPlugin;
import static android.content.ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW;
......@@ -37,7 +43,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
private static final String TAG = "FlutterActivityAndFragmentDelegate";
private static int ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE=0;
private static int ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE = 0;
@NonNull
private Host host;
@Nullable
......@@ -179,20 +185,18 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
public void onResume() {
if(mSyncer.isLocked()) return;
if (mSyncer.isLocked()) return;
mSyncer.onAppear();
Log.v(TAG, "onResume()");
ensureAlive();
flutterEngine.getLifecycleChannel().appIsResumed();
if(ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE == 0 ||
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE != this.host.getActivity().hashCode()){
flutterEngine.getActivityControlSurface().detachFromActivityForConfigChanges();
flutterEngine.getActivityControlSurface().attachToActivity(host.getActivity(),host.getLifecycle());
if (ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE == 0 ||
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE != this.host.getActivity().hashCode()) {
ACTIVITY_CONTROL_SURFACE_ATTACH_TO_ACTVITY_HASH_CODE = host.getActivity().hashCode();
}
}
}
......@@ -213,7 +217,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
public void onPause() {
Log.v(TAG, "onPause()");
if(mSyncer.isLocked()) return;
if (mSyncer.isLocked()) return;
ensureAlive();
mSyncer.onDisappear();
flutterEngine.getLifecycleChannel().appIsInactive();
......@@ -249,7 +253,8 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
if (host.getActivity().isChangingConfigurations()) {
flutterEngine.getActivityControlSurface().detachFromActivityForConfigChanges();
} else {
flutterEngine.getActivityControlSurface().detachFromActivity();
// flutterEngine.getActivityControlSurface().detachFromActivity();
}
}
Utils.fixInputMethodManagerLeak(host.getActivity());
......@@ -481,6 +486,7 @@ public class FlutterActivityAndFragmentDelegate implements IFlutterViewContainer
*/
PlatformPlugin providePlatformPlugin(
@Nullable Activity activity, @NonNull FlutterEngine flutterEngine);
/**
* Hook for the host to configure the {@link FlutterEngine} as desired.
*/
......
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