From 182d6ebe665cb1ed4c329091e1b734b1729dc0e0 Mon Sep 17 00:00:00 2001 From: tal Date: Fri, 13 Apr 2018 16:43:13 +0300 Subject: [PATCH] Restore WebView state on orientation changes This fixes #28 --- .../com/etesync/syncadapter/ui/WebViewActivity.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.java b/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.java index d9d16030..b7978232 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.java +++ b/app/src/main/java/com/etesync/syncadapter/ui/WebViewActivity.java @@ -55,7 +55,10 @@ public class WebViewActivity extends BaseActivity { mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mWebView.getSettings().setJavaScriptEnabled(true); - mWebView.loadUrl(uri.toString()); + if (savedInstanceState == null) { + mWebView.loadUrl(uri.toString()); + } + mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { @@ -190,6 +193,12 @@ public class WebViewActivity extends BaseActivity { mWebView.saveState(outState); } + @Override + protected void onRestoreInstanceState(Bundle savedInstanceState) { + super.onRestoreInstanceState(savedInstanceState); + mWebView.restoreState(savedInstanceState); + } + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) {