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

防止空指针

parent edcd73fa
...@@ -692,7 +692,6 @@ public class XFlutterView extends FrameLayout { ...@@ -692,7 +692,6 @@ public class XFlutterView extends FrameLayout {
// signifies that this View does not process input (until a new engine is attached). // 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 // 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. // Instruct our FlutterRenderer that we are no longer interested in being its RenderSurface.
FlutterRenderer flutterRenderer = flutterEngine.getRenderer(); FlutterRenderer flutterRenderer = flutterEngine.getRenderer();
// didRenderFirstFrame = false; // didRenderFirstFrame = false;
...@@ -701,32 +700,12 @@ public class XFlutterView extends FrameLayout { ...@@ -701,32 +700,12 @@ public class XFlutterView extends FrameLayout {
flutterEngine = null; flutterEngine = null;
} }
public void release(){ public void release(){
textInputPlugin.release(); if(textInputPlugin!=null){
} 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();
} }
} }
/** /**
* Returns true if this {@code FlutterView} is currently attached to a {@link FlutterEngine}. * 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