Browse Source

fix clearInterval not works on react issue for index.android.js; fix package path issue for android

iou90 6 years ago
parent
commit
365b36eed5

android/src/main/java/com/dscj/autoheightwebview/AutoHeightWebViewManager.java → android/src/main/java/com/iou90/autoheightwebview/AutoHeightWebViewManager.java View File


android/src/main/java/com/dscj/autoheightwebview/AutoHeightWebViewPackage.java → android/src/main/java/com/iou90/autoheightwebview/AutoHeightWebViewPackage.java View File


android/src/main/java/com/dscj/autoheightwebview/JavascriptBridge.java → android/src/main/java/com/iou90/autoheightwebview/JavascriptBridge.java View File


+ 8
- 6
autoHeightWebView/index.android.js View File

201
       return;
201
       return;
202
     }
202
     }
203
     this.finishInterval = false;
203
     this.finishInterval = false;
204
-    this.interval = setInterval(() => {
205
-      if (!this.finishInterval) {
206
-        isBelowKitKat ? this.sendToWebView('getBodyHeight') : this.postMessage('getBodyHeight');
207
-      }
208
-    }, 205);
204
+    this.setState({
205
+      interval: setInterval(() => {
206
+        if (!this.finishInterval) {
207
+          isBelowKitKat ? this.sendToWebView('getBodyHeight') : this.postMessage('getBodyHeight');
208
+        }
209
+      }, 205)
210
+    });
209
   }
211
   }
210
 
212
 
211
   stopInterval() {
213
   stopInterval() {
212
     this.finishInterval = true;
214
     this.finishInterval = true;
213
-    clearInterval(this.interval);
215
+    clearInterval(this.state.interval);
214
   }
216
   }
215
 
217
 
216
   onMessage = e => {
218
   onMessage = e => {