From 2eec3de87b6b616a69a46c1f97c2397159031d2f Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 21 十一月 2023 18:01:43 +0800
Subject: [PATCH] 广告升级/bug修复

---
 BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java |   75 ++++++++++++++++++++++++++++++-------
 1 files changed, 61 insertions(+), 14 deletions(-)

diff --git a/BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java b/BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java
index d33fa1c..0baf482 100644
--- a/BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java
+++ b/BuWanVideo/src/com/doudou/ysvideo/wxapi/WXEntryActivity.java
@@ -1,18 +1,19 @@
 package com.doudou.ysvideo.wxapi;
 
 
-import android.app.Activity;
-import android.app.ProgressDialog;
+import android.app.Dialog;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
-import android.support.annotation.Nullable;
+import androidx.annotation.Nullable;
+
 import android.view.View;
 import android.view.Window;
 import android.view.WindowManager;
 
+import com.lcjian.library.dialog.DialogUtil;
 import com.lcjian.library.util.SingleToast;
 import com.tencent.mm.opensdk.modelbase.BaseReq;
 import com.tencent.mm.opensdk.modelbase.BaseResp;
@@ -22,8 +23,8 @@
 import com.weikou.beibeivideo.BeibeiVideoAPI;
 import com.weikou.beibeivideo.BeibeiVideoApplication;
 import com.weikou.beibeivideo.ui.BaseActivity;
+import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil;
 import com.weikou.beibeivideo.util.UserUtil;
-import com.weikou.beibeivideo.util.novel.NovelJNZUtil;
 
 import org.apache.http.Header;
 import org.json.JSONObject;
@@ -33,7 +34,8 @@
     private static final int RETURN_MSG_TYPE_LOGIN = 1;
     private static final int RETURN_MSG_TYPE_SHARE = 2;
     private static final int RETURN_MSG_TYPE_XCX = 19;
-    private ProgressDialog dialog;
+    private static final int RETURN_MSG_TYPE_BIND = 30;
+    private Dialog dialog;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -50,12 +52,13 @@
         }
         //濡傛灉娌″洖璋僶nResp锛屽叓鎴愭槸杩欏彞娌℃湁鍐�
         BeibeiVideoApplication.application.mWxApi.handleIntent(getIntent(), this);
-        dialog = new ProgressDialog(this);
+        dialog = LoadingDialogUtil.getLoadingDialog(this, "");
     }
 
     // 寰俊鍙戦�佽姹傚埌绗笁鏂瑰簲鐢ㄦ椂锛屼細鍥炶皟鍒拌鏂规硶
     @Override
     public void onReq(BaseReq req) {
+
     }
 
     // 绗笁鏂瑰簲鐢ㄥ彂閫佸埌寰俊鐨勮姹傚鐞嗗悗鐨勫搷搴旂粨鏋滐紝浼氬洖璋冨埌璇ユ柟娉�
@@ -80,16 +83,18 @@
                 switch (resp.getType()) {
                     case RETURN_MSG_TYPE_LOGIN:
                         SendAuth.Resp res = (SendAuth.Resp) resp;
-                        setLogin(res.code);
+                        if ("bind".equalsIgnoreCase(res.state)) {
+                            bind(res.code);
+                        } else {
+                            login(res.code);
+                        }
                         break;
 
                     case RETURN_MSG_TYPE_SHARE:
-//                        UIUtils.showToast("寰俊鍒嗕韩鎴愬姛");
 
                         finish();
                         break;
                     case RETURN_MSG_TYPE_XCX:
-//                        UIUtils.showToast("寰俊鍒嗕韩鎴愬姛");
 
                         finish();
                         break;
@@ -102,12 +107,13 @@
     /**
      * 璇锋眰鏈嶅姟鍣ㄥ尮閰嶉獙璇佺爜
      */
-    private void setLogin(String code) {
+    private void login(String code) {
         BeibeiVideoAPI.wxLogin(this, UserUtil.getUid(this), code, new BasicTextHttpResponseHandler() {
 
             @Override
             public void onStart() {
                 super.onStart();
+                DialogUtil.show(dialog);
                 if (!dialog.isShowing())
                     dialog.show();
             }
@@ -115,8 +121,7 @@
             @Override
             public void onFinish() {
                 super.onFinish();
-                if (dialog.isShowing())
-                    dialog.dismiss();
+                DialogUtil.dismiss(dialog);
             }
 
             @Override
@@ -137,8 +142,6 @@
                             user.optString("sex"));
                     edit.commit();
 
-                    NovelJNZUtil.setUid(getApplicationContext());
-
                     SingleToast.showToast(getApplicationContext(),
                             "鐧诲綍鎴愬姛");
                 } else {
@@ -158,4 +161,48 @@
             }
         });
     }
+
+
+    /**
+     * 璇锋眰鏈嶅姟鍣ㄥ尮閰嶉獙璇佺爜
+     */
+    private void bind(String code) {
+        BeibeiVideoAPI.bindWX(this, UserUtil.getLoginUid(this), code, new BasicTextHttpResponseHandler() {
+
+            @Override
+            public void onStart() {
+                super.onStart();
+                if (!dialog.isShowing())
+                    dialog.show();
+            }
+
+            @Override
+            public void onFinish() {
+                super.onFinish();
+                if (dialog.isShowing())
+                    dialog.dismiss();
+            }
+
+            @Override
+            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
+
+                if (jsonObject.optBoolean("IsPost")) {
+                    SingleToast.showToast(getApplicationContext(),
+                            "寰俊缁戝畾鎴愬姛");
+                } else {
+                    SingleToast.showToast(WXEntryActivity.this,
+                            jsonObject.optString("Error"));
+                }
+                WXEntryActivity.this.finish();
+            }
+
+            @Override
+            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
+                super.onFailure(statusCode, headers, responseString, throwable);
+                SingleToast.showToast(getApplicationContext(),
+                        "寰俊缁戝畾澶辫触");
+                WXEntryActivity.this.finish();
+            }
+        });
+    }
 }

--
Gitblit v1.8.0