package org.hogel.naroubrowser.activities;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import butterknife.InjectView;
import org.hogel.naroubrowser.R;
import org.hogel.naroubrowser.consts.UrlConst;
import org.hogel.naroubrowser.views.MainWebView;


public class MainActivity extends AbstractActivity {
    @InjectView(R.id.main_webview)
    MainWebView mainWebview;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        setup();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onBackPressed() {
        if (mainWebview.canGoBack()) {
            mainWebview.goBack();
            return;
        }
        super.onBackPressed();
    }

    private void setup() {
        mainWebview.setCallback(new MainWebView.Callback() {
            @Override
            public void onLoadResource(String title) {
                setTitle(title);
            }
        });
        mainWebview.loadUrl(UrlConst.URL_LAUNCH);
    }
}

@@ -571,22 +571,599 @@
         
-setup(
+if (savedInstanceState == null) %7B%0A            setup();%0A        %7D else %7B%0A            mainWebview.restoreState(savedInstanceState);%0A        %7D%0A    %7D%0A%0A    private void setup() %7B%0A        mainWebview.setCallback(new MainWebView.Callback() %7B%0A            @Override%0A            public void onLoadResource(String title) %7B%0A                setTitle(title);%0A            %7D%0A        %7D);%0A        mainWebview.loadUrl(UrlConst.URL_LAUNCH);%0A    %7D%0A%0A    @Override%0A    protected void onSaveInstanceState(Bundle outState) %7B%0A        super.onSaveInstanceState(outState);%0A        mainWebview.saveState(outState
 );%0A    %7D
@@ -1751,288 +1751,7 @@
    %7D
-%0A%0A    private void setup() %7B%0A        mainWebview.setCallback(new MainWebView.Callback() %7B%0A            @Override%0A            public void onLoadResource(String title) %7B%0A                setTitle(title);%0A            %7D%0A        %7D);%0A        mainWebview.loadUrl(UrlConst.URL_LAUNCH);%0A    %7D
 %0A%7D%0A

Save webview state