288 lines
13 KiB
Java
288 lines
13 KiB
Java
package com.ubt.jimu.user.view;
|
|
|
|
import android.content.Intent;
|
|
import android.os.Bundle;
|
|
import android.os.CountDownTimer;
|
|
import android.os.Handler;
|
|
import android.text.TextUtils;
|
|
import android.view.View;
|
|
import android.widget.EditText;
|
|
import android.widget.TextView;
|
|
import butterknife.ButterKnife;
|
|
import com.alibaba.android.arouter.facade.Postcard;
|
|
import com.alibaba.android.arouter.launcher.ARouter;
|
|
import com.ubt.jimu.BaseActivity;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.entities.ApiStatus;
|
|
import com.ubt.jimu.base.entities.UserDetailInfo;
|
|
import com.ubt.jimu.base.http.ApiResultException;
|
|
import com.ubt.jimu.base.http.IApiObserver;
|
|
import com.ubt.jimu.user.repository.UserRepository;
|
|
import com.ubt.jimu.utils.LocaleUtils;
|
|
import com.ubt.jimu.utils.RxSchedulers;
|
|
import com.ubt.jimu.widgets.ClearEditText;
|
|
import com.ubt.jimu.widgets.JAlertDialog;
|
|
import com.ubt.jimu.widgets.NavigationBarView;
|
|
import io.reactivex.Observable;
|
|
import io.reactivex.ObservableEmitter;
|
|
import io.reactivex.ObservableOnSubscribe;
|
|
import io.reactivex.Observer;
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class TelephoneUpdateActivity extends BaseActivity implements NavigationBarView.OnActionClickListener {
|
|
private CompositeDisposable a = new CompositeDisposable();
|
|
private Handler b = new Handler();
|
|
private CountDownTimer c;
|
|
ClearEditText captchaEditText;
|
|
TextView countDownTextView;
|
|
TextView countryCodeTextView;
|
|
private JAlertDialog d;
|
|
NavigationBarView navBarView;
|
|
EditText telephoneEditText;
|
|
|
|
private void D0() {
|
|
Observable.create(new ObservableOnSubscribe<String>() { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.5
|
|
@Override // io.reactivex.ObservableOnSubscribe
|
|
public void subscribe(ObservableEmitter<String> observableEmitter) throws Exception {
|
|
observableEmitter.onNext(LocaleUtils.a(TelephoneUpdateActivity.this));
|
|
observableEmitter.onComplete();
|
|
}
|
|
}).compose(RxSchedulers.a()).subscribe(new Observer<String>() { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.4
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(String str) {
|
|
TelephoneUpdateActivity.this.countryCodeTextView.setText(str);
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
TelephoneUpdateActivity.this.a.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void E0() {
|
|
this.c = new CountDownTimer(60000L, 1000L) { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.2
|
|
@Override // android.os.CountDownTimer
|
|
public void onFinish() {
|
|
TelephoneUpdateActivity.this.countDownTextView.setText(R.string.get_captcha);
|
|
TelephoneUpdateActivity.this.countDownTextView.setClickable(true);
|
|
TelephoneUpdateActivity telephoneUpdateActivity = TelephoneUpdateActivity.this;
|
|
telephoneUpdateActivity.countDownTextView.setTextColor(telephoneUpdateActivity.getResources().getColor(R.color.txt_287EF1));
|
|
}
|
|
|
|
@Override // android.os.CountDownTimer
|
|
public void onTick(long j) {
|
|
String format = String.format(TelephoneUpdateActivity.this.getResources().getString(R.string.hint_seconds), Long.valueOf(j / 1000));
|
|
TelephoneUpdateActivity telephoneUpdateActivity = TelephoneUpdateActivity.this;
|
|
telephoneUpdateActivity.countDownTextView.setTextColor(telephoneUpdateActivity.getResources().getColor(R.color.txt_98A5B6));
|
|
TelephoneUpdateActivity.this.countDownTextView.setText(format);
|
|
}
|
|
};
|
|
this.c.start();
|
|
this.countDownTextView.setClickable(false);
|
|
}
|
|
|
|
private void onConfirmAction(View view) {
|
|
if (e(false)) {
|
|
String trim = this.countryCodeTextView.getText().toString().trim();
|
|
String str = trim.substring(trim.indexOf("+") + 1, trim.length()) + this.telephoneEditText.getText().toString().trim();
|
|
String trim2 = this.captchaEditText.getText().toString().trim();
|
|
a("", R.drawable.ic_loading, true);
|
|
UserRepository.a(str, 0, trim2).compose(RxSchedulers.a()).subscribe(new IApiObserver<UserDetailInfo>(this) { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.3
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(UserDetailInfo userDetailInfo) {
|
|
super.onNext(userDetailInfo);
|
|
if (TelephoneUpdateActivity.this.d != null) {
|
|
TelephoneUpdateActivity.this.d.dismiss();
|
|
}
|
|
if (userDetailInfo == null || userDetailInfo == null) {
|
|
return;
|
|
}
|
|
TelephoneUpdateActivity telephoneUpdateActivity = TelephoneUpdateActivity.this;
|
|
telephoneUpdateActivity.toastSuccess(telephoneUpdateActivity.getString(R.string.update_success));
|
|
Intent intent = new Intent();
|
|
intent.putExtra("new_telephone", userDetailInfo.getUserPhone());
|
|
TelephoneUpdateActivity.this.setResult(-1, intent);
|
|
TelephoneUpdateActivity.this.finish();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
public void onApiError(final ApiResultException apiResultException) {
|
|
TelephoneUpdateActivity.this.b.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.3.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (TelephoneUpdateActivity.this.d != null) {
|
|
TelephoneUpdateActivity.this.d.dismiss();
|
|
}
|
|
TelephoneUpdateActivity.this.toastError(apiResultException.getMessage());
|
|
}
|
|
}, 1500L);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
TelephoneUpdateActivity.this.a.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onActivityResult(int i, int i2, Intent intent) {
|
|
super.onActivityResult(i, i2, intent);
|
|
if (i2 == -1 && intent != null && i == 1) {
|
|
String stringExtra = intent.getStringExtra("country_code");
|
|
String stringExtra2 = intent.getStringExtra("country_name");
|
|
this.countryCodeTextView.setText(stringExtra2 + stringExtra);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.widgets.NavigationBarView.OnActionClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R.id.iv_left) {
|
|
finish();
|
|
} else {
|
|
if (id != R.id.iv_right) {
|
|
return;
|
|
}
|
|
onConfirmAction(view);
|
|
}
|
|
}
|
|
|
|
public void onCountDownAction(View view) {
|
|
if (e(true)) {
|
|
String trim = this.countryCodeTextView.getText().toString().trim();
|
|
String trim2 = this.telephoneEditText.getText().toString().trim();
|
|
String substring = trim.substring(trim.indexOf("+") + 1, trim.length());
|
|
a(getString(R.string.have_send_captcha), R.drawable.ic_loading, true);
|
|
UserRepository.a(substring + trim2, 0, 1).compose(RxSchedulers.a()).subscribe(new IApiObserver<ApiStatus>(this) { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.1
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(ApiStatus apiStatus) {
|
|
super.onNext(apiStatus);
|
|
if (apiStatus.getCode() == 0) {
|
|
TelephoneUpdateActivity.this.E0();
|
|
TelephoneUpdateActivity.this.b.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.1.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (TelephoneUpdateActivity.this.d != null) {
|
|
TelephoneUpdateActivity.this.d.dismiss();
|
|
}
|
|
}
|
|
}, 1000L);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
public void onApiError(final ApiResultException apiResultException) {
|
|
TelephoneUpdateActivity.this.b.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.view.TelephoneUpdateActivity.1.2
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
if (TelephoneUpdateActivity.this.d != null) {
|
|
TelephoneUpdateActivity.this.d.dismiss();
|
|
}
|
|
TelephoneUpdateActivity.this.toastError(apiResultException.getMessage());
|
|
if (TelephoneUpdateActivity.this.c != null) {
|
|
TelephoneUpdateActivity.this.c.cancel();
|
|
}
|
|
TelephoneUpdateActivity.this.countDownTextView.setText(R.string.get_captcha);
|
|
TelephoneUpdateActivity.this.countDownTextView.setClickable(true);
|
|
TelephoneUpdateActivity telephoneUpdateActivity = TelephoneUpdateActivity.this;
|
|
telephoneUpdateActivity.countDownTextView.setTextColor(telephoneUpdateActivity.getResources().getColor(R.color.txt_287EF1));
|
|
}
|
|
}, 2000L);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
TelephoneUpdateActivity.this.a.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
public void onCountryCodeAction(View view) {
|
|
String charSequence = this.countryCodeTextView.getText().toString();
|
|
String substring = !TextUtils.isEmpty(charSequence) ? charSequence.substring(charSequence.indexOf("+")) : null;
|
|
Postcard a = ARouter.b().a("/account/countrycode");
|
|
a.a("selected_code", substring);
|
|
a.a(this, 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_telephone_update);
|
|
ButterKnife.a(this);
|
|
this.navBarView.setRightIcon(R.drawable.community_collection_icon);
|
|
this.navBarView.setListener(this);
|
|
D0();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onDestroy() {
|
|
this.b.removeCallbacksAndMessages(null);
|
|
super.onDestroy();
|
|
this.a.dispose();
|
|
this.a.a();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity
|
|
public void relayout() {
|
|
}
|
|
|
|
private void a(String str, int i, boolean z) {
|
|
JAlertDialog jAlertDialog = this.d;
|
|
if (jAlertDialog == null) {
|
|
JAlertDialog.Builder builder = new JAlertDialog.Builder(this);
|
|
builder.a(str);
|
|
builder.a(z);
|
|
builder.a(i);
|
|
this.d = builder.a();
|
|
} else {
|
|
jAlertDialog.a(str);
|
|
this.d.b(i);
|
|
this.d.a(z);
|
|
}
|
|
this.d.show();
|
|
}
|
|
|
|
private boolean e(boolean z) {
|
|
if (TextUtils.isEmpty(this.countryCodeTextView.getText().toString().trim())) {
|
|
toastError(getString(R.string.error_empty_phone_code));
|
|
return false;
|
|
}
|
|
String trim = this.telephoneEditText.getText().toString().trim();
|
|
if (TextUtils.isEmpty(trim)) {
|
|
toastError(getString(R.string.error_empty_phone));
|
|
return false;
|
|
}
|
|
if (!com.ubt.jimu.utils.TextUtils.c(trim)) {
|
|
toastError(getString(R.string.error_phone_format));
|
|
return false;
|
|
}
|
|
String trim2 = this.captchaEditText.getText().toString().trim();
|
|
if (z || !TextUtils.isEmpty(trim2)) {
|
|
return true;
|
|
}
|
|
toastError(getString(R.string.error_empty_captcha));
|
|
return false;
|
|
}
|
|
}
|