导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - PhoneVerifyActivity.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 PhoneVerifyActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.luanxingyuan.app.activity;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import com.luanxingyuan.app.base.AppManager;
import com.luanxingyuan.app.base.BaseActivity;
import com.luanxingyuan.app.base.BaseResponse;
import com.luanxingyuan.app.bean.ChatUserInfo;
import com.luanxingyuan.app.bean.UserCenterBean;
import com.luanxingyuan.app.util.LogUtil;
import com.luanxingyuan.app.util.ParamUtil;
import com.luanxingyuan.app.util.ToastUtil;
import com.luanxingyuan.app.util.VerifyUtils;
import com.tencent.qcloud.tim.uikit.R;
import java.util.HashMap;
import o6.n;
import x8.c0;

public class PhoneVerifyActivity extends BaseActivity {
    private static final String FROM_TYPE = "from_type";
    private boolean isForce;

    @BindView
    EditText mCodeEt;
    private CountDownTimer mCountDownTimer;
    private int mFromType;

    @BindView
    EditText mMobileEt;

    @BindView
    TextView mSendVerifyTv;

    @BindView
    TextView phoneTv;
    private final int NEED_JUMP_TO_YOUNG_MODE = 1;
    private final int FROM_FORGET_PASSWORD = 2;

    class a extends r6.a<BaseResponse<UserCenterBean>> {
        a() {
        }

        public void onResponse(BaseResponse<UserCenterBean> baseResponse, int i8) {
            UserCenterBean userCenterBean;
            if (baseResponse == null || baseResponse.m_istatus != 1 || (userCenterBean = baseResponse.m_object) == null || TextUtils.isEmpty(userCenterBean.t_phone)) {
                return;
            }
            PhoneVerifyActivity.this.mMobileEt.setText(userCenterBean.t_phone);
            PhoneVerifyActivity.this.mMobileEt.setEnabled(false);
        }
    }

    class b extends r6.a<BaseResponse> {

        final String f6714a;

        b(String str) {
            this.f6714a = str;
        }

        public void onBefore(c0 c0Var, int i8) {
            super.onBefore(c0Var, i8);
            PhoneVerifyActivity.this.showLoadingDialog();
        }

        @Override
        public void onError(x8.e eVar, Exception exc, int i8) {
            super.onError(eVar, exc, i8);
            PhoneVerifyActivity.this.dismissLoadingDialog();
            ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821363);
        }

        public void onResponse(BaseResponse baseResponse, int i8) {
            LogUtil.i("修改手机号==--", w0.a.u(baseResponse));
            PhoneVerifyActivity.this.dismissLoadingDialog();
            if (baseResponse == null) {
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821418);
                return;
            }
            if (baseResponse.m_istatus != 1) {
                String str = baseResponse.m_strMessage;
                if (TextUtils.isEmpty(str)) {
                    ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821418);
                    return;
                } else {
                    ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), str);
                    return;
                }
            }
            ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821419);
            if (PhoneVerifyActivity.this.mFromType == 1) {
                YoungModePasswordActivity.startYoungPasswordActivity(PhoneVerifyActivity.this, false);
            } else if (PhoneVerifyActivity.this.mFromType == 2) {
                n.Q(PhoneVerifyActivity.this.getApplicationContext(), "");
            } else {
                Intent intent = new Intent();
                intent.putExtra("phone_modify", this.f6714a);
                PhoneVerifyActivity.this.setResult(-1, intent);
            }
            if (PhoneVerifyActivity.this.isForce) {
                ChatUserInfo k8 = AppManager.f().k();
                k8.t_phone_status = 1;
                n.u(((BaseActivity) PhoneVerifyActivity.this).mContext, k8);
            }
            PhoneVerifyActivity.this.finish();
        }
    }

    class c implements View.OnClickListener {

        final Dialog f6716a;

        c(Dialog dialog) {
            this.f6716a = dialog;
        }

        @Override
        public void onClick(View view) {
            this.f6716a.dismiss();
        }
    }

    class d implements View.OnClickListener {

        final String f6718a;

        final ImageView f6719b;

        d(String str, ImageView imageView) {
            this.f6718a = str;
            this.f6719b = imageView;
        }

        @Override
        public void onClick(View view) {
            com.bumptech.glide.b.x(PhoneVerifyActivity.this).p(this.f6718a).f(w2.j.f17953b).l0(true).G0(this.f6719b);
        }
    }

    class e implements View.OnClickListener {

        final EditText f6721a;

        final String f6722b;

        final Dialog f6723c;

        e(EditText editText, String str, Dialog dialog) {
            this.f6721a = editText;
            this.f6722b = str;
            this.f6723c = dialog;
        }

        @Override
        public void onClick(View view) {
            String trim = this.f6721a.getText().toString().trim();
            if (TextUtils.isEmpty(trim)) {
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821180);
            } else {
                PhoneVerifyActivity.this.checkVerifyCode(trim, this.f6722b);
                this.f6723c.dismiss();
            }
        }
    }

    class f extends r6.a<BaseResponse> {

        final String f6725a;

        f(String str) {
            this.f6725a = str;
        }

        @Override
        public void onError(x8.e eVar, Exception exc, int i8) {
            super.onError(eVar, exc, i8);
            ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821462);
        }

        public void onResponse(BaseResponse baseResponse, int i8) {
            if (baseResponse == null || baseResponse.m_istatus != 1) {
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821462);
            } else {
                PhoneVerifyActivity.this.sendSmsVerifyCode(this.f6725a);
            }
        }
    }

    class g extends r6.a<BaseResponse> {
        g() {
        }

        public void onBefore(c0 c0Var, int i8) {
            super.onBefore(c0Var, i8);
            PhoneVerifyActivity.this.showLoadingDialog();
        }

        @Override
        public void onError(x8.e eVar, Exception exc, int i8) {
            super.onError(eVar, exc, i8);
            PhoneVerifyActivity.this.dismissLoadingDialog();
            ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821363);
        }

        public void onResponse(BaseResponse baseResponse, int i8) {
            LogUtil.i("获取短信验证码==--", w0.a.u(baseResponse));
            PhoneVerifyActivity.this.dismissLoadingDialog();
            if (baseResponse != null && baseResponse.m_istatus == 1) {
                String str = baseResponse.m_strMessage;
                if (TextUtils.isEmpty(str) || !str.contains(PhoneVerifyActivity.this.getResources().getString(2131821294))) {
                    return;
                }
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821295);
                PhoneVerifyActivity.this.startCountDown();
                return;
            }
            if (baseResponse == null || baseResponse.m_istatus != 0) {
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821290);
                return;
            }
            String str2 = baseResponse.m_strMessage;
            if (TextUtils.isEmpty(str2)) {
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), 2131821290);
            } else {
                ToastUtil.showToast(PhoneVerifyActivity.this.getApplicationContext(), str2);
            }
        }
    }

    class h extends CountDownTimer {
        h(long j8, long j9) {
            super(j8, j9);
        }

        @Override
        public void onFinish() {
            PhoneVerifyActivity.this.mSendVerifyTv.setClickable(true);
            PhoneVerifyActivity phoneVerifyActivity = PhoneVerifyActivity.this;
            phoneVerifyActivity.mSendVerifyTv.setTextColor(phoneVerifyActivity.getResources().getColor(2131099903));
            PhoneVerifyActivity phoneVerifyActivity2 = PhoneVerifyActivity.this;
            phoneVerifyActivity2.mSendVerifyTv.setBackgroundColor(phoneVerifyActivity2.getResources().getColor(2131099963));
            PhoneVerifyActivity.this.mSendVerifyTv.setText(2131820880);
            if (PhoneVerifyActivity.this.mCountDownTimer != null) {
                PhoneVerifyActivity.this.mCountDownTimer.cancel();
                PhoneVerifyActivity.this.mCountDownTimer = null;
            }
        }

        @Override
        public void onTick(long j8) {
            PhoneVerifyActivity.this.mSendVerifyTv.setText(PhoneVerifyActivity.this.getResources().getString(2131821242) + (j8 / 1000) + PhoneVerifyActivity.this.getResources().getString(2131821277));
        }
    }

    public void checkVerifyCode(String str, String str2) {
        HashMap hashMap = new HashMap();
        hashMap.put("phone", str2);
        hashMap.put("verifyCode", str);
        x7.a.h().c(m6.a.D0()).e("param", ParamUtil.getParam(hashMap)).f().c(new f(str));
    }

    private void finishVerify() {
        String trim = this.mMobileEt.getText().toString().trim();
        if (TextUtils.isEmpty(trim)) {
            ToastUtil.showToast(getApplicationContext(), 2131821148);
            return;
        }
        if (!VerifyUtils.isPhoneNum(trim)) {
            ToastUtil.showToast(getApplicationContext(), 2131821464);
            return;
        }
        String trim2 = this.mCodeEt.getText().toString().trim();
        if (TextUtils.isEmpty(trim2)) {
            ToastUtil.showToast(getApplicationContext(), 2131821415);
            return;
        }
        String d02 = this.mFromType == 2 ? m6.a.d0() : m6.a.o1();
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        hashMap.put("phone", trim);
        hashMap.put("smsCode", trim2);
        x7.a.h().c(d02).e("param", ParamUtil.getParam(hashMap)).f().c(new b(trim));
    }

    private void getInfo() {
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        x7.a.h().c(m6.a.M0()).e("param", ParamUtil.getParam(hashMap)).f().c(new a());
    }

    private void initStart() {
        int intExtra = getIntent().getIntExtra(FROM_TYPE, 0);
        this.mFromType = intExtra;
        if (intExtra == 2) {
            getInfo();
        }
        boolean booleanExtra = getIntent().getBooleanExtra("force", false);
        this.isForce = booleanExtra;
        if (booleanExtra) {
            setTitle("请绑定手机号");
            this.mLeftFl.setVisibility(8);
        }
        String stringExtra = getIntent().getStringExtra("phone");
        if (TextUtils.isEmpty(stringExtra)) {
            return;
        }
        this.phoneTv.setText(String.format("* 当前已绑定手机号:%s\n* 如需更换手机号请重新验证", stringExtra));
        this.phoneTv.setVisibility(0);
    }

    public void sendSmsVerifyCode(String str) {
        String trim = this.mMobileEt.getText().toString().trim();
        if (TextUtils.isEmpty(trim)) {
            ToastUtil.showToast(getApplicationContext(), 2131821148);
            return;
        }
        if (!VerifyUtils.isPhoneNum(trim)) {
            ToastUtil.showToast(getApplicationContext(), 2131821464);
            return;
        }
        String str2 = this.mFromType == 2 ? "3" : "2";
        HashMap hashMap = new HashMap();
        hashMap.put("phone", trim);
        hashMap.put("resType", str2);
        hashMap.put("verifyCode", str);
        x7.a.h().c(m6.a.h1()).e("param", ParamUtil.getParam(hashMap)).f().c(new g());
    }

    private void setVerifyDialogView(View view, Dialog dialog, String str) {
        ((ImageView) view.findViewById(2131296453)).setOnClickListener(new c(dialog));
        ImageView imageView = (ImageView) view.findViewById(2131296519);
        String str2 = m6.a.C0() + str;
        com.bumptech.glide.b.x(this).p(str2).f(w2.j.f17953b).l0(true).G0(imageView);
        ((TextView) view.findViewById(2131296465)).setOnClickListener(new d(str2, imageView));
        ((TextView) view.findViewById(2131296538)).setOnClickListener(new e((EditText) view.findViewById(2131296517), str, dialog));
    }

    private void showVerifyDialog() {
        String trim = this.mMobileEt.getText().toString().trim();
        if (TextUtils.isEmpty(trim)) {
            ToastUtil.showToast(getApplicationContext(), 2131821148);
            return;
        }
        if (!VerifyUtils.isPhoneNum(trim)) {
            ToastUtil.showToast(getApplicationContext(), 2131821464);
            return;
        }
        Dialog dialog = new Dialog(this, 2131886281);
        View inflate = LayoutInflater.from(this).inflate(2131493083, (ViewGroup) null);
        setVerifyDialogView(inflate, dialog, trim);
        dialog.setContentView(inflate);
        Point point = new Point();
        getWindowManager().getDefaultDisplay().getSize(point);
        Window window = dialog.getWindow();
        if (window != null) {
            window.getAttributes().width = point.x;
            window.setGravity(17);
        }
        dialog.setCanceledOnTouchOutside(true);
        if (isFinishing()) {
            return;
        }
        dialog.show();
    }

    public static void start(Context context, String str) {
        Intent intent = new Intent(context, (Class<?>) PhoneVerifyActivity.class);
        intent.putExtra(FROM_TYPE, 0);
        intent.putExtra("phone", str);
        context.startActivity(intent);
    }

    public void startCountDown() {
        this.mSendVerifyTv.setClickable(false);
        this.mSendVerifyTv.setTextColor(getResources().getColor(R.color.white));
        this.mSendVerifyTv.setBackgroundResource(2131231539);
        this.mCountDownTimer = new h(60000L, 1000L).start();
    }

    public static void startPhoneVerifyActivity(Context context, int i8) {
        Intent intent = new Intent(context, (Class<?>) PhoneVerifyActivity.class);
        intent.putExtra(FROM_TYPE, i8);
        context.startActivity(intent);
    }

    @Override
    protected View getContentView() {
        return inflate(2131492941);
    }

    @Override
    public void onBackPressed() {
        if (this.isForce) {
            return;
        }
        super.onBackPressed();
    }

    @OnClick
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131296683) {
            finishVerify();
        } else {
            if (id != 2131296711) {
                return;
            }
            showVerifyDialog();
        }
    }

    @Override
    protected void onContentAdded() {
        setTitle(2131821150);
        initStart();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        CountDownTimer countDownTimer = this.mCountDownTimer;
        if (countDownTimer != null) {
            countDownTimer.cancel();
            this.mCountDownTimer = null;
        }
    }
}