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 22
22
import android .os .Build ;
23
23
24
24
public class IonicKeyboard extends CordovaPlugin {
25
+ private OnGlobalLayoutListener list ;
26
+ private View rootView ;
25
27
26
28
public void initialize (CordovaInterface cordova , CordovaWebView webView ) {
27
29
super .initialize (cordova , webView );
@@ -64,8 +66,8 @@ public void run() {
64
66
final float density = dm .density ;
65
67
66
68
//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 () {
69
71
int previousHeightDiff = 0 ;
70
72
@ Override
71
73
public void onGlobalLayout () {
@@ -124,6 +126,10 @@ else if ( pixelHeightDiff != previousHeightDiff && ( previousHeightDiff - pixelH
124
126
return false ; // Returning false results in a "MethodNotFound" error.
125
127
}
126
128
129
+ @ Override
130
+ public void onDestroy () {
131
+ rootView .getViewTreeObserver ().removeOnGlobalLayoutListener (list );
132
+ }
127
133
128
134
}
129
135
You can’t perform that action at this time.
0 commit comments