正在查看: Credmex v3.12.2 应用的 ReUploadDocumentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Credmex v3.12.2 应用的 ReUploadDocumentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.credmex.authentication.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Pair;
import android.util.SparseArray;
import android.view.View;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import butterknife.BindView;
import butterknife.OnClick;
import com.credmex.activity.TakeHandWithIdCardPhotoActivity;
import com.credmex.appconfig.GeneralConfigManager;
import com.credmex.authentication.kycinformation.IDCardPickComponent;
import com.credmex.commom.CommonActivity;
import com.credmex.models.CashBooleanResponse;
import com.credmex.models.GeneralConfigResponse;
import com.credmex.models.ReUploadDocRequest;
import com.credmex.models.ReUploadDocType;
import com.credmex.models.ReUploadItemDesc;
import com.credmex.models.event.HandWithIdCardEvent;
import com.credmex.models.response.ReUploadDocumentResponse;
import com.credmex.net.CredMexBaseResult;
import com.credmex.net.CredMexObserver;
import com.credmex.net.CredMexResponseCode;
import com.credmex.net.IApiRoutes;
import com.credmex.track.ThirdPartTrackEvents;
import com.credmex.track.ThirdPartTrackLib;
import com.credmex.track.TrackEventParamsConfigurator;
import com.credmex.widght.RoundImageView;
import com.open.mx.ui.base.BaseComponent;
import com.open.mx.ui.base.BaseComponentPresenter;
import com.open.mx.ui.model.LabelBean;
import com.open.mx.ui.views.button.PrimaryButton;
import com.sensorsdata.analytics.android.autotrack.aop.SensorsDataAutoTrackHelper;
import com.sensorsdata.analytics.android.sdk.SensorsDataInstrumented;
import com.veda.android.imageloaderlib.Imager;
import com.veda.supertoolkit.customtools.CollectionUtils;
import com.veda.supertoolkit.filetools.FilePathUtil;
import com.veda.supertoolkit.lifecycle.LifecycleEvent;
import com.veda.supertoolkit.utils.ImageUtil;
import com.veda.supertoolkit.widgets.BaseUtils;
import com.yangqianguan.statistics.AutoTrackHelper;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.BiFunction;
import io.reactivex.functions.Consumer;
import io.reactivex.processors.BehaviorProcessor;
import java.io.File;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
public class ReUploadDocumentActivity extends CommonActivity {
public static final String BACK_IMAGE_KEY = "backImage";
public static final String FRONT_IMAGE_KEY = "frontImage";
public static final String HAND_WITH_ID_CARD_KEY = "frontImage";
private int D = 0;
private SparseArray<ReUploadDocRequest.ReUploadDocRequestBean> E = new SparseArray<>();
private List<String> F = new ArrayList();
private String G = "";
private String H = "";
private BehaviorProcessor<ReUploadDocumentResponse> I = BehaviorProcessor.s0();
private BehaviorProcessor<Boolean> J = BehaviorProcessor.s0();
@BindView(2131361937)
PrimaryButton btnConfirm;
@BindView(2131362041)
ConstraintLayout clHandWithIdCard;
@BindView(2131362276)
IDCardPickComponent idCardPickComponent;
@BindView(2131362351)
RoundImageView ivHandHoldIdCardPhoto;
@BindView(2131362352)
RoundImageView ivHandWithIdCard;
@BindView(2131362478)
View llErrorContent;
@BindView(2131362894)
ScrollView svItemContent;
@BindView(2131363082)
TextView tvHandWithIdCardDesc;
@BindView(2131363083)
TextView tvHandWithIdCardTitle;
@BindView(2131362968)
TextView tvTakeHandWithIdCardBtn;
@Retention(RetentionPolicy.SOURCE)
public @interface ReUploadDocIndex {
}
private void A0(String str, String str2, SparseArray<ReUploadDocRequest.ReUploadDocRequestBean> sparseArray) {
ReUploadDocRequest.ReUploadDocRequestBean reUploadDocRequestBean = new ReUploadDocRequest.ReUploadDocRequestBean();
reUploadDocRequestBean.name = str;
ReUploadItemDesc reUploadItemDesc = this.userSession.f().reUploadItemDesc;
str.hashCode();
if (str.equals(ReUploadDocType.HAND_HELD_ID)) {
this.D |= 32;
if (this.E.get(5) == null) {
reUploadDocRequestBean.data.put("frontImage", this.H);
sparseArray.put(5, reUploadDocRequestBean);
} else {
sparseArray.put(5, this.E.get(5));
}
this.tvHandWithIdCardTitle.setText(str2);
if (reUploadItemDesc != null && !TextUtils.isEmpty(reUploadItemDesc.HAND_HELD_ID)) {
this.tvHandWithIdCardDesc.setText(reUploadItemDesc.HAND_HELD_ID);
}
this.clHandWithIdCard.setVisibility(0);
return;
}
if (str.equals(ReUploadDocType.ID)) {
this.D |= 1;
if (this.E.get(0) == null) {
reUploadDocRequestBean.data.put("frontImage", this.idCardPickComponent.getFrontUrl());
reUploadDocRequestBean.data.put(BACK_IMAGE_KEY, this.idCardPickComponent.getBackUrl());
sparseArray.put(0, reUploadDocRequestBean);
} else {
sparseArray.put(0, this.E.get(0));
}
this.idCardPickComponent.k0(str2);
this.idCardPickComponent.setVisibility(0);
if (reUploadItemDesc == null || TextUtils.isEmpty(reUploadItemDesc.ID)) {
return;
}
this.idCardPickComponent.setTips(reUploadItemDesc.ID);
}
}
public void B0() {
((IApiRoutes) this.apiHelper.a()).Y0().t(AndroidSchedulers.a()).a(new CredMexObserver<ReUploadDocumentResponse>(this) {
@Override
public void onError(Throwable th, ReUploadDocumentResponse reUploadDocumentResponse) {
if (reUploadDocumentResponse == null) {
reUploadDocumentResponse = new ReUploadDocumentResponse();
}
CredMexBaseResult.Status status = reUploadDocumentResponse.status;
if (status != null && !TextUtils.isEmpty(status.detail)) {
ReUploadDocumentActivity.this.showErrorToast(reUploadDocumentResponse.status.detail);
}
ReUploadDocumentActivity.this.I.onNext(reUploadDocumentResponse);
}
public void onSuccess(ReUploadDocumentResponse reUploadDocumentResponse) {
ReUploadDocumentActivity.this.I.onNext(reUploadDocumentResponse);
}
});
}
private void C0() {
this.tvTakeHandWithIdCardBtn.setText(2131820808);
this.tvTakeHandWithIdCardBtn.setCompoundDrawablesRelativeWithIntrinsicBounds(2131231124, 0, 0, 0);
this.ivHandHoldIdCardPhoto.setVisibility(0);
this.ivHandWithIdCard.setVisibility(8);
this.clHandWithIdCard.setBackgroundResource(2131231298);
}
private void D0() {
this.svItemContent.postDelayed(new Runnable() {
@Override
public final void run() {
ReUploadDocumentActivity.this.w0();
}
}, 800L);
}
private void E0() {
showLoadingDialog();
((IApiRoutes) this.apiHelper.a()).p(l0()).t(AndroidSchedulers.a()).a(new CredMexObserver<CashBooleanResponse>(this) {
public void onSuccess(CashBooleanResponse cashBooleanResponse) {
ReUploadDocumentActivity.this.dismissLoadingDialog();
ReUploadDocumentActivity.this.finish();
}
@Override
public void onError(Throwable th, CashBooleanResponse cashBooleanResponse) {
CredMexBaseResult.Status status;
super.onError(th, (Throwable) cashBooleanResponse);
if (cashBooleanResponse == null || (status = cashBooleanResponse.status) == null || CredMexResponseCode.NEED_UPLOAD_HAND_HOLD_ID_CARD_PHOTO.code != status.code) {
return;
}
ReUploadDocumentActivity.this.showLoadingDialog();
ReUploadDocumentActivity.this.B0();
}
});
}
private void k0(ReUploadDocRequest.ReUploadDocRequestBean reUploadDocRequestBean, String str, String str2) {
if (reUploadDocRequestBean == null) {
return;
}
reUploadDocRequestBean.data.put(str, str2);
}
private ReUploadDocRequest l0() {
ArrayList arrayList = new ArrayList();
for (int i2 = 0; i2 <= 5; i2++) {
if (this.E.get(i2) != null) {
arrayList.add(this.E.get(i2));
}
}
ReUploadDocRequest reUploadDocRequest = new ReUploadDocRequest();
reUploadDocRequest.documents = arrayList;
return reUploadDocRequest;
}
private boolean m0() {
if ((this.D & 1) != 0) {
if (CollectionUtils.b(this.E.get(0).data)) {
showNormalToast(2131821138);
return false;
}
if (this.E.get(0).data.get("frontImage") == null) {
showNormalToast(2131821138);
return false;
}
if (this.E.get(0).data.get(BACK_IMAGE_KEY) == null) {
showNormalToast(2131821137);
return false;
}
}
return true;
}
private void n0() {
new GeneralConfigManager(this).i(new GeneralConfigManager.FetchGeneralConfigListener() {
@Override
public void onError(GeneralConfigResponse generalConfigResponse) {
ReUploadDocumentActivity.this.J.onNext(Boolean.FALSE);
}
@Override
public void onSuccess(GeneralConfigResponse generalConfigResponse) {
ReUploadDocumentActivity.this.J.onNext(Boolean.TRUE);
}
});
}
private void o0() {
duringActive(Flowable.j(this.J, this.I, new BiFunction() {
public final Object apply(Object obj, Object obj2) {
return new Pair((Boolean) obj, (ReUploadDocumentResponse) obj2);
}
})).J(AndroidSchedulers.a()).V(new Consumer() {
public final void accept(Object obj) {
ReUploadDocumentActivity.this.r0((Pair) obj);
}
});
}
private boolean p0() {
SparseArray<ReUploadDocRequest.ReUploadDocRequestBean> sparseArray = this.E;
return (sparseArray == null || sparseArray.get(5) == null || this.E.get(5).data == null || this.E.get(5).data.get("frontImage") == null) ? false : true;
}
private boolean q0() {
SparseArray<ReUploadDocRequest.ReUploadDocRequestBean> sparseArray = this.E;
return (sparseArray == null || sparseArray.get(0) == null || this.E.get(0).data == null || this.E.get(0).data.get("frontImage") == null || this.E.get(0).data.get(BACK_IMAGE_KEY) == null) ? false : true;
}
public void r0(Pair pair) throws Exception {
dismissLoadingDialog();
Object obj = pair.second;
if (obj == null || !((ReUploadDocumentResponse) obj).isSuccess()) {
this.llErrorContent.setVisibility(0);
return;
}
x0((ReUploadDocumentResponse) pair.second);
y0();
this.llErrorContent.setVisibility(8);
}
@SensorsDataInstrumented
public void s0(View view) {
if (BaseUtils.b()) {
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
} else {
ThirdPartTrackLib.d(this, ThirdPartTrackEvents.UserAuth.MEX_VERIFY_BTN_TAKEFPIC);
this.idCardPickComponent.T0();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
}
public static void startReUploadDocumentActivity(Activity activity) {
activity.startActivity(new Intent(activity, (Class<?>) ReUploadDocumentActivity.class));
}
@SensorsDataInstrumented
public void t0(View view) {
if (BaseUtils.b()) {
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
} else {
ThirdPartTrackLib.d(this, ThirdPartTrackEvents.UserAuth.MEX_VERIFY_BTN_TAKEOPIC);
this.idCardPickComponent.S0();
SensorsDataAutoTrackHelper.trackViewOnClick(view);
AutoTrackHelper.trackViewOnClick(view);
}
}
public void u0(List list) {
k0(this.E.get(0), "frontImage", this.idCardPickComponent.getFrontUrl());
k0(this.E.get(0), BACK_IMAGE_KEY, this.idCardPickComponent.getBackUrl());
y0();
D0();
}
public static void v0(HandWithIdCardEvent handWithIdCardEvent, Map map) {
map.put(ThirdPartTrackEvents.UserAuth.Keys.FILE_PATH, handWithIdCardEvent.filePath);
}
public void w0() {
if (!q0()) {
this.svItemContent.smoothScrollTo(0, 0);
} else if (p0()) {
this.svItemContent.smoothScrollTo(0, this.clHandWithIdCard.getTop());
} else {
this.svItemContent.smoothScrollTo(0, this.btnConfirm.getTop());
}
}
private void x0(ReUploadDocumentResponse reUploadDocumentResponse) {
this.idCardPickComponent.setVisibility(8);
this.clHandWithIdCard.setVisibility(8);
this.btnConfirm.setVisibility(8);
if (CollectionUtils.a(reUploadDocumentResponse.body)) {
showErrorToast(2131820803);
} else {
z0(reUploadDocumentResponse);
this.btnConfirm.setVisibility(0);
}
}
private void y0() {
boolean z = false;
if (this.E.size() == 0) {
this.btnConfirm.setEnabled(false);
return;
}
int i2 = 0;
while (true) {
if (i2 > 5) {
z = true;
break;
}
if (((1 << i2) & this.D) != 0) {
if (!CollectionUtils.b(this.E.get(i2).data)) {
if (i2 != 0) {
if (5 == i2 && this.E.get(i2).data.get("frontImage") == null) {
break;
}
} else if (this.E.get(i2).data.get("frontImage") == null || this.E.get(i2).data.get(BACK_IMAGE_KEY) == null) {
break;
}
} else {
break;
}
}
i2++;
}
this.btnConfirm.setEnabled(z);
}
private void z0(ReUploadDocumentResponse reUploadDocumentResponse) {
if (reUploadDocumentResponse == null || CollectionUtils.a(reUploadDocumentResponse.body)) {
return;
}
this.D = 0;
SparseArray<ReUploadDocRequest.ReUploadDocRequestBean> sparseArray = new SparseArray<>();
for (LabelBean labelBean : reUploadDocumentResponse.body) {
A0(labelBean.value, labelBean.label, sparseArray);
}
this.E = sparseArray;
}
@Override
protected void D() {
super.D();
showLoadingDialog();
n0();
B0();
}
@Override
protected void G(@NonNull Bundle bundle) {
super.G(bundle);
this.idCardPickComponent.j(bundle);
if (TextUtils.isEmpty(this.G)) {
this.G = bundle.getString("HAND_WITH_ID_CARD_PATH", "");
}
if (TextUtils.isEmpty(this.H)) {
this.H = bundle.getString("HAND_WITH_ID_CARD_SERVER_KEY", "");
}
}
@Override
protected void J() {
super.J();
this.idCardPickComponent.setPresenter(new BaseComponentPresenter(this));
this.idCardPickComponent.setTrackSource("re_upload_document");
this.idCardPickComponent.B0().setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ReUploadDocumentActivity.this.s0(view);
}
});
this.idCardPickComponent.y0().setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ReUploadDocumentActivity.this.t0(view);
}
});
this.idCardPickComponent.c(new BaseComponent.ComponentDoneListener() {
public final void a(Object obj) {
ReUploadDocumentActivity.this.u0((List) obj);
}
});
this.idCardPickComponent.setPickCardType(IDCardPickComponent.IdCardPickType.ALL);
this.idCardPickComponent.setIsAllowSelectPicture(false);
o0();
}
@Override
protected void K() {
super.K();
if (TextUtils.isEmpty(this.G)) {
return;
}
Imager.a().d(getContext(), Uri.fromFile(new File(this.G)), this.ivHandHoldIdCardPhoto);
C0();
}
@Override
protected void X(@NonNull Bundle bundle) {
super.X(bundle);
this.idCardPickComponent.v(bundle);
bundle.putString("HAND_WITH_ID_CARD_PATH", this.G);
bundle.putString("HAND_WITH_ID_CARD_SERVER_KEY", this.H);
}
@Override
public int getLayoutID() {
return 2131558444;
}
public void jumpTakeHandWithIdCard() {
TakeHandWithIdCardPhotoActivity.startActivity(this);
}
public void onConfirm() {
if (m0()) {
E0();
}
}
@Override
protected void onDestroy() {
Iterator<String> it = this.F.iterator();
while (it.hasNext()) {
ImageUtil.d(this, it.next());
}
FilePathUtil.d(this);
super.onDestroy();
}
@Subscribe(sticky = true)
public void onTakePhotoResult(final HandWithIdCardEvent handWithIdCardEvent) {
if (8 != handWithIdCardEvent.requestType) {
return;
}
EventBus.c().q(handWithIdCardEvent);
if (!handWithIdCardEvent.success || TextUtils.isEmpty(handWithIdCardEvent.serverKey)) {
return;
}
ThirdPartTrackLib.e(this, ThirdPartTrackEvents.UserAuth.MEX_ID_CARD_SCAN_RESULT, new TrackEventParamsConfigurator() {
@Override
public final void a(Map map) {
ReUploadDocumentActivity.v0(HandWithIdCardEvent.this, map);
}
});
this.G = handWithIdCardEvent.filePath;
this.H = handWithIdCardEvent.serverKey;
Imager.a().d(getContext(), Uri.fromFile(new File(handWithIdCardEvent.filePath)), this.ivHandHoldIdCardPhoto);
k0(this.E.get(5), "frontImage", handWithIdCardEvent.serverKey);
C0();
y0();
D0();
}
@OnClick({2131361937, 2131362352, 2131361967, 2131362968, 2131362351})
public void onViewClick(View view) {
if (BaseUtils.b()) {
}
switch (view.getId()) {
case 2131361937:
onConfirm();
break;
case 2131361967:
showLoadingDialog();
B0();
break;
case 2131362351:
case 2131362352:
case 2131362968:
jumpTakeHandWithIdCard();
break;
}
}
@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);
}
}