|
|
@@ -1,6 +1,7 @@
|
|
|
package com.sheep.gamegroup.view.activity;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
+import android.os.Bundle;
|
|
|
import android.support.annotation.StringDef;
|
|
|
import android.support.v7.widget.AppCompatEditText;
|
|
|
import android.text.InputFilter;
|
|
|
@@ -11,6 +12,7 @@ import android.widget.TextView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
+import com.sheep.gamegroup.event.WXLoginAuthEvent;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
import com.sheep.gamegroup.model.util.SheepSubscriber;
|
|
|
import com.sheep.gamegroup.util.CommonUtil;
|
|
|
@@ -18,16 +20,22 @@ import com.sheep.gamegroup.util.DataUtil;
|
|
|
import com.sheep.gamegroup.util.SelfCountDownTimer;
|
|
|
import com.sheep.gamegroup.util.StringUtils;
|
|
|
import com.sheep.jiuyan.samllsheep.BuildConfig;
|
|
|
+import com.sheep.jiuyan.samllsheep.Config;
|
|
|
import com.sheep.jiuyan.samllsheep.R;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
|
|
|
+import com.sheep.jiuyan.samllsheep.wxutil.WXAPIUtil;
|
|
|
import com.umeng.socialize.UMAuthListener;
|
|
|
import com.umeng.socialize.UMShareAPI;
|
|
|
import com.umeng.socialize.bean.SHARE_MEDIA;
|
|
|
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
+
|
|
|
import java.lang.annotation.Retention;
|
|
|
import java.lang.annotation.RetentionPolicy;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -52,6 +60,12 @@ public class ActModifyThird extends BaseActivity {
|
|
|
AppCompatEditText modifyThirdCodeEt;
|
|
|
|
|
|
@Override
|
|
|
+ protected void onCreate(Bundle b){
|
|
|
+ super.onCreate(b);
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
protected int getLayoutId() {
|
|
|
return R.layout.act_modify_third;
|
|
|
}
|
|
|
@@ -272,6 +286,24 @@ public class ActModifyThird extends BaseActivity {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ @Subscribe
|
|
|
+ public void whenWXAuth(WXLoginAuthEvent ev){
|
|
|
+ if (!TextUtils.isEmpty(ev.code)) {
|
|
|
+ WXAPIUtil.loadWXUserToken(ev.code, (ret, openid, accessToken, refreshToken) -> {
|
|
|
+ if (TextUtils.isEmpty(openid)) return;
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("access_token", accessToken);
|
|
|
+ params.put("refresh_token", refreshToken);
|
|
|
+ params.put("openid", openid);
|
|
|
+ params.put("account_type", "wx");
|
|
|
+ params.put("app_id", Config.WX_AUTH_APP_ID);
|
|
|
+ modifyThird("wechat", accessToken, openid);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ G.shortToast("微信授权失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* aaccess_token string
|
|
|
* authorization_code string
|
|
|
@@ -282,7 +314,10 @@ public class ActModifyThird extends BaseActivity {
|
|
|
* sheep, web_sheep
|
|
|
*/
|
|
|
private void modifyThird(String platform, String access_token, String openid) {
|
|
|
- if (TextUtils.isEmpty(openid)) return;
|
|
|
+ if (TextUtils.isEmpty(openid)) {
|
|
|
+ hideProgress();
|
|
|
+ return;
|
|
|
+ }
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("access_token", access_token);
|
|
|
jsonObject.put("authorization_code", authorization_code);
|
|
|
@@ -321,6 +356,7 @@ public class ActModifyThird extends BaseActivity {
|
|
|
|
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
|
if (selfCountDownTimer != null)
|
|
|
selfCountDownTimer.cancel();
|
|
|
super.onDestroy();
|