222 lines
7.3 KiB
Java
222 lines
7.3 KiB
Java
package com.ubt.jimu.user.view;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.os.CountDownTimer;
|
|
import android.text.Editable;
|
|
import android.text.TextUtils;
|
|
import android.text.TextWatcher;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.widget.TextView;
|
|
import butterknife.ButterKnife;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.ApiStatus;
|
|
import com.ubt.jimu.base.entities.User;
|
|
import com.ubt.jimu.base.http.ApiConstants;
|
|
import com.ubt.jimu.user.contract.VerifyContract$Presenter;
|
|
import com.ubt.jimu.user.contract.VerifyContract$View;
|
|
import com.ubt.jimu.user.model.SpUserHolder;
|
|
import com.ubt.jimu.user.presenter.VerifyPresenter;
|
|
import com.ubt.jimu.widgets.ClearEditText;
|
|
import com.ubt.jimu.widgets.NavigationBarView;
|
|
import com.ubtech.view.widget.UButton;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class VerifyCaptchaActivity extends BaseActivity implements TextWatcher, VerifyContract$View {
|
|
private String a;
|
|
private String b;
|
|
UButton btnVerify;
|
|
private User c;
|
|
ClearEditText captchaEditText;
|
|
TextView countDownTextView;
|
|
private VerifyContract$Presenter d;
|
|
private CountDownTimer e;
|
|
NavigationBarView mNavBarView;
|
|
|
|
private void D0() {
|
|
this.countDownTextView.setClickable(false);
|
|
this.e = new CountDownTimer(60000L, 1000L) { // from class: com.ubt.jimu.user.view.VerifyCaptchaActivity.2
|
|
@Override // android.os.CountDownTimer
|
|
public void onFinish() {
|
|
VerifyCaptchaActivity.this.countDownTextView.setText(R.string.get_captcha);
|
|
VerifyCaptchaActivity.this.countDownTextView.setClickable(true);
|
|
VerifyCaptchaActivity.this.e = null;
|
|
}
|
|
|
|
@Override // android.os.CountDownTimer
|
|
public void onTick(long j) {
|
|
VerifyCaptchaActivity.this.countDownTextView.setText((j / 1000) + "s");
|
|
}
|
|
};
|
|
this.e.start();
|
|
}
|
|
|
|
private void E0() {
|
|
CountDownTimer countDownTimer = this.e;
|
|
if (countDownTimer == null) {
|
|
return;
|
|
}
|
|
try {
|
|
countDownTimer.cancel();
|
|
this.e = null;
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
private void b(Bundle bundle) {
|
|
if (bundle == null) {
|
|
finish();
|
|
return;
|
|
}
|
|
this.a = bundle.getString("account");
|
|
this.b = bundle.getString("account_type");
|
|
this.c = (User) bundle.getSerializable("user");
|
|
User user = this.c;
|
|
if (user != null) {
|
|
SpUserHolder.a(user.getUserId(), this.c.getToken());
|
|
}
|
|
}
|
|
|
|
private void initView() {
|
|
this.mNavBarView.setListener(new NavigationBarView.OnActionClickListener.Stub() { // from class: com.ubt.jimu.user.view.VerifyCaptchaActivity.1
|
|
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener.Stub
|
|
public void onLeftClick(View view) {
|
|
VerifyCaptchaActivity.this.onImgBack(view);
|
|
}
|
|
});
|
|
this.captchaEditText.addTextChangedListener(this);
|
|
this.d = new VerifyPresenter(this);
|
|
}
|
|
|
|
private void l(int i) {
|
|
Intent intent = new Intent();
|
|
intent.putExtra("user", this.c);
|
|
setResult(i, intent);
|
|
finish();
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void afterTextChanged(Editable editable) {
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.VerifyContract$View
|
|
public void c(Throwable th) {
|
|
hideLoading();
|
|
toast(getString(R.string.error_get_captcha));
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.VerifyContract$View
|
|
public void e(ApiStatus apiStatus) {
|
|
D0();
|
|
hideLoading();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.VerifyContract$View
|
|
public void g(ApiStatus apiStatus) {
|
|
hideLoading();
|
|
l(-1);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
|
protected void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
setContentView(R.layout.activity_verify_catcha);
|
|
ButterKnife.a(this);
|
|
initView();
|
|
a(bundle);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
E0();
|
|
SpUserHolder.a();
|
|
}
|
|
|
|
protected void onGetCaptcha(View view) {
|
|
this.d.getCaptcha(this.a, this.b, String.valueOf(5), String.valueOf(0), ApiConstants.APP_ID);
|
|
showLoading(getString(R.string.have_send_captcha));
|
|
}
|
|
|
|
protected void onImgBack(View view) {
|
|
l(0);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
|
|
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
|
if (i != 4) {
|
|
return super.onKeyDown(i, keyEvent);
|
|
}
|
|
l(0);
|
|
return true;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onPause() {
|
|
super.onPause();
|
|
}
|
|
|
|
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
|
protected void onSaveInstanceState(Bundle bundle) {
|
|
super.onSaveInstanceState(bundle);
|
|
bundle.putString("account", this.a);
|
|
bundle.putString("account_type", this.b);
|
|
bundle.putSerializable("user", this.c);
|
|
}
|
|
|
|
@Override // android.text.TextWatcher
|
|
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
String obj = this.captchaEditText.getText().toString();
|
|
if (TextUtils.isEmpty(obj) || obj.length() < 4) {
|
|
this.btnVerify.setEnabled(false);
|
|
} else {
|
|
this.btnVerify.setEnabled(true);
|
|
}
|
|
}
|
|
|
|
protected void onVerify(View view) {
|
|
String obj = this.captchaEditText.getText().toString();
|
|
if (TextUtils.isEmpty(obj)) {
|
|
toast(getString(R.string.error_empty_captcha));
|
|
} else {
|
|
this.d.a(this.a, obj);
|
|
showLoading(getString(R.string.waiting));
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity
|
|
public void relayout() {
|
|
}
|
|
|
|
private void a(Bundle bundle) {
|
|
if (bundle != null) {
|
|
b(bundle);
|
|
return;
|
|
}
|
|
Intent intent = getIntent();
|
|
if (intent == null) {
|
|
finish();
|
|
return;
|
|
}
|
|
Bundle bundleExtra = intent.getBundleExtra("extra");
|
|
if (bundleExtra == null) {
|
|
finish();
|
|
} else {
|
|
b(bundleExtra);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.VerifyContract$View
|
|
public void b(Throwable th) {
|
|
hideLoading();
|
|
toast(getString(R.string.error_captcha));
|
|
}
|
|
}
|