Commit 7422c7c1 authored by yangwu.jia's avatar yangwu.jia

防止空指针

parent edcd73fa
......@@ -692,7 +692,6 @@ public class XFlutterView extends FrameLayout {
// signifies that this View does not process input (until a new engine is attached).
// TODO(mattcarroll): once this is proven to work, move this line ot TextInputPlugin
// resolveMemoryLeaks();
// Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface.
FlutterRenderer flutterRenderer = flutterEngine.getRenderer();
// didRenderFirstFrame = false;
......@@ -701,32 +700,12 @@ public class XFlutterView extends FrameLayout {
flutterEngine = null;
}
public void release(){
textInputPlugin.release();
}
public void resolveMemoryLeaks(){
try {
Class clazz = TextInputPlugin.class;
for (Field f : clazz.getDeclaredFields()) {
System.out.println(f.isAccessible());
f.setAccessible(true);
if(f.get(this.textInputPlugin) instanceof TextInputChannel){
System.out.println( "xxxxxx:" +f.getName());
TextInputChannel channel=(TextInputChannel)f.get(this.textInputPlugin);
channel.setTextInputMethodHandler(null);
}
}
} catch (Throwable e) {
e.printStackTrace();
if(textInputPlugin!=null){
textInputPlugin.release();
}
}
/**
* Returns true if this {@code FlutterView} is currently attached to a {@link FlutterEngine}.
*/
......
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