From 205a7bba1dbef65c082daa17df82ab8339a5411d Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期五, 05 二月 2021 21:55:24 +0800
Subject: [PATCH] Merge branch '3.7.9' of ssh://193.112.35.168:29418/buwan-android-new into 3.7.9

---
 BuWanVideo/src/com/weikou/beibeivideo/ui/login/PersonInfoActivity.java |  212 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 199 insertions(+), 13 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PersonInfoActivity.java b/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PersonInfoActivity.java
index cc15811..a0e2395 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PersonInfoActivity.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/ui/login/PersonInfoActivity.java
@@ -3,12 +3,14 @@
 import android.annotation.SuppressLint;
 import android.app.Activity;
 import android.app.AlertDialog;
+import android.app.Dialog;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.graphics.Bitmap;
 import android.graphics.BitmapFactory;
+import android.graphics.Color;
 import android.os.Build;
 import android.os.Bundle;
 import android.util.Base64;
@@ -20,16 +22,23 @@
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
+import android.widget.Toast;
 
 import com.bumptech.glide.Glide;
 import com.google.gson.Gson;
 import com.lcjian.library.util.Environment;
 import com.lcjian.library.util.SingleToast;
 import com.lcjian.library.util.common.StringUtils;
+import com.tencent.mm.opensdk.modelmsg.SendAuth;
+import com.umeng.socialize.UMAuthListener;
+import com.umeng.socialize.UMShareAPI;
+import com.umeng.socialize.bean.SHARE_MEDIA;
 import com.weikou.beibeivideo.BasicTextHttpResponseHandler;
 import com.weikou.beibeivideo.BeibeiVideoAPI;
+import com.weikou.beibeivideo.BeibeiVideoApplication;
 import com.weikou.beibeivideo.entity.vo.UserInfoVO;
 import com.weikou.beibeivideo.ui.BaseActivity;
+import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil;
 import com.weikou.beibeivideo.util.BeibeiConstant;
 import com.weikou.beibeivideo.util.GlideCircleTransform;
 import com.weikou.beibeivideo.util.SelectPicUtil;
@@ -46,12 +55,15 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.Calendar;
+import java.util.Map;
 
 /**
  * Created by weikou2015 on 2016/10/27.
  */
 
 public class PersonInfoActivity extends BaseActivity implements View.OnClickListener {
+
+    private String TAG = PersonInfoActivity.class.getSimpleName();
 
     private LinearLayout ll_portrait;
     private LinearLayout ll_nickName;
@@ -64,6 +76,17 @@
     private TextView tv_birthday;
     private TextView tv_sex;
     private TextView tv_autograph;
+
+    private TextView tv_qq;
+    private TextView tv_wx;
+    private TextView tv_phone;
+
+    private TextView tv_bind_qq;
+    private TextView tv_bind_wx;
+    private TextView tv_bind_phone;
+
+    private Dialog loadingDialog;
+
 
     @Override
     protected void onCreate(Bundle arg0) {
@@ -96,14 +119,26 @@
         tv_sex = (TextView) findViewById(R.id.tv_sex);
         tv_autograph = (TextView) findViewById(R.id.tv_autograph);
 
+        tv_qq = findViewById(R.id.tv_qq);
+        tv_wx = findViewById(R.id.tv_wx);
+        tv_phone = findViewById(R.id.tv_phone);
+
+        tv_bind_qq = findViewById(R.id.tv_bind_qq);
+        tv_bind_wx = findViewById(R.id.tv_bind_wx);
+        tv_bind_phone = findViewById(R.id.tv_bind_phone);
+
+
         ll_portrait.setOnClickListener(this);
         ll_nickName.setOnClickListener(this);
         ll_birthday.setOnClickListener(this);
         ll_sex.setOnClickListener(this);
         ll_autograph.setOnClickListener(this);
         findViewById(R.id.tv_back).setOnClickListener(this);
-        findViewById(R.id.tv_top_right).setOnClickListener(this);
-        getPersonInfo();
+        tv_bind_qq.setOnClickListener(this);
+        tv_bind_wx.setOnClickListener(this);
+        tv_bind_phone.setOnClickListener(this);
+        loadingDialog = LoadingDialogUtil.getLoadingDialog(this, "");
+
     }
 
     private String sign = "";
@@ -118,25 +153,89 @@
                 if (jsonObject.optBoolean("IsPost")) {
                     JSONObject data = jsonObject.optJSONObject("Data");
                     UserInfoVO userInfoVO = new Gson().fromJson(data.toString(), UserInfoVO.class);
-
-                    Glide.with(PersonInfoActivity.this).load(BeibeiConstant.addPreFix(userInfoVO.getPortrait())).
-                            placeholder(R.drawable.ic_portrait_default).error(R.drawable.ic_portrait_default).into(iv_portrait);
-                    tv_nickName.setText(userInfoVO.getNickName());
-                    tv_birthday.setText(userInfoVO.getBirthday());
-                    tv_sex.setText(Integer.parseInt(userInfoVO.getSex()) == 0 ? "濂�" : "鐢�");
-                    sign = userInfoVO.getSign();
-                    tv_autograph.setText(sign);
+                    setData(userInfoVO);
                 }
             }
         });
+    }
+
+    private void setData(UserInfoVO userInfoVO) {
+        Glide.with(PersonInfoActivity.this).load(BeibeiConstant.addPreFix(userInfoVO.getPortrait())).
+                placeholder(R.drawable.ic_portrait_default).error(R.drawable.ic_portrait_default).transform(new GlideCircleTransform(getApplicationContext())).into(iv_portrait);
+        if (!StringUtils.isEmpty(userInfoVO.getNickName())) {
+            tv_nickName.setText(userInfoVO.getNickName());
+            tv_nickName.setTextColor(Color.WHITE);
+        } else {
+            tv_nickName.setText("鏈~鍐�");
+            tv_nickName.setTextColor(Color.GRAY);
+        }
+
+
+        if (!StringUtils.isEmpty(userInfoVO.getBirthday())) {
+            tv_birthday.setText(userInfoVO.getBirthday());
+            tv_birthday.setTextColor(Color.WHITE);
+        } else {
+            tv_birthday.setText("鏈~鍐�");
+            tv_birthday.setTextColor(Color.GRAY);
+        }
+
+        if (!StringUtils.isEmpty(userInfoVO.getSex())) {
+            tv_sex.setText(Integer.parseInt(userInfoVO.getSex()) == 0 ? "濂�" : "鐢�");
+            tv_sex.setTextColor(Color.WHITE);
+        } else {
+            tv_sex.setText("鏈~鍐�");
+            tv_sex.setTextColor(Color.GRAY);
+        }
+
+        sign = userInfoVO.getSign();
+
+        if (!StringUtils.isEmpty(userInfoVO.getSign())) {
+            tv_autograph.setText(userInfoVO.getSign());
+            tv_autograph.setTextColor(Color.WHITE);
+        } else {
+            tv_autograph.setText("鏈~鍐�");
+            tv_autograph.setTextColor(Color.GRAY);
+        }
+
+
+        if (!StringUtils.isEmpty(userInfoVO.getQqOpenId())) {
+            tv_qq.setText(userInfoVO.getQqNickName());
+            tv_bind_qq.setVisibility(View.GONE);
+            tv_qq.setVisibility(View.VISIBLE);
+        } else {
+            tv_bind_qq.setVisibility(View.VISIBLE);
+            tv_qq.setVisibility(View.GONE);
+        }
+
+
+        if (!StringUtils.isEmpty(userInfoVO.getWxUnionId())) {
+            tv_wx.setText(userInfoVO.getWxName());
+            tv_bind_wx.setVisibility(View.GONE);
+            tv_wx.setVisibility(View.VISIBLE);
+        } else {
+            tv_bind_wx.setVisibility(View.VISIBLE);
+            tv_wx.setVisibility(View.GONE);
+        }
+
+
+        if (!StringUtils.isEmpty(userInfoVO.getPhone())) {
+            tv_phone.setText(userInfoVO.getPhone());
+            tv_bind_phone.setVisibility(View.GONE);
+            tv_phone.setVisibility(View.VISIBLE);
+        } else {
+            tv_bind_phone.setVisibility(View.VISIBLE);
+            tv_phone.setVisibility(View.GONE);
+        }
+
+
     }
 
     String imgBase64 = "";
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        // TODO Auto-generated method stub
         super.onActivityResult(requestCode, resultCode, data);
+        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
         if (resultCode == Activity.RESULT_OK) {
             Bitmap bm = null;
             bm = SelectPicUtil.onActivityResult(this, requestCode,
@@ -258,8 +357,87 @@
             case R.id.ll_autograph://涓�х鍚�
                 getAutograph();
                 break;
-            case R.id.tv_top_right://瀹屾垚涓汉淇℃伅鐨勪慨鏀�
-                break;
+
+            case R.id.tv_bind_qq:
+                //缁戝畾QQ
+            {
+                if (LoginActivity.isQQClientAvailable(getApplicationContext())) {
+                    // qq鐧诲綍閫昏緫澶勭悊 鐐瑰嚮鐧诲綍鍚庨渶瑕佹殏鏃堕攣瀹氳繑鍥為敭鍜岃繑鍥炲姛鑳� 涓嶇劧浼氭姤閿�
+                    UMShareAPI.get(getApplicationContext()).getPlatformInfo(PersonInfoActivity.this, SHARE_MEDIA.QQ, new UMAuthListener() {
+
+                        @Override
+                        public void onStart(SHARE_MEDIA share_media) {
+                            if (loadingDialog != null && !loadingDialog.isShowing())
+                                loadingDialog.show();
+                        }
+
+                        @Override
+                        public void onComplete(SHARE_MEDIA share_media, int i, Map<String, String> map) {
+                            Log.d(TAG, "onComplete");
+                            if (loadingDialog != null && loadingDialog.isShowing())
+                                loadingDialog.dismiss();
+                            String nickName = map.get("name");
+                            String openid = map.get("openid");
+                            String portrait = map.get("iconurl");
+                            String sex = map.get("gender");
+                            String province = map.get("province");
+                            String city = map.get("city");
+                            if (StringUtils.isEmpty(openid)) {
+                                return;
+                            }
+
+                            BeibeiVideoAPI.bindQQ(PersonInfoActivity.this, UserUtil.getLoginUid(getApplicationContext()), nickName, portrait, openid, new BasicTextHttpResponseHandler() {
+                                @Override
+                                public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
+                                    if (jsonObject.optBoolean("IsPost")) {
+                                        Toast.makeText(PersonInfoActivity.this, "QQ缁戝畾鎴愬姛", Toast.LENGTH_SHORT).show();
+                                        getPersonInfo();
+                                    } else {
+                                        Toast.makeText(PersonInfoActivity.this, jsonObject.optString("Error"), Toast.LENGTH_SHORT).show();
+                                    }
+                                }
+                            });
+                        }
+
+                        @Override
+                        public void onError(SHARE_MEDIA share_media, int i, Throwable throwable) {
+                            throwable.printStackTrace();
+                            Log.d(TAG, "onError");
+                            if (loadingDialog != null && loadingDialog.isShowing())
+                                loadingDialog.dismiss();
+
+                            Toast.makeText(PersonInfoActivity.this, "QQ鎺堟潈鍑洪敊锛岃绋嶅悗鍐嶈瘯", Toast.LENGTH_SHORT).show();
+                        }
+
+                        @Override
+                        public void onCancel(SHARE_MEDIA share_media, int i) {
+                            Log.d(TAG, "onCancel");
+                            if (loadingDialog != null && loadingDialog.isShowing())
+                                loadingDialog.dismiss();
+                        }
+                    });
+                } else {
+                    Toast.makeText(this, "QQ涓嶅彲鐢紝璇锋煡璇㈡墜鏈烘槸鍚﹀畨瑁匭Q...", Toast.LENGTH_LONG).show();
+                }
+            }
+            break;
+            case R.id.tv_bind_wx: {
+                if (LoginActivity.isWXClientAvailable(getApplicationContext())) {
+                    SendAuth.Req req = new SendAuth.Req();
+                    req.scope = "snsapi_userinfo";
+                    req.state = "bind";
+                    BeibeiVideoApplication.application.mWxApi.sendReq(req);
+                } else {
+                    Toast.makeText(this, "寰俊涓嶅彲鐢紝璇锋煡璇㈡墜鏈烘槸鍚﹀畨瑁呭井淇�...", Toast.LENGTH_LONG).show();
+                }
+            }
+            break;
+            case R.id.tv_bind_phone: {
+                Intent intent = new Intent(this, PhoneLoginActivity.class);
+                intent.putExtra("login", false);
+                startActivity(intent);
+            }
+            break;
         }
     }
 
@@ -417,4 +595,12 @@
             }
         });
     }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        getPersonInfo();
+    }
+
+
 }

--
Gitblit v1.8.0