This repository was archived by the owner on Apr 2, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 2222import android .os .Build ;
2323
2424public class IonicKeyboard extends CordovaPlugin {
25+ private OnGlobalLayoutListener list ;
26+ private View rootView ;
2527
2628 public void initialize (CordovaInterface cordova , CordovaWebView webView ) {
2729 super .initialize (cordova , webView );
@@ -64,8 +66,8 @@ public void run() {
6466 final float density = dm .density ;
6567
6668 //http://stackoverflow.com/a/4737265/1091751 detect if keyboard is showing
67- final View rootView = cordova .getActivity ().getWindow ().getDecorView ().findViewById (android .R .id .content ).getRootView ();
68- OnGlobalLayoutListener list = new OnGlobalLayoutListener () {
69+ rootView = cordova .getActivity ().getWindow ().getDecorView ().findViewById (android .R .id .content ).getRootView ();
70+ list = new OnGlobalLayoutListener () {
6971 int previousHeightDiff = 0 ;
7072 @ Override
7173 public void onGlobalLayout () {
@@ -124,6 +126,10 @@ else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelH
124126 return false ; // Returning false results in a "MethodNotFound" error.
125127 }
126128
129+ @ Override
130+ public void onDestroy () {
131+ rootView .getViewTreeObserver ().removeOnGlobalLayoutListener (list );
132+ }
127133
128134}
129135
You can’t perform that action at this time.
0 commit comments