| 
					
				 | 
			
			
				@@ -0,0 +1,592 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+package com.haochuan.djbl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.app.Activity; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.app.AlertDialog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.app.ProgressDialog; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.content.DialogInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.content.Intent; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.os.Build; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.os.Bundle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.os.Handler; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.support.annotation.NonNull; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.util.Log; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.view.View; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.view.ViewGroup; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.CookieManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.CookieSyncManager; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.JavascriptInterface; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.ValueCallback; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.WebChromeClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.WebSettings; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.WebView; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.webkit.WebViewClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.widget.FrameLayout; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import android.widget.Toast; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.android.volley.Request; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.android.volley.RequestQueue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.android.volley.Response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.android.volley.VolleyError; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.android.volley.toolbox.JsonObjectRequest; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.android.volley.toolbox.Volley; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.haochuan.djbl2.R; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.odin.framework.plugable.Logger; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sdk.commplatform.entry.AuthResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sdk.commplatform.entry.ErrorCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sdk.commplatform.entry.PayResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.sdk.commplatform.listener.CallbackListener; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+public class DjblMainActivity extends Activity { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    String TAG = "HuaweiPay"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String userId=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private WebView webview; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String backUrl = ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String buyProductId=""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    boolean enableLogger = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void Logger(String msg){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(enableLogger){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Log.d(TAG,msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private boolean isPlayPay =false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private int requestPlayCode = 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private int requestPayCode =2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private int responsePlayCode =3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private H5Result h5Result = new H5Result() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void videoPlay(String url,String title,String uId,String sourceId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Intent intent = new Intent(DjblMainActivity.this,VideoPlayerActivity.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            intent.putExtra("url",url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            intent.putExtra("title",title); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            intent.putExtra("uId",uId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            intent.putExtra("sourceId",sourceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DjblMainActivity.this.startActivityForResult(intent,requestPlayCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private MyPayResult myPayResult = new MyPayResult() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void onSuccess() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Toast("计费成功" ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Logger("计费成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            authAfterPay(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void onFail(String msg) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Logger("计费失败:" + msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            authAfterPay(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void authAfterPay(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        final ProgressDialog dialog = new ProgressDialog(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dialog.setMessage("获取用户支付状态中,请稍后..."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        dialog.setCancelable(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HuaweiPay.getInstance().authForMonth(new CallbackListener<AuthResult>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void callback(int i, AuthResult authResult) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(i == ErrorCode.COM_PLATFORM_SUCCESS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                   new LocalStore(DjblMainActivity.this).saveIsVip(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    new LocalStore(DjblMainActivity.this).saveIsVip(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                DjblMainActivity.this.runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        dialog.dismiss(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(!isPlayPay){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    reloadUrl(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public static String replaceAccessTokenReg(String url, String name, String accessToken) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        url = url.replaceAll("(" + name + "=[^&]*)", name + "=" + accessToken); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String transUrl(String url){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(url.contains("is_vip=")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            url = replaceAccessTokenReg(url,"is_vip",new LocalStore(DjblMainActivity.this).getIsVip()?"true":"false"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            url = url + "&is_vip=" + (new LocalStore(DjblMainActivity.this).getIsVip()?"true":"false"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(!url.contains("uid=")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            url = url+ "&uid=" + userId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return url; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void reloadUrl(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        this.runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String url = transUrl(DjblMainActivity.this.backUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                webview.loadUrl(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void onActivityResult(int requestCode,int resultCode,final Intent data){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.onActivityResult(requestCode,resultCode,data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(requestCode == requestPlayCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            onJsFresh(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(resultCode == responsePlayCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Log.d(TAG,"视频跳转计费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                isPlayPay = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gotoPayActivity(userId,buyProductId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else if(requestCode == requestPayCode){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            onJsFresh(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            authAfterPay(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void gotoPayActivity(String userId,String buyProductId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Intent intent = new Intent(this,PayActivity.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        intent.putExtra("userId",userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        intent.putExtra("buyProductId",buyProductId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        startActivityForResult(intent,requestPayCode); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void onCreate(Bundle savedInstanceState) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.onCreate(savedInstanceState); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        setContentView(R.layout.activity_main); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        FrameLayout frameLayout = findViewById(R.id.webview_container); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview = new WebView(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        frameLayout.addView(webview,new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.setVisibility(View.INVISIBLE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        prepare(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void saveLoginUser(String userId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String requestUrl = "http://202.99.114.74:56199/index.php?m=Home&c=DuduApi&a=addUser" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    + "&uid=" + userId 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    + "&UserToken=dudutoken" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    +"&originId" + 2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        RequestQueue queue = Volley.newRequestQueue(this); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        queue.add(new JsonObjectRequest(Request.Method.GET, requestUrl, null, new Response.Listener<JSONObject>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void onResponse(JSONObject response) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }, new Response.ErrorListener() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void onErrorResponse(VolleyError error) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        })); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void loadH5Url(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String url = "http://202.99.114.74:56251/h5v2/tribeapp_test/index.html?is_vip=%s&uid=%s"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        url = String.format(url,new LocalStore(DjblMainActivity.this).getIsVip(),userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.getSettings().setJavaScriptEnabled(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.setWebChromeClient(new WebChromeClient() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void onProgressChanged(WebView view, int progress) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                DjblMainActivity.this.setProgress(progress * 1000); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.setWebViewClient(new WebViewClient() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void onPageFinished(WebView view, String url) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                super.onPageFinished(view, url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                webview.setVisibility(View.VISIBLE); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Toast("Oh no! "); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.addJavascriptInterface(new AndroidToJs(h5Result,myPayResult),"H5Play"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        webview.loadUrl(url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void prepare(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HuaweiPay.getInstance().init(this, new CallbackListener<Integer>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void callback(final int paramInt, final Integer paramT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                switch (paramInt){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    case ErrorCode.COM_PLATFORM_SUCCESS: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //Toast("初始化成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        HuaweiPay.getInstance().authForMonth(new CallbackListener<AuthResult>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            public void callback(int i, AuthResult authResult) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                switch (i){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    case ErrorCode.COM_PLATFORM_SUCCESS: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        new LocalStore(DjblMainActivity.this).saveIsVip(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(authResult!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            Toast(authResult.description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            Log.i(TAG,authResult.description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        runH5(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    case ErrorCode.COM_PLATFORM_ERROR_PARAM: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        new LocalStore(DjblMainActivity.this).saveIsVip(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(authResult!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            getBuyProductId(authResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        runH5(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        Log.i(TAG,"参数错误,description:" + authResult.description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    case ErrorCode.COM_PLATFORM_ERROR_UNKNOWN: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        new LocalStore(DjblMainActivity.this).saveIsVip(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(authResult!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            getBuyProductId(authResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        runH5(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        Log.i(TAG,"SDK未初始化及其它错误,description:" + authResult.description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        new LocalStore(DjblMainActivity.this).saveIsVip(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        if(authResult!=null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            getBuyProductId(authResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        runH5(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        Log.i(TAG,"其他错误,description:" + authResult.description); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        userId = HuaweiPay.getInstance().getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        saveLoginUser(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        new LocalStore(DjblMainActivity.this).saveUserId(userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    case ErrorCode.COM_PLATFORM_ERROR_ONLINE_CHECK_FAILURE: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Log.i(TAG,"无网络"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        CrashHandler.getInstance().saveCrashInfoToWeb("初始化失败,无网络"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onInitFail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    case ErrorCode.COM_PLATFORM_ERROR_FORCE_CLOSE: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Log.i(TAG,"初始化异常,强制退出"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        CrashHandler.getInstance().saveCrashInfoToWeb("初始化异常,强制退出"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onInitFail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    case ErrorCode.COM_PLATFORM_ERROR_TIME_OUT: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //Toast(DjblMainActivity.this,"网络超时:" + paramInt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Log.i(TAG,"网络超时"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        CrashHandler.getInstance().saveCrashInfoToWeb("初始化失败,网络超时"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onInitFail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        Log.i(TAG,"其他错误:" + paramInt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        CrashHandler.getInstance().saveCrashInfoToWeb("初始化失败,其他错误:" + paramInt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onInitFail(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void onInitFail(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                new AlertDialog.Builder(DjblMainActivity.this) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .setMessage("初始化失败,点击'确定'退出") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .setPositiveButton("确定",new DialogInterface.OnClickListener(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            public void onClick(DialogInterface dialog, int which) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                DjblMainActivity.this.finish(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        }).show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void getBuyProductId(@NonNull AuthResult authResult){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(authResult.productInfos.length>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            buyProductId = authResult.productInfos[0].productId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Log.d(TAG," buyProductId:" + buyProductId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //Toast("计费产品ID:" + buyProductId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+       }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            CrashHandler.getInstance().saveCrashInfoToWeb("计费失败,未检测到产品列表,用户ID:" + userId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Toast("没有检测到产品列表,不能发起计费!"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void monthPay(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Logger("开始计费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                HuaweiPay.getInstance().payForMonth(DjblMainActivity.this,userId,buyProductId,new CallbackListener<PayResult>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    public void callback(final int arg0, PayResult arg1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        switch(arg0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case ErrorCode.COM_PLATFORM_SUCCESS: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                       /* Log.i(TAG,"计费成功,用户ID:" + arg1.getUin() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                +";流水号:" + arg1.getConsumeStreamId() + ";商户收入:" + arg1.getShare());*/ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                Log.d(TAG,"鉴权成功"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                myPayResult.onSuccess(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case ErrorCode.COM_PLATFORM_ERROR_PARAM: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                myPayResult.onFail("参数错误"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case ErrorCode.COM_PLATFORM_ERROR_UNKNOWN: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                myPayResult.onFail("SDK未初始化及其它错误,tradeStatus:" + arg1.getTradeStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            case ErrorCode.COM_PLATFORM_ERROR_PAY_CANCEL: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                myPayResult.onFail("用户取消" + arg1.getTradeStatus()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                myPayResult.onFail("计费未知错误:" + arg0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (null != arg1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Logger.d(TAG, "unipayExt PayResult : "+ arg1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void runH5(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                loadH5Url(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void Toast(final String msg){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DjblMainActivity.this.runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Toast.makeText(DjblMainActivity.this,msg,Toast.LENGTH_SHORT).show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public class AndroidToJs{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        H5Result listener; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        MyPayResult payResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public AndroidToJs(H5Result h5Result,MyPayResult payResult){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.listener = h5Result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            this.payResult = payResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void play(final String url,final String title,final String sourceId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            listener.videoPlay(url,title,userId,sourceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void pay(String backUrl){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //Toast.makeText(DjblMainActivity.this,"开始计费",Toast.LENGTH_SHORT).show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Log.d(TAG,"限时订购计费"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DjblMainActivity.this.backUrl = backUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            gotoPayActivity(userId,buyProductId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public int getScreenWidth(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return getWindowManager().getDefaultDisplay().getWidth(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void exit(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //todo run in ui thread 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            DjblMainActivity.this.runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    new AlertDialog.Builder(DjblMainActivity.this) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .setMessage("确认退出!") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            .setPositiveButton("继续观看", new DialogInterface.OnClickListener() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                public void onClick(DialogInterface dialog, int which) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }).setNegativeButton("立即退出", new DialogInterface.OnClickListener() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        public void onClick(DialogInterface dialog, int which) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            DjblMainActivity.this.finish(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }).show(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void jsAuth(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            HuaweiPay.getInstance().authForMonth(new CallbackListener<AuthResult>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                public void callback(int i, AuthResult authResult) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(i == ErrorCode.COM_PLATFORM_SUCCESS){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onAuthResult(1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        onAuthResult(-1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public int  getVipState(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            boolean vipState = new LocalStore(DjblMainActivity.this).getIsVip(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return vipState?1:-1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        @JavascriptInterface 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public String getUserId(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String userId = new LocalStore(DjblMainActivity.this).getUserId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return userId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    protected void onDestroy(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //清空所有Cookie 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CookieSyncManager.createInstance(this);  //Create a singleton CookieSyncManager within a context 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CookieManager cookieManager = CookieManager.getInstance(); // the singleton CookieManager instance 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        cookieManager.removeAllCookie();// Removes all cookies. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        CookieSyncManager.getInstance().sync(); // forces sync manager to sync now 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(webview != null){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearCache(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearFormData(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearMatches(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearSslPreferences(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearDisappearingChildren(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearHistory(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearAnimation(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.loadUrl("about:blank"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.removeAllViews(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.freeMemory(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.setWebChromeClient(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.setWebViewClient(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.getSettings().setJavaScriptEnabled(false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.clearCache(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HuaweiPay.getInstance().onDestroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        super.onDestroy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void onBackPressed() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        onJsBack(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void onJsBack(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        final int version = Build.VERSION.SDK_INT; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(version>18){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.evaluateJavascript("javascript:onBack()", new ValueCallback<String>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                public void onReceiveValue(String value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //此处为 js 返回的结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.loadUrl("javascript:onBack()"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void onJsFresh(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        final int version = Build.VERSION.SDK_INT; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(version>18){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.evaluateJavascript("javascript:myrefresh()", new ValueCallback<String>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                public void onReceiveValue(String value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //此处为 js 返回的结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.loadUrl("javascript:myrefresh()"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void onPlayBackPay(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        final int version = Build.VERSION.SDK_INT; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(version>18){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.evaluateJavascript("javascript:onPlayBackPay()", new ValueCallback<String>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                public void onReceiveValue(String value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    //此处为 js 返回的结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            webview.loadUrl("javascript:onPlayBackPay()"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private void onAuthResult(final int i){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DjblMainActivity.this.runOnUiThread(new Runnable() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            public void run() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                final int version = Build.VERSION.SDK_INT; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                String script = "javascript:onAuthResult(" + i +")"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if(version>18){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    webview.evaluateJavascript(script, new ValueCallback<String>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        public void onReceiveValue(String value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            //此处为 js 返回的结果 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    webview.loadUrl(script); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public interface H5Result { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void videoPlay(String url,String title,String uId,String sourceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public interface MyPayResult{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void onSuccess(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        public void onFail(String msg); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 |