导航菜单

页面标题

页面副标题

WeatherSense v1.8.9 - ChangeActivity.java 源代码

正在查看: WeatherSense v1.8.9 应用的 ChangeActivity.java JAVA 源代码文件

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


package com.emax.weather.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.OnClick;
import com.emax.weahter.R;
import com.emax.weather.base.MvpBaseActivity;
import com.emax.weather.base.ResponseType;
import com.emax.weather.bean.User;
import com.emax.weather.event.UserEvent;
import com.emax.weather.presenter.ChangePwdPresenterImp;
import com.emax.weather.ui.fragment.login.CompleteActivity;
import com.ezon.health.utils_lib.RegexUtils;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.ezon.health.utils_lib.ToastUtil;
import com.google.android.material.textfield.TextInputEditText;
import com.google.android.material.textfield.TextInputLayout;

public class ChangeActivity extends MvpBaseActivity<UserEvent.UserView, ChangePwdPresenterImp> implements UserEvent.UserView {

    @BindView(R.id.back_sub)
    ImageView backSub;

    @BindView(R.id.btn_code_send_pswd)
    Button btnCode;

    @BindView(R.id.code_et_pswd)
    TextInputEditText codeEt;

    @BindView(R.id.email_et)
    TextInputEditText emailEt;

    @BindView(R.id.email_layout)
    TextInputLayout emailLayout;

    @BindView(R.id.llFactoryModule)
    LinearLayout factoryModuleLl;

    @BindView(R.id.new_ag_et)
    TextInputEditText newAgEt;

    @BindView(R.id.new_ag_layout)
    TextInputLayout newAgLayout;

    @BindView(R.id.new_et)
    TextInputEditText newEt;

    @BindView(R.id.new_layout)
    TextInputLayout newLayout;

    @BindView(R.id.setting)
    ImageView setting;

    @BindView(R.id.submit_btn)
    Button submitBtn;

    @BindView(R.id.title_rl)
    RelativeLayout titleRl;

    @BindView(R.id.title_sub)
    TextView titleSub;

    @Override
    protected int getActivityRId() {
        return R.layout.fragment_change;
    }

    @Override
    public Context getContext() {
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.titleSub.setText(getString(R.string.change_pwd));
        if (SharedPreUtils.getInt(this, SharedPre.FactoryUrl.FACTORY_URL, -1) == 0) {
            this.factoryModuleLl.setVisibility(8);
        } else {
            this.factoryModuleLl.setVisibility(0);
        }
    }

    public void subMitRequest() {
        if (TextUtils.isEmpty(this.emailEt.getText().toString())) {
            showToastMessage(R.string.please_enter_the_email_address);
            return;
        }
        if (!RegexUtils.isEmail(this.emailEt.getText().toString())) {
            showToastMessage(R.string.please_enter_the_email_address);
            return;
        }
        if (TextUtils.isEmpty(this.newEt.getText().toString())) {
            showToastMessage(R.string.please_enter_new_password);
            return;
        }
        if (TextUtils.isEmpty(this.codeEt.getText().toString())) {
            showToastMessage(R.string.code_str);
            return;
        }
        if (this.newEt.getText().toString().length() < 6) {
            showToastMessage(R.string.please_enter_6_16_bit_password);
            return;
        }
        if (TextUtils.isEmpty(this.newAgEt.getText().toString())) {
            showToastMessage(R.string.please_enter_again_new_password);
        } else if (!this.newEt.getText().toString().equals(this.newAgEt.getText().toString())) {
            showToastMessage(R.string.password_inconsistent);
        } else {
            ((ChangePwdPresenterImp) this.mPresenter).requestData();
        }
    }

    @Override
    public ChangePwdPresenterImp createPresenter() {
        return new ChangePwdPresenterImp(this);
    }

    @Override
    public void dismissLoadingViews() {
        dismissProgressDialog();
    }

    @Override
    public void showLoadingViews() {
        showProgressDialog();
    }

    @Override
    public void showErrorViews(int errorCode, String msg) {
        try {
            ToastUtil.show(msg, this);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void refreshContentView(int type, User data) {
        System.out.println("lyq ChangeActivity refreshContentView type:" + type);
        if (type == ResponseType.SEND_CODE) {
            new VerificationCodeTimer(this.btnCode, 60000L, 1000L, getResources().getString(R.string.code_send), getResources().getString(R.string.seconds)).start();
            ToastUtil.show(getResources().getString(R.string.code_success), this);
            return;
        }
        System.out.println("lyq ChangeActivity CompleteActivity");
        startActivity(new Intent(this, (Class<?>) CompleteActivity.class));
        finish();
    }

    @Override
    public void showToastMessage(int msg) {
        ToastUtil.show(getString(msg), this);
    }

    @OnClick({R.id.submit_btn, R.id.btn_code_send_pswd})
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131230865) {
            sendCode();
        } else {
            if (id != 2131231508) {
                return;
            }
            subMitRequest();
        }
    }

    private void sendCode() {
        if (TextUtils.isEmpty(this.emailEt.getText().toString())) {
            showToastMessage(R.string.please_enter_the_email_address);
        } else if (!RegexUtils.isEmail(this.emailEt.getText().toString())) {
            showToastMessage(R.string.please_enter_the_email_address);
        } else {
            ((ChangePwdPresenterImp) this.mPresenter).sendCode();
        }
    }

    @Override
    public String getEmail() {
        return this.emailEt.getText().toString();
    }

    @Override
    public String getPwd() {
        return this.newAgEt.getText().toString();
    }

    @Override
    public String getCode() {
        return this.codeEt.getText().toString();
    }

    private class VerificationCodeTimer extends CountDownTimer {
        private String btnStr;
        private Button button;
        private String unit;

        public VerificationCodeTimer(Button button, long millisInFuture, long countDownInterval, String btnStr, String unit) {
            super(millisInFuture, countDownInterval);
            System.out.println("---- VerificationCodeTimer controller ----");
            this.button = button;
            this.btnStr = btnStr;
            this.unit = unit;
        }

        @Override
        public void onTick(long millisUntilFinished) {
            System.out.println("---- VerificationCodeTimer onTick ----");
            this.button.setEnabled(false);
            this.button.setText((millisUntilFinished / 1000) + " " + this.unit);
        }

        @Override
        public void onFinish() {
            System.out.println("---- VerificationCodeTimer onFinish ----");
            this.button.setEnabled(true);
            this.button.setText(this.btnStr);
        }
    }
}