1
0
mirror of https://github.com/etesync/android synced 2024-11-29 11:28:19 +00:00

Restore WebView state on orientation changes

This fixes #28
This commit is contained in:
tal 2018-04-13 16:43:13 +03:00 committed by Tom Hacohen
parent 277da4a770
commit 182d6ebe66

View File

@ -55,7 +55,10 @@ public class WebViewActivity extends BaseActivity {
mProgressBar = (ProgressBar) findViewById(R.id.progressBar); mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.loadUrl(uri.toString()); if (savedInstanceState == null) {
mWebView.loadUrl(uri.toString());
}
mWebView.setWebViewClient(new WebViewClient() { mWebView.setWebViewClient(new WebViewClient() {
@Override @Override
public void onPageFinished(WebView view, String url) { public void onPageFinished(WebView view, String url) {
@ -190,6 +193,12 @@ public class WebViewActivity extends BaseActivity {
mWebView.saveState(outState); mWebView.saveState(outState);
} }
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mWebView.restoreState(savedInstanceState);
}
@Override @Override
public boolean onKeyDown(int keyCode, KeyEvent event) { public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {