| | |
| | | import android.content.DialogInterface; |
| | | import android.content.Intent; |
| | | import android.content.SharedPreferences; |
| | | |
| | | import androidx.databinding.BindingAdapter; |
| | | import androidx.databinding.DataBindingUtil; |
| | | |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.drawable.BitmapDrawable; |
| | | import android.net.Uri; |
| | |
| | | import android.os.Bundle; |
| | | import android.os.Environment; |
| | | import android.provider.MediaStore; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import android.util.Log; |
| | | import android.view.Gravity; |
| | | import android.view.View; |
| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.tejia.lijin.app.entity.common.GoodsConvertLinkJumpLink; |
| | | import com.tejia.lijin.app.ui.dialog.ShapeLoadingDialog; |
| | | import com.tejia.lijin.app.util.GoodsBuyJumpUtil; |
| | | import com.tejia.lijin.app.util.user.UserUtil; |
| | | import com.tencent.mm.opensdk.modelmsg.SendAuth; |
| | | import com.wpc.library.util.common.DimenUtils; |
| | | import com.wpc.library.util.common.StringUtils; |
| | |
| | | |
| | | private String fansCountLink; |
| | | |
| | | //拼多多是否备案 |
| | | private Boolean pddBuyBind; |
| | | private Boolean pddShareBind; |
| | | |
| | | protected ShapeLoadingDialog loading = null; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | |
| | | // tv_middle.setText("我的信息"); |
| | | binding.includeTopBar.tvTopBarLeft.setOnClickListener(this); |
| | | binding.llInfoSex.setOnClickListener(this); |
| | | binding.llInfoWchatNum.setOnClickListener(this); |
| | | binding.llInfoPortrait.setOnClickListener(this); |
| | | binding.llInfoNickname.setOnClickListener(this); |
| | | binding.llInfoRelativeQq.setOnClickListener(this); |
| | |
| | | binding.llInfoRelativeWechat.setOnClickListener(this); |
| | | binding.llInfoRelativeMobile.setOnClickListener(this); |
| | | binding.llInfoInviteCode.setOnClickListener(this); |
| | | binding.llInfoVip.setOnClickListener(this); |
| | | binding.llInfoFans.setOnClickListener(this); |
| | | binding.llInfoPddBuy.setOnClickListener(this); |
| | | binding.llInfoPddShare.setOnClickListener(this); |
| | | |
| | | |
| | | binding.tvInfoUid.setOnLongClickListener(new View.OnLongClickListener() { |
| | | @Override |
| | | public boolean onLongClick(View v) { |
| | |
| | | return false; |
| | | } |
| | | }); |
| | | binding.llVipAction.setOnClickListener(this); |
| | | mPermissionsChecker = new PermissionHelper(this, this);//权限 |
| | | |
| | | loading = new ShapeLoadingDialog.Builder(this).build(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onClick(View view) { |
| | | Boolean buy = null; |
| | | switch (view.getId()) { |
| | | case R.id.tv_top_bar_left: |
| | | finish(); |
| | | break; |
| | | case R.id.ll_info_relative_wechat: |
| | | if(info==null) |
| | | case R.id.ll_info_relative_wechat: { |
| | | if (info == null) |
| | | return; |
| | | String title = "更换微信帐号"; |
| | | String message = "确定更换微信账号"; |
| | |
| | | } |
| | | }).create().show(); |
| | | break; |
| | | } |
| | | |
| | | case R.id.ll_info_relative_qq: { |
| | | if (info == null) |
| | | return; |
| | | String title = "更换QQ帐号"; |
| | | String message = "确定更换QQ帐号"; |
| | | String positive = "更换"; |
| | | if (StringUtils.isEmpty(info.getQqOpenId())) {//QQ |
| | | title = "绑定QQ帐号"; |
| | | message = "确定绑定QQ账号"; |
| | | positive = "绑定"; |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(phoneNum)) { |
| | | title = "更换提醒"; |
| | | message = "该帐号没有绑定手机号,需绑定手机号才能完成QQ更换。"; |
| | | positive = "绑定手机号"; |
| | | } |
| | | AddZFBInfoDialog2.Builder builder1 = new AddZFBInfoDialog2.Builder(MyInfoActivity.this); |
| | | builder1.setTitle(title).setMessage(message) |
| | | .setPositiveButton(positive, new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | if (StringUtils.isEmpty(phoneNum)) { |
| | | bindMobile(); |
| | | } else { |
| | | bindQQ(); |
| | | } |
| | | } |
| | | }).setNegativeButton("不了", new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | } |
| | | }).create().show(); |
| | | break; |
| | | } |
| | | |
| | | case R.id.ll_info_tbaccount: |
| | | String title1 = "更换淘宝账号"; |
| | | String message1 = "确定更换淘宝账号"; |
| | |
| | | message1 = "确定绑定淘宝账号"; |
| | | positive1 = "绑定"; |
| | | } |
| | | |
| | | if (info != null && StringUtils.isEmpty(phoneNum)) { |
| | | title1 = "更换提醒"; |
| | | positive1 = "绑定手机号"; |
| | | message1 = "该帐号没有绑定手机号,需绑定手机号才能完成淘宝更换。"; |
| | | } |
| | | AddZFBInfoDialog2.Builder builder2 = new AddZFBInfoDialog2.Builder(MyInfoActivity.this); |
| | | builder2.setTitle(title1).setMessage(message1) |
| | | .setPositiveButton(positive1, new DialogInterface.OnClickListener() { |
| | | @Override |
| | | public void onClick(DialogInterface dialog, int which) { |
| | | dialog.dismiss(); |
| | | if (StringUtils.isEmpty(phoneNum)) { |
| | | bindMobile(); |
| | | } else { |
| | | bindTB(); |
| | | } |
| | | } |
| | | }).setNegativeButton("不了", new DialogInterface.OnClickListener() { |
| | | @Override |
| | |
| | | case R.id.ll_info_sex://设置性别 |
| | | popwindow_sex();//选择相册 |
| | | break; |
| | | case R.id.ll_info_wchat_num://设置微信号 |
| | | startActivity(new Intent(this, MyWXNumActivity.class) |
| | | .putExtra("weixin", StringUtils.isEmpty(weixin) ? "" : weixin) |
| | | .putExtra("weixintip", weixintip).putExtra("erCode", info.getErCode())); |
| | | break; |
| | | case R.id.ll_info_vip://超级会员信息 |
| | | Intent intent = new Intent(this, ShareBrowserActivity.class); |
| | | intent.putExtra("url", vipLink); |
| | | startActivity(intent); |
| | | break; |
| | | case R.id.ll_info_invite_code://邀请码 |
| | | if (info == null) |
| | | return; |
| | | if (invitCodeUpdated || StringUtils.isEmpty(inviteCode) || !info.isVip()) |
| | | return; |
| | | Intent intent2 = new Intent(this, MyInviteCodeActivity.class); |
| | |
| | | case R.id.ll_info_fans: |
| | | startActivity(new Intent(this, ShareBrowserActivity.class).putExtra("url", fansCountLink)); |
| | | break; |
| | | case R.id.ll_vip_action: |
| | | if (vipAction != null) |
| | | JumpActivityUtil.jumpPage(this, vipAction.getJumpDetail(), vipAction.getParams()); |
| | | |
| | | case R.id.ll_info_pdd_buy: |
| | | buy = true; |
| | | case R.id.ll_info_pdd_share: |
| | | if (buy == null) |
| | | buy = false; |
| | | ShoppingApi.getPDDAuthInfo(getApplicationContext(), UserUtil.getUid(getApplicationContext()) + "", buy, new BasicTextHttpResponseHandler() { |
| | | @Override |
| | | public void onStart() { |
| | | super.onStart(); |
| | | if (loading != null && !loading.isShowing()) |
| | | loading.show(); |
| | | } |
| | | |
| | | @Override |
| | | public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception { |
| | | super.onSuccessPerfect(statusCode, headers, jsonObject); |
| | | if (jsonObject.optInt("code") == 0) { |
| | | JSONObject data = jsonObject.optJSONObject("data"); |
| | | GoodsConvertLinkJumpLink pddJumpLink = new Gson().fromJson(data.toString(), GoodsConvertLinkJumpLink.class); |
| | | GoodsBuyJumpUtil.jumpPDD(getApplicationContext(), pddJumpLink); |
| | | } else { |
| | | Toast.makeText(MyInfoActivity.this, jsonObject.optString("msg"), Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(int statusCode, Header[] headers, String jsonObject, Throwable e) { |
| | | super.onFailure(statusCode, headers, jsonObject, e); |
| | | } |
| | | |
| | | @Override |
| | | public void onFinish() { |
| | | super.onFinish(); |
| | | if (loading != null && loading.isShowing()) |
| | | loading.dismiss(); |
| | | } |
| | | }); |
| | | |
| | | break; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | private void bindQQ() { |
| | | if (ShoppingApplication.application.mWxApi.isWXAppInstalled()) { |
| | | SharedPreferences sp = getSharedPreferences("user", MODE_PRIVATE); |
| | | SharedPreferences.Editor editor = sp.edit(); |
| | | editor.putBoolean("closeHint", false); |
| | | editor.putBoolean("bindqq", true); |
| | | editor.commit(); |
| | | SendAuth.Req req = new SendAuth.Req(); |
| | | req.scope = "snsapi_userinfo"; |
| | | req.state = "rebate"; |
| | | ShoppingApplication.application.mWxApi.sendReq(req); |
| | | } else { |
| | | // SingleToast.showToast(MyInfoActivity.this, "请先安装微信客户端"); |
| | | Toast.makeText(MyInfoActivity.this, "请先安装QQ客户端", Toast.LENGTH_SHORT).show(); |
| | | } |
| | | } |
| | | |
| | | /* |
| | | 绑定淘宝授权 |
| | | */ |
| | |
| | | if (data.optJSONObject("vipAction") != null) { |
| | | vipAction = new Gson().fromJson(data.optJSONObject("vipAction").toString(), VIPActionInfo.class); |
| | | } |
| | | pddBuyBind = data.optBoolean("pddBuyBind"); |
| | | pddShareBind = data.optBoolean("pddShareBind"); |
| | | |
| | | |
| | | String json = data.optJSONObject("user").toString(); |
| | |
| | | } else { |
| | | binding.tvInfoRelativeWechat.setText(info.getWxName()); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(info.getQqOpenId())) {//QQ |
| | | binding.tvInfoRelativeQq.setText("去绑定"); |
| | | } else { |
| | | binding.tvInfoRelativeQq.setText(info.getQqNickName()); |
| | | } |
| | | |
| | | if (StringUtils.isEmpty(info.getOpenid())) {//淘宝 |
| | | binding.tvInfoTbaccount.setText("去绑定"); |
| | | } else { |
| | |
| | | binding.tvInfoRelativeMobile.setText(info.getPhone()); |
| | | } |
| | | |
| | | //信息设置 |
| | | // if (info.isVip()) { |
| | | binding.tvInfoVip.setVisibility(View.GONE); |
| | | // } else { |
| | | // binding.tvInfoVip.setVisibility(View.VISIBLE); |
| | | // } |
| | | |
| | | //邀请码设置 |
| | | if (StringUtils.isEmpty(inviteCode) || !info.isVip()) |
| | | binding.llInfoInviteCode.setVisibility(View.GONE); |
| | | else { |
| | | binding.llInfoInviteCode.setVisibility(View.VISIBLE); |
| | | binding.tvInfoInviteCode.setText(inviteCode); |
| | | if (invitCodeUpdated || !info.isVip()) { |
| | | binding.ivInfoInviteCodeEdit.setVisibility(View.GONE); |
| | | ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams(); |
| | | params.setMargins(0, 0, DimenUtils.dip2px(this, 20), 0); |
| | | binding.tvInfoInviteCode.requestLayout(); |
| | | if (pddBuyBind != null) { |
| | | if (pddBuyBind) { |
| | | binding.tvInfoPddBuy.setText("去更改"); |
| | | } else { |
| | | binding.ivInfoInviteCodeEdit.setVisibility(View.VISIBLE); |
| | | ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams(); |
| | | params.setMargins(0, 0, DimenUtils.dip2px(this, 10), 0); |
| | | binding.tvInfoInviteCode.requestLayout(); |
| | | binding.tvInfoPddBuy.setText("去备案"); |
| | | } |
| | | } else { |
| | | binding.tvInfoPddBuy.setText(""); |
| | | } |
| | | |
| | | binding.llInfoInviteCode.setVisibility(View.GONE); |
| | | if (pddShareBind != null) { |
| | | if (pddShareBind) { |
| | | binding.tvInfoPddShare.setText("去更改"); |
| | | } else { |
| | | binding.tvInfoPddShare.setText("去备案"); |
| | | } |
| | | } else { |
| | | binding.tvInfoPddShare.setText(""); |
| | | } |
| | | |
| | | |
| | | //邀请码设置 |
| | | // if (StringUtils.isEmpty(inviteCode) || !info.isVip()) |
| | | // binding.llInfoInviteCode.setVisibility(View.GONE); |
| | | // else { |
| | | // binding.llInfoInviteCode.setVisibility(View.VISIBLE); |
| | | // binding.tvInfoInviteCode.setText(inviteCode); |
| | | // if (invitCodeUpdated || !info.isVip()) { |
| | | // binding.ivInfoInviteCodeEdit.setVisibility(View.GONE); |
| | | // ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams(); |
| | | // params.setMargins(0, 0, DimenUtils.dip2px(this, 20), 0); |
| | | // binding.tvInfoInviteCode.requestLayout(); |
| | | // } else { |
| | | // binding.ivInfoInviteCodeEdit.setVisibility(View.VISIBLE); |
| | | // ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) binding.tvInfoInviteCode.getLayoutParams(); |
| | | // params.setMargins(0, 0, DimenUtils.dip2px(this, 10), 0); |
| | | // binding.tvInfoInviteCode.requestLayout(); |
| | | // } |
| | | // } |
| | | |
| | | //是否显示邀请人 |
| | | // if (StringUtils.isEmpty(fansCountLink)) { |
| | |
| | | // binding.ivInfoFansEdit.setVisibility(View.VISIBLE); |
| | | // } |
| | | |
| | | //设置会员动作 |
| | | if (vipAction != null) { |
| | | binding.llVipAction.setVisibility(View.VISIBLE); |
| | | binding.tvVipActionName.setText(vipAction.getName()); |
| | | if (vipAction.getContent() != null) |
| | | binding.tvVipActionContent.setText(vipAction.getContent()); |
| | | } else { |
| | | binding.llVipAction.setVisibility(View.GONE); |
| | | } |
| | | |
| | | } |
| | | |