1
0
mirror of https://github.com/etesync/android synced 2024-11-05 15:39:49 +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);
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) {