package com.grishman.rssfeed.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.grishman.rssfeed.R;

/**
 * A Detail View fragment containing a web view
 * for displaying URL from feed list.
 */
public class DetailWebViewFragment extends Fragment {

    public static final String DETAIL_URL = "URL";
    private String mUrl;

    public DetailWebViewFragment() {
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
        WebView myWebView = (WebView) rootView.findViewById(R.id.webview);
        Bundle arguments = getArguments();
        if (arguments != null) {
            mUrl = arguments.getString(DetailWebViewFragment.DETAIL_URL);
        }
        Log.d("URT TO DETAIL", "" + mUrl);
        // TODO Fix rotation
        myWebView.getSettings().setJavaScriptEnabled(true);
        myWebView.setWebViewClient(new FeedWebViewClient());
        myWebView.loadUrl(mUrl);
        return rootView;
    }

    private class FeedWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return true;
        }
    }
}

@@ -548,52 +548,477 @@
 rl;%0A
-%0A    public DetailWebViewFragment() %7B%0A    %7D%0A
+    private WebView detailWebView;%0A    private Bundle webViewBundle;%0A%0A    public DetailWebViewFragment() %7B%0A    %7D%0A%0A    @Override%0A    public void onSaveInstanceState(Bundle outState) %7B%0A        super.onSaveInstanceState(outState);%0A        detailWebView.saveState(outState);%0A    %7D%0A%0A    @Override%0A    public void onActivityCreated(Bundle savedInstanceState) %7B%0A        super.onActivityCreated(savedInstanceState);%0A        detailWebView.restoreState(savedInstanceState);%0A    %7D
 %0A   
@@ -1259,18 +1259,14 @@
     
-WebView my
+detail
 WebV
@@ -1550,34 +1550,38 @@
 otation%0A        
-my
+detail
 WebView.getSetti
@@ -1614,34 +1614,102 @@
 (true);%0A        
-my
+detailWebView.getSettings().setDomStorageEnabled(true);%0A        detail
 WebView.setWebVi
@@ -1743,24 +1743,26 @@
 ent());%0A
+//
         
 myWebVie
@@ -1757,56 +1757,381 @@
     
-myWebView.loadUrl(mUrl);%0A        return rootView
+detailWebView.loadUrl(mUrl);%0A%0A        if (webViewBundle == null) %7B%0A            detailWebView.loadUrl(mUrl);%0A        %7D else %7B%0A            detailWebView.restoreState(webViewBundle);%0A        %7D%0A        return rootView;%0A    %7D%0A    @Override%0A    public void onPause() %7B%0A        super.onPause();%0A%0A        webViewBundle = new Bundle();%0A        detailWebView.saveState(webViewBundle)
 ;%0A  

Update webView to use DOM Try to restore state of webView