package com.performance.liferecord.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.performance.liferecord.R;
import com.performance.liferecord.model.GankData;

public class PostDetailActivity extends AppCompatActivity {

    private WebView mWebView;
    private String postUrl;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);

        setContentView(R.layout.activity_post_detail);
        getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);

        mWebView = (WebView) findViewById(R.id.web_view);
        final Activity MyActivity = this;
        WebSettings webSettings = null;
        if (mWebView != null) {
            webSettings = mWebView.getSettings();
            webSettings.setJavaScriptEnabled(true);
            webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
            webSettings.setSupportZoom(true);
            webSettings.setSupportMultipleWindows(true);
            mWebView.setWebViewClient(new WebViewClient());
            mWebView.setWebChromeClient(new WebChromeClient() {
                @Override
                public void onProgressChanged(WebView view, int newProgress) {
                    super.onProgressChanged(view, newProgress);
                    MyActivity.setTitle(getString(R.string.loading));
                    MyActivity.setProgress(newProgress * 100);
                    // Return the app name after finish loading
                    if (newProgress == 100)
                        MyActivity.setTitle(R.string.app_name);
                }

            });
        }

        getData();

    }

    private void getData() {
        Intent intent = getIntent();
        postUrl = intent.getStringExtra(GankData.POST_URL);
        mWebView.loadUrl(postUrl);
    }

    @Override
    protected void onResume() {
        super.onResume();
        mWebView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mWebView.onPause();
    }

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

@@ -172,32 +172,89 @@
 ompatActivity;%0D%0A
+import android.util.Log;%0D%0Aimport android.view.KeyEvent;%0D%0A
 import android.v
@@ -564,24 +564,85 @@
 tivity %7B%0D%0A%0D%0A
+    private static final String TAG = %22PostDetailActivity%22;%0D%0A
     private 
@@ -882,64 +882,8 @@
 %0D%0A%0D%0A
-        setContentView(R.layout.activity_post_detail);%0D%0A
     
@@ -995,45 +995,26 @@
 w = 
-(WebView) findViewById(R.id.web_view)
+new WebView(this);
 ;%0D%0A 
@@ -1100,45 +1100,8 @@
 l;%0D%0A
-        if (mWebView != null) %7B%0D%0A    
     
@@ -1139,28 +1139,24 @@
 ettings();%0D%0A
-    
         webS
@@ -1192,36 +1192,32 @@
 true);%0D%0A        
- 
-   
 webSettings.setC
@@ -1260,28 +1260,24 @@
 _NETWORK);%0D%0A
-    
         webS
@@ -1311,28 +1311,24 @@
 );%0D%0A        
-    
 webSettings.
@@ -1361,36 +1361,32 @@
 true);%0D%0A        
-   
- 
 mWebView.setWebV
@@ -1414,28 +1414,24 @@
 Client());%0D%0A
-    
         mWeb
@@ -1491,20 +1491,16 @@
         
-  
-  
 @Overrid
@@ -1502,20 +1502,16 @@
 erride%0D%0A
-    
         
@@ -1590,28 +1590,24 @@
             
- 
-   
 super.onProg
@@ -1635,28 +1635,24 @@
 Progress);%0D%0A
-    
             
@@ -1714,36 +1714,32 @@
                 
-    
 MyActivity.setPr
@@ -1782,20 +1782,16 @@
         
-   
- 
 // Retur
@@ -1839,28 +1839,24 @@
             
-    
 if (newProgr
@@ -1880,36 +1880,32 @@
                 
-  
-  
 MyActivity.setTi
@@ -1937,28 +1937,24 @@
             
-    
 %7D%0D%0A%0D%0A       
@@ -1958,26 +1958,11 @@
     
- 
-   %7D);%0D%0A        %7D
+%7D);
 %0D%0A%0D%0A
@@ -1977,26 +1977,24 @@
 getData();%0D%0A
-%0D%0A
     %7D%0D%0A%0D%0A   
@@ -2151,24 +2151,59 @@
 (postUrl);%0D%0A
+        setContentView(mWebView);%0D%0A
     %7D%0D%0A%0D%0A   
@@ -2454,44 +2454,139 @@
 lic 
-void onBackPressed() %7B%0D%0A        if (
+boolean onKeyDown(int keyCode, KeyEvent event) %7B%0D%0A        Log.v(TAG,%22onKeyDown%22);%0D%0A        if (keyCode == KeyEvent.KEYCODE_BACK && 
 mWeb
@@ -2636,16 +2636,26 @@
 oBack();
+// %E8%BF%94%E5%9B%9E%E5%89%8D%E4%B8%80%E4%B8%AA%E9%A1%B5%E9%9D%A2
 %0D%0A      
@@ -2666,16 +2666,21 @@
   return
+ true
 ;%0D%0A     
@@ -2685,24 +2685,26 @@
      %7D%0D%0A
+%0D%0A
         
 super.on
@@ -2695,24 +2695,31 @@
         
+return 
 super.on
 BackPres
@@ -2714,20 +2714,30 @@
 r.on
-BackPressed(
+KeyDown(keyCode, event
 );%0D%0A

update webview config