Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added reloading (Android) #59

Merged
merged 11 commits into from
May 24, 2018
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
case "resize":
resize(call, result);
break;
case "reload":
reload(call, result);
break;
case "back":
back(call, result);
break;
case "forward":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad code format

forward(call, result);
break;
default:
result.notImplemented();
break;
Expand Down Expand Up @@ -111,6 +120,25 @@ private void close(MethodCall call, MethodChannel.Result result) {
}
}


private void back(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.back(call, result);
}
}

private void forward(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.forward(call, result);
}
}


private void reload(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.reload(call, result);
}
}
private void eval(MethodCall call, final MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.eval(call, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,33 @@ public void onReceiveValue(String value) {
});
}

void reload(MethodCall call, MethodChannel.Result result) {
if (webView != null) {
webView.reload();
}
}

void back(MethodCall call, MethodChannel.Result result) {
if (webView != null && webView.canGoBack()) {
webView.goBack();
}
}

void forward(MethodCall call, MethodChannel.Result result) {
if (webView != null && webView.canGoForward()) {
webView.goForward();
}
}

void resize(FrameLayout.LayoutParams params) {
webView.setLayoutParams(params);
}

boolean canGoBack() {
return webView.canGoBack();
}

boolean canGoForward() {
return webView.canGoForward();
}
}
6 changes: 6 additions & 0 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ class FlutterWebviewPlugin {
/// Will trigger the [onDestroy] event
Future close() => _channel.invokeMethod("close");

Future reload() => _channel.invokeMethod("reload");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please comment functions and explain that it is only available on Android for now

Future goBack() => _channel.invokeMethod("back");

Future goForward() => _channel.invokeMethod("forward");

/// Close all Streams
void dispose() {
_onDestroy.close();
Expand Down