Skip to content
This repository was archived by the owner on Apr 2, 2018. It is now read-only.

Commit 4fe0e7e

Browse files
committed
Remove layout listener onDestroy
1 parent f5c21ed commit 4fe0e7e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/android/IonicKeyboard.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import android.os.Build;
2323

2424
public 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

0 commit comments

Comments
 (0)