浏览代码

added stop loading method and handling on android

Peter Thaler 7 年之前
父节点
当前提交
97295a6b19

+ 9 - 0
android/src/main/java/com/flutter_webview_plugin/FlutterWebviewPlugin.java

@@ -67,6 +67,9 @@ public class FlutterWebviewPlugin implements MethodCallHandler, PluginRegistry.A
                 break;
             case "reloadUrl":
                 reloadUrl(call, result);
+                break;
+            case "stopLoading":
+                stopLoading(call, result);
                 break;				
             default:
                 result.notImplemented();
@@ -124,6 +127,12 @@ public class FlutterWebviewPlugin implements MethodCallHandler, PluginRegistry.A
         return params;
     }
 
+    private void stopLoading(MethodCall call, MethodChannel.Result result) {
+        if (webViewManager != null){
+            webViewManager.stopLoading(call, result);
+        }
+    }
+
     private void close(MethodCall call, MethodChannel.Result result) {
         if (webViewManager != null) {
             webViewManager.close(call, result);

+ 6 - 0
android/src/main/java/com/flutter_webview_plugin/WebviewManager.java

@@ -279,4 +279,10 @@ class WebviewManager {
             webView.setVisibility(View.VISIBLE);
         }
     }
+
+    void stopLoading(MethodCall call, MethodChannel.Result result){
+        if (webView != null){
+            webView.stopLoading();
+        }
+    }
 }

+ 3 - 0
lib/src/base.dart

@@ -146,6 +146,9 @@ class FlutterWebviewPlugin {
     await _channel.invokeMethod("reloadUrl", args);
   }
 
+  // Stops current loading process
+  Future stopLoading() => _channel.invokeMethod("stopLoading");
+
   /// adds the plugin as ActivityResultListener
   /// Only needed and used on Android
   Future registerAcitivityResultListener() => _channel.invokeMethod("registerAcitivityResultListener");