388 lines
16 KiB
Java
388 lines
16 KiB
Java
package com.ubt.jimu.user.presenter;
|
|
|
|
import android.content.Context;
|
|
import android.os.Handler;
|
|
import android.os.HandlerThread;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
import com.facebook.AccessToken;
|
|
import com.tencent.open.SocialConstants;
|
|
import com.ubt.jimu.base.cache.Cache;
|
|
import com.ubt.jimu.base.cache.SharePreferenceHelper;
|
|
import com.ubt.jimu.base.entities.ApiStatus;
|
|
import com.ubt.jimu.base.entities.Constant;
|
|
import com.ubt.jimu.base.entities.User;
|
|
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.push.JimuPushMessage;
|
|
import com.ubt.jimu.user.contract.RegisterContract$Presenter;
|
|
import com.ubt.jimu.user.contract.RegisterContract$View;
|
|
import com.ubt.jimu.user.model.EmailCheckMsg;
|
|
import com.ubt.jimu.user.model.RefHolder;
|
|
import com.ubt.jimu.user.presenter.RegisterPresenter;
|
|
import com.ubt.jimu.user.repository.UserRepository;
|
|
import com.ubt.jimu.utils.DeviceUtils;
|
|
import com.ubt.jimu.utils.LocaleUtils;
|
|
import com.ubt.jimu.utils.Md5Utils;
|
|
import com.ubt.jimu.utils.RxSchedulers;
|
|
import com.ubtech.utils.XLog;
|
|
import com.ubtrobot.log.ALog;
|
|
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;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class RegisterPresenter implements RegisterContract$Presenter {
|
|
private Context a;
|
|
private RegisterContract$View b;
|
|
private CompositeDisposable c = new CompositeDisposable();
|
|
private Handler d;
|
|
private HandlerThread e;
|
|
|
|
public RegisterPresenter(Context context, RegisterContract$View registerContract$View) {
|
|
this.a = context.getApplicationContext();
|
|
this.b = registerContract$View;
|
|
}
|
|
|
|
@Override // com.ubtech.presenter.BasePresenter
|
|
public void subscribe() {
|
|
this.e = new HandlerThread("check parent email theread");
|
|
this.e.start();
|
|
this.d = new Handler(this.e.getLooper());
|
|
}
|
|
|
|
@Override // com.ubtech.presenter.BasePresenter
|
|
public void unSubscribe() {
|
|
this.c.dispose();
|
|
this.c.a();
|
|
Handler handler = this.d;
|
|
if (handler != null) {
|
|
handler.removeCallbacksAndMessages(null);
|
|
this.d = null;
|
|
}
|
|
HandlerThread handlerThread = this.e;
|
|
if (handlerThread != null) {
|
|
handlerThread.quit();
|
|
this.e = null;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void c(String str, String str2) {
|
|
Cache.getInstance().getSettings().put(SharePreferenceHelper.SP_KEY_LAST_PARENT_EMAIL, str);
|
|
b(str, str2);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.RegisterContract$Presenter
|
|
public void d(String str, String str2) {
|
|
this.b.F();
|
|
UserRepository.a(this.a, str, Md5Utils.a(str2)).compose(RxSchedulers.a()).subscribe(new Observer<User>() { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.6
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(User user) {
|
|
RegisterPresenter.this.b.a(user);
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
RegisterPresenter.this.b.H();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public void b(String str, String str2) {
|
|
UserRepository.a(str, str2).compose(RxSchedulers.a()).subscribe(new AnonymousClass5(this.a, str, str2));
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.RegisterContract$Presenter
|
|
public void a(final String str, final String str2, String str3, String str4, String str5) {
|
|
boolean contains = str3.contains("@");
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("account", str3);
|
|
hashMap.put("accountType", String.valueOf(contains ? 1 : 0));
|
|
hashMap.put("appId", String.valueOf(Constant.Base.APP_ID));
|
|
hashMap.put("password", Md5Utils.a(str4));
|
|
hashMap.put("captcha", str5);
|
|
this.b.Q();
|
|
UserRepository.a(this.a, hashMap).compose(RxSchedulers.a()).subscribe(new IApiObserver<User>(this.a) { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.1
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(User user) {
|
|
super.onNext(user);
|
|
RegisterPresenter.this.b.d(user);
|
|
RegisterPresenter.this.a(str, str2);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
public void onApiError(ApiResultException apiResultException) {
|
|
RegisterPresenter.this.b.k(apiResultException.getMessage());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.RegisterContract$Presenter
|
|
public void b() {
|
|
Observable.create(new ObservableOnSubscribe<String>() { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.8
|
|
@Override // io.reactivex.ObservableOnSubscribe
|
|
public void subscribe(ObservableEmitter<String> observableEmitter) throws Exception {
|
|
observableEmitter.onNext(LocaleUtils.a(RegisterPresenter.this.a));
|
|
observableEmitter.onComplete();
|
|
}
|
|
}).compose(RxSchedulers.a()).subscribe(new Observer<String>() { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.7
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(String str) {
|
|
RegisterPresenter.this.b.c(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) {
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
/* renamed from: com.ubt.jimu.user.presenter.RegisterPresenter$5, reason: invalid class name */
|
|
class AnonymousClass5 extends IApiObserver<EmailCheckMsg> {
|
|
final /* synthetic */ String a;
|
|
final /* synthetic */ String b;
|
|
|
|
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
|
AnonymousClass5(Context context, String str, String str2) {
|
|
super(context);
|
|
this.a = str;
|
|
this.b = str2;
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(EmailCheckMsg emailCheckMsg) {
|
|
super.onNext(emailCheckMsg);
|
|
ALog.a("RegPresenter").e("getEmailCheckState:" + emailCheckMsg, new Object[0]);
|
|
if (emailCheckMsg.isEmailChecked()) {
|
|
RegisterPresenter.this.b.a(RegisterPresenter.this.a);
|
|
Cache.getInstance().getSettings().put(SharePreferenceHelper.SP_KEY_LAST_PARENT_EMAIL, "");
|
|
if (RegisterPresenter.this.d == null) {
|
|
return;
|
|
}
|
|
RegisterPresenter.this.d.removeCallbacksAndMessages(null);
|
|
return;
|
|
}
|
|
if (RegisterPresenter.this.d != null) {
|
|
ALog.a("RegPresenter").e("postDelay check email", new Object[0]);
|
|
Handler handler = RegisterPresenter.this.d;
|
|
final String str = this.a;
|
|
final String str2 = this.b;
|
|
handler.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.presenter.b
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
RegisterPresenter.AnonymousClass5.this.b(str, str2);
|
|
}
|
|
}, 4000L);
|
|
}
|
|
}
|
|
|
|
public /* synthetic */ void b(String str, String str2) {
|
|
RegisterPresenter.this.b(str, str2);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
public void onApiError(ApiResultException apiResultException) {
|
|
if (RegisterPresenter.this.d != null) {
|
|
ALog.a("RegPresenter").e("postDelay check email", new Object[0]);
|
|
Handler handler = RegisterPresenter.this.d;
|
|
final String str = this.a;
|
|
final String str2 = this.b;
|
|
handler.postDelayed(new Runnable() { // from class: com.ubt.jimu.user.presenter.a
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
RegisterPresenter.AnonymousClass5.this.a(str, str2);
|
|
}
|
|
}, 4000L);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
|
|
public /* synthetic */ void a(String str, String str2) {
|
|
RegisterPresenter.this.b(str, str2);
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.RegisterContract$Presenter
|
|
public void a(String str, String str2, String str3, String str4, String str5, String str6, String str7) {
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("accessToken", str);
|
|
hashMap.put("appId", str2);
|
|
hashMap.put("loginType", str3);
|
|
hashMap.put("miniTvsId", str4);
|
|
hashMap.put("openId", str5);
|
|
hashMap.put("ubtAppId", String.valueOf(Constant.Base.APP_ID));
|
|
hashMap.put("nickName", str6);
|
|
hashMap.put(SocialConstants.PARAM_IMG_URL, str7);
|
|
this.b.Q();
|
|
UserRepository.b(this.a, hashMap).compose(RxSchedulers.a()).subscribe(new IApiObserver<User>(this.a) { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.2
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(User user) {
|
|
super.onNext(user);
|
|
RegisterPresenter.this.b.d(user);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
protected void onApiError(ApiResultException apiResultException) {
|
|
RegisterPresenter.this.b.k(apiResultException.getMessage());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.RegisterContract$Presenter
|
|
public void a(String str, int i) {
|
|
if (TextUtils.isEmpty(str)) {
|
|
XLog.b("RegPresenter", "account is null or empty!");
|
|
return;
|
|
}
|
|
boolean contains = str.contains("@");
|
|
this.b.T();
|
|
UserRepository.a(str, contains ? 1 : 0, i).compose(RxSchedulers.a()).subscribe(new IApiObserver<ApiStatus>(this.a) { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.3
|
|
@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);
|
|
RegisterPresenter.this.b.b(apiStatus);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
public void onApiError(ApiResultException apiResultException) {
|
|
RegisterPresenter.this.b.e(apiResultException.getMessage());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.ubt.jimu.user.contract.RegisterContract$Presenter
|
|
public void a(String str, final String str2, String str3, boolean z) {
|
|
Map<String, String> b;
|
|
RefHolder.a(str2);
|
|
try {
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("appSource", "Jimu");
|
|
hashMap.put("appType", "2");
|
|
hashMap.put("deviceId", DeviceUtils.a(this.a.getApplicationContext()));
|
|
hashMap.put("nickName", str);
|
|
hashMap.put("email", str2);
|
|
hashMap.put(JimuPushMessage.KEY_USER_BIRTHDAY, str3);
|
|
hashMap.put("isCheckEmail", z ? "1" : "0");
|
|
if (!z && (b = RefHolder.b()) != null) {
|
|
hashMap.put("appId", b.get("ubtsocial_app_id"));
|
|
hashMap.put("loginType", b.get("social_type"));
|
|
hashMap.put("openId", b.get("ubtsocial_user_id"));
|
|
hashMap.put("accessToken", b.get(AccessToken.ACCESS_TOKEN_KEY));
|
|
}
|
|
UserRepository.a(hashMap).compose(RxSchedulers.a()).subscribe(new IApiObserver<ApiStatus>(this.a) { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.4
|
|
@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);
|
|
Log.i("sendGuardianEmail", apiStatus.getMessage());
|
|
RegisterPresenter.this.b.f(apiStatus);
|
|
RegisterPresenter registerPresenter = RegisterPresenter.this;
|
|
registerPresenter.c(str2, DeviceUtils.a(registerPresenter.a));
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver
|
|
public void onApiError(ApiResultException apiResultException) {
|
|
RegisterPresenter.this.b.i(apiResultException.getMessage());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.http.IApiObserver, io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
super.onSubscribe(disposable);
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
this.b.i(e.getMessage());
|
|
}
|
|
}
|
|
|
|
public void a(String str, String str2) {
|
|
HashMap hashMap = new HashMap();
|
|
if (!TextUtils.isEmpty(str2)) {
|
|
hashMap.put("countryName", str2);
|
|
}
|
|
if (!TextUtils.isEmpty(str)) {
|
|
hashMap.put("countryCode", str);
|
|
}
|
|
if (hashMap.size() < 1) {
|
|
return;
|
|
}
|
|
UserRepository.b(hashMap).compose(RxSchedulers.a()).subscribe(new Observer<UserDetailInfo>() { // from class: com.ubt.jimu.user.presenter.RegisterPresenter.9
|
|
@Override // io.reactivex.Observer
|
|
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
|
public void onNext(UserDetailInfo userDetailInfo) {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onComplete() {
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onError(Throwable th) {
|
|
th.printStackTrace();
|
|
}
|
|
|
|
@Override // io.reactivex.Observer
|
|
public void onSubscribe(Disposable disposable) {
|
|
RegisterPresenter.this.c.b(disposable);
|
|
}
|
|
});
|
|
}
|
|
}
|