Skip to content

Commit

Permalink
Restore WebView state on orientation changes
Browse files Browse the repository at this point in the history
This fixes etesync#28
  • Loading branch information
talhaco authored and tasn committed Apr 16, 2018
1 parent 277da4a commit 182d6eb
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ protected void onCreate(Bundle savedInstanceState) {
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) {
Expand Down Expand Up @@ -190,6 +193,12 @@ protected void onSaveInstanceState(Bundle outState) {
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) {
Expand Down

0 comments on commit 182d6eb

Please sign in to comment.