导航菜单

页面标题

页面副标题

Credmex v3.12.2 - ForgetPasswordStepOneActivity.java 源代码

正在查看: Credmex v3.12.2 应用的 ForgetPasswordStepOneActivity.java JAVA 源代码文件

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


package com.credmex.activity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import butterknife.BindView;
import butterknife.OnClick;
import com.credmex.activity.ForgetPasswordStepOneActivity;
import com.credmex.commom.BaseRegisterOrLoginActivity;
import com.credmex.manager.SMSTokenManager;
import com.credmex.models.YqdMobileVerificationPurpose;
import com.credmex.models.response.MobileSendVerificationResponse;
import com.credmex.models.response.UserGenerateCaptchaResponse;
import com.credmex.net.CredMexObserver;
import com.credmex.net.CredMexResponseCode;
import com.credmex.net.IApiRoutes;
import com.credmex.track.ThirdPartEventUtils;
import com.credmex.track.ThirdPartTrackEvents;
import com.credmex.track.ThirdPartTrackLib;
import com.credmex.utils.KeyboardListener.SoftKeyboardStateHelper;
import com.credmex.utils.PhoneUtil;
import com.credmex.widght.editTextBridge.DefaultTextWatcher;
import com.open.mx.ui.views.button.PrimaryButton;
import com.veda.android.bananalibrary.infrastructure.BaseActivity;
import com.veda.android.bananalibrary.net.ICallBack;
import com.veda.android.imageloaderlib.IImageLoader;
import com.veda.android.imageloaderlib.Imager;
import com.veda.supertoolkit.lifecycle.LifecycleEvent;
import com.veda.supertoolkit.widgets.BaseUtils;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.sentry.ISpan;
import io.sentry.SpanStatus;

public class ForgetPasswordStepOneActivity extends BaseRegisterOrLoginActivity {
    private final int E = 4;
    private String F;
    private String G;
    private boolean H;

    @BindView(2131361953)
    PrimaryButton btnNextStep;

    @BindView(2131362177)
    EditText etGraphCaptcha;

    @BindView(2131362181)
    EditText etPhoneNumber;

    @BindView(2131362330)
    ImageView ivDeletePhoneNumber;

    @BindView(2131362346)
    ImageView ivGraphCaptcha;

    @BindView(2131362461)
    LinearLayout llContainer;

    @BindView(2131362520)
    LinearLayout llPhoneNum;

    @BindView(2131362483)
    LinearLayout llRootView;

    class AnonymousClass4 extends CredMexObserver<MobileSendVerificationResponse> {
        final ISpan a;

        AnonymousClass4(ICallBack iCallBack, ISpan iSpan) {
            super(iCallBack);
            this.a = iSpan;
        }

        public void b() {
            ForgetPasswordStepOneActivity forgetPasswordStepOneActivity = ForgetPasswordStepOneActivity.this;
            forgetPasswordStepOneActivity.showSoftInput(forgetPasswordStepOneActivity.etGraphCaptcha);
        }

        @Override
        public void onError(Throwable th, MobileSendVerificationResponse mobileSendVerificationResponse) {
            super.onError(th, (Throwable) mobileSendVerificationResponse);
            ISpan iSpan = this.a;
            if (iSpan != null) {
                ForgetPasswordStepOneActivity.this.e0(iSpan, mobileSendVerificationResponse.getErrorMsg());
            }
            if (mobileSendVerificationResponse.status.code == CredMexResponseCode.INVALID_CAPTCHA.code) {
                ForgetPasswordStepOneActivity.this.r0();
                ForgetPasswordStepOneActivity.this.D0();
                ForgetPasswordStepOneActivity.this.etGraphCaptcha.postDelayed(new Runnable() {
                    @Override
                    public final void run() {
                        ForgetPasswordStepOneActivity.AnonymousClass4.this.b();
                    }
                }, 500L);
            }
        }

        public void onSuccess(MobileSendVerificationResponse mobileSendVerificationResponse) {
            ForgetPasswordStepOneActivity.this.dismissLoadingDialog();
            ISpan iSpan = this.a;
            if (iSpan != null) {
                iSpan.n(SpanStatus.OK);
            }
            ForgetPasswordStepOneActivity.this.z0();
        }
    }

    public void A0() {
        this.F = null;
        this.ivGraphCaptcha.setImageDrawable(ContextCompat.getDrawable(this, 2131230925));
        reportFullyDisplayed();
    }

    public void B0(UserGenerateCaptchaResponse userGenerateCaptchaResponse) {
        this.F = userGenerateCaptchaResponse.body;
        Imager.a().c(this, ((BaseActivity) this).appGlobal.a.b() + "api/user/getCaptchaImage/" + this.F, this.ivGraphCaptcha, new IImageLoader.IImageLoaderListener<String>() {
            public boolean b(Exception exc, String str) {
                ForgetPasswordStepOneActivity.this.reportFullyDisplayed();
                return false;
            }

            public boolean a(String str) {
                ForgetPasswordStepOneActivity.this.reportFullyDisplayed();
                return false;
            }
        });
    }

    private void C0() {
        showLoadingDialog();
        String b = SMSTokenManager.b(this);
        ISpan b0 = this.H ? b0() : null;
        ((IApiRoutes) this.apiHelper.a()).w(isLoggedIn() ? this.G : t0(), (isLoggedIn() ? YqdMobileVerificationPurpose.SET_PASSWORD : YqdMobileVerificationPurpose.FORGET_PASSWORD).name(), s0(), this.F, b).a(new AnonymousClass4(this, b0));
    }

    public void D0() {
        ((IApiRoutes) this.apiHelper.a()).X().t(AndroidSchedulers.a()).a(new CredMexObserver<UserGenerateCaptchaResponse>(this) {
            @Override
            public void onError(Throwable th, UserGenerateCaptchaResponse userGenerateCaptchaResponse) {
                super.onError(th, (Throwable) userGenerateCaptchaResponse);
                ForgetPasswordStepOneActivity.this.A0();
            }

            public void onSuccess(UserGenerateCaptchaResponse userGenerateCaptchaResponse) {
                ForgetPasswordStepOneActivity.this.dismissLoadingDialog();
                ForgetPasswordStepOneActivity.this.B0(userGenerateCaptchaResponse);
            }
        });
    }

    public void E0() {
        this.ivDeletePhoneNumber.setVisibility((isLoggedIn() || TextUtils.isEmpty(t0())) ? 8 : 0);
    }

    public void q0() {
        if (TextUtils.isEmpty(t0()) || !(isLoggedIn() || PhoneUtil.g(t0()))) {
            this.btnNextStep.setEnabled(false);
        } else if (TextUtils.isEmpty(s0()) || !y0()) {
            this.btnNextStep.setEnabled(false);
        } else {
            this.btnNextStep.setEnabled(true);
        }
    }

    public void r0() {
        this.etGraphCaptcha.setText("");
        this.F = null;
    }

    private String s0() {
        return this.etGraphCaptcha.getText().toString().trim();
    }

    public static void startForgetPasswordActivityStepOne(Activity activity, @Nullable String str, boolean z) {
        ThirdPartTrackLib.d(activity, ThirdPartTrackEvents.UserLogin.MEX_LOGIN_BTN_FORGETPWD);
        Intent intent = new Intent(activity, (Class<?>) ForgetPasswordStepOneActivity.class);
        intent.putExtra("phoneNumberValue", str);
        intent.putExtra("isInRegisterOrLoginProcess", z);
        activity.startActivityForResult(intent, 1001);
    }

    private String t0() {
        return this.etPhoneNumber.getText().toString().trim();
    }

    private void u0() {
        this.etPhoneNumber.addTextChangedListener(new DefaultTextWatcher() {
            @Override
            public void afterTextChanged(Editable editable) {
                ForgetPasswordStepOneActivity.this.q0();
                ForgetPasswordStepOneActivity.this.E0();
            }
        });
        this.etGraphCaptcha.addTextChangedListener(new DefaultTextWatcher() {
            @Override
            public void afterTextChanged(Editable editable) {
                ForgetPasswordStepOneActivity.this.q0();
            }
        });
    }

    private void v0() {
        boolean isLoggedIn = isLoggedIn();
        this.etPhoneNumber.setFocusable(!isLoggedIn);
        this.etPhoneNumber.setFocusableInTouchMode(!isLoggedIn);
        this.etPhoneNumber.setLongClickable(!isLoggedIn);
        this.etPhoneNumber.setInputType(isLoggedIn ? 0 : 2);
        EditText editText = this.etPhoneNumber;
        String str = this.G;
        if (isLoggedIn) {
            str = PhoneUtil.e(str);
        }
        editText.setText(str);
        this.etPhoneNumber.setSelection(this.G.length());
        E0();
        if (isLoggedIn || PhoneUtil.g(this.G)) {
            this.etGraphCaptcha.requestFocus();
        } else {
            this.etPhoneNumber.requestFocus();
        }
    }

    private void w0() {
        ((BaseActivity) this).f.setBackgroundColor(0);
        ((BaseActivity) this).a.setImageResource(2131231041);
    }

    private void x0() {
        setSoftKeyboardStateHelper(this.llRootView, new SoftKeyboardStateHelper.SoftKeyboardStateListener() {
            @Override
            public void a() {
                ForgetPasswordStepOneActivity.this.llContainer.scrollTo(0, 0);
                ForgetPasswordStepOneActivity.this.etPhoneNumber.setCursorVisible(false);
            }

            @Override
            public void b(int i2) {
                ForgetPasswordStepOneActivity.this.etPhoneNumber.setCursorVisible(true);
                int bottom = ForgetPasswordStepOneActivity.this.llRootView.getBottom() - ForgetPasswordStepOneActivity.this.llContainer.getBottom();
                if (bottom < i2) {
                    ForgetPasswordStepOneActivity.this.llContainer.scrollTo(0, i2 - bottom);
                }
            }
        });
    }

    private boolean y0() {
        return s0().length() == 4;
    }

    public void z0() {
        ForgetPasswordStepTwoActivity.startForgetPasswordActivityStepTwo(this, isLoggedIn() ? this.G : t0(), this.H);
        ThirdPartTrackLib.d(this, ThirdPartTrackEvents.UserLogin.MEX_FORGETPWD_BTN_NEXT);
    }

    @Override
    protected void D() {
        D0();
    }

    @Override
    protected void G(@NonNull Bundle bundle) {
        super.G(bundle);
        this.G = bundle.getString("phoneNumberValue", "");
        this.H = bundle.getBoolean("isInRegisterOrLoginProcess");
    }

    @Override
    protected void K() {
        w0();
        x0();
        u0();
        v0();
        ThirdPartEventUtils.f(this.etGraphCaptcha);
        ThirdPartEventUtils.k(this.etPhoneNumber);
        registerHideInputWhenTouchOutside(this.etPhoneNumber, this.llPhoneNum);
    }

    @Override
    protected void X(@NonNull Bundle bundle) {
        super.X(bundle);
        if (!TextUtils.isEmpty(t0())) {
            bundle.putString("phoneNumberValue", t0());
        }
        bundle.putBoolean("isInRegisterOrLoginProcess", this.H);
    }

    @Override
    protected String c0() {
        return "forgetPasswordOne";
    }

    public void doGetVerificationCode() {
        if (!isLoggedIn()) {
            if (TextUtils.isEmpty(t0())) {
                showErrorToast(2131820827);
                return;
            } else if (!PhoneUtil.g(t0())) {
                showErrorToast(2131820828);
                return;
            }
        }
        if (TextUtils.isEmpty(s0())) {
            showErrorToast(2131821117);
        } else if (y0()) {
            ThirdPartTrackLib.d(this, ThirdPartTrackEvents.UserLogin.MEX_FORGETPWD_BTN_SUBMITPICCODE);
            C0();
        }
    }

    @Override
    public int getLayoutID() {
        return 2131558637;
    }

    @OnClick({2131362346, 2131361953, 2131362413, 2131362330})
    public void onViewClick(View view) {
        if (BaseUtils.b()) {
        }
        switch (view.getId()) {
            case 2131361953:
                doGetVerificationCode();
                break;
            case 2131362330:
                this.G = "";
                this.etPhoneNumber.setText("");
                this.etPhoneNumber.requestFocus();
                break;
            case 2131362346:
                refreshCaptcha();
                break;
            case 2131362413:
                B();
                break;
        }
    }

    public void refreshCaptcha() {
        this.ivGraphCaptcha.setImageDrawable(null);
        D0();
        ThirdPartTrackLib.d(this, ThirdPartTrackEvents.UserLogin.MEX_FORGETPWD_BTN_REFRESHCODE);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnCreated(@NonNull Runnable runnable) {
        return com.veda.supertoolkit.lifecycle.i.a(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnDestroy(@NonNull Runnable runnable) {
        return com.veda.supertoolkit.lifecycle.i.b(this, runnable);
    }

    @Override
    @SuppressLint({"CheckResult"})
    public Disposable runOnEvent(@NonNull LifecycleEvent lifecycleEvent, @Nullable Runnable runnable) {
        return com.veda.supertoolkit.lifecycle.i.c(this, lifecycleEvent, runnable);
    }
}