Skip to content

Commit

Permalink
Merge pull request #42 from pkillian/issue-40_Integrated-browser-refr…
Browse files Browse the repository at this point in the history
…esh-on-rotate

Issue 40 integrated browser refresh on rotate
  • Loading branch information
bishopmatthew committed Jan 1, 2014
2 parents cdab92b + a742ea6 commit 2107c48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/com/airlocksoftware/hackernews/fragment/WebFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ public WebFragment() {
public void onCreate(Bundle savedState) {
super.onCreate(savedState);
Bundle args = getArguments();

if (args != null) {
mUrl = args.getString(URL);
}

}

@Override
Expand All @@ -84,7 +86,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mWebView.setWebChromeClient(mWebChromeClient);
mWebView.setWebViewClient(mWebViewClient);

if (mUrl != null) {
if (savedInstanceState != null) {
mWebView.restoreState(savedInstanceState);
} else if (mUrl != null) {
mWebView.loadUrl(mUrl);
}

Expand All @@ -109,6 +113,7 @@ public void onProgressChanged(WebView view, int progress) {
WebViewClient mWebViewClient = new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
mUrl = url;
return true;
}
};
Expand Down Expand Up @@ -149,6 +154,7 @@ public void onActivityCreated(Bundle savedInstanceState) {

@Override
public void onSaveInstanceState(Bundle outState) {
mWebView.saveState(outState);
outState.putString(URL, mUrl);
super.onSaveInstanceState(outState);
}
Expand Down

0 comments on commit 2107c48

Please sign in to comment.