正在查看: Clash Legends v0.0.1 应用的 CFDropSeamlessActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 CFDropSeamlessActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.cashfree.pg.ui.hidden.seamless;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Bundle;
import android.widget.ProgressBar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import com.cashfree.pg.core.api.CFCorePaymentGatewayService;
import com.cashfree.pg.core.api.CFTheme;
import com.cashfree.pg.core.api.base.CFPayment;
import com.cashfree.pg.core.api.exception.CFException;
import com.cashfree.pg.core.api.ui.PaymentInitiationData;
import com.cashfree.pg.core.api.utils.CFErrorResponse;
import com.cashfree.pg.core.api.utils.CFUPIApp;
import com.cashfree.pg.core.api.utils.CFUPIUtil;
import com.cashfree.pg.core.api.utils.CFUtil;
import com.cashfree.pg.core.api.utils.ThreadUtil;
import com.cashfree.pg.core.hidden.network.response.models.ConfigResponse;
import com.cashfree.pg.core.hidden.network.response.models.config.MerchantInfo;
import com.cashfree.pg.core.hidden.network.response.models.config.OrderDetails;
import com.cashfree.pg.core.hidden.utils.CFPaymentModes;
import com.cashfree.pg.network.INetworkChecks;
import com.cashfree.pg.network.NetworkConnectivityUtil;
import com.cashfree.pg.ui.R;
import com.cashfree.pg.ui.api.CFDropCheckoutPayment;
import com.cashfree.pg.ui.hidden.activity.base.BaseActivity;
import com.cashfree.pg.ui.hidden.channel.CFNativeCallbackEventBus;
import com.cashfree.pg.ui.hidden.channel.CFNativeCallbackEvents;
import com.cashfree.pg.ui.hidden.seamless.CFDropSeamlessActivity;
import com.cashfree.pg.ui.hidden.seamless.callbacks.CFSeamlessCallbacks;
import com.cashfree.pg.ui.hidden.seamless.dialog.UPISeamlessBottomSheetDialog;
import com.cashfree.pg.ui.hidden.viewModel.BaseViewModel;
import com.cashfree.pg.ui.hidden.viewModel.CFDropSeamlessViewModel;
import java.util.ArrayList;
import java.util.List;
public class CFDropSeamlessActivity extends BaseActivity implements UPISeamlessBottomSheetDialog.UPIPayListener, CFDropSeamlessViewModel.DataFetch, CFDropSeamlessViewModel.DropSeamlessCallbacks {
private List<String> blacklistedUPIAppList;
private CFDropSeamlessViewModel cfDropSeamlessViewModel;
private CFTheme cfTheme;
private CoordinatorLayout loader;
private MerchantInfo merchantInfo;
private OrderDetails orderDetails;
private List<String> orderedUPIAppList;
private ArrayList<CFUPIApp> upiAppList;
private UPISeamlessBottomSheetDialog upiDialog;
private boolean isResponseSent = false;
private boolean isFresh = true;
private final CFSeamlessCallbacks cfNativeCoreCallbacks = new AnonymousClass1();
class AnonymousClass1 extends CFSeamlessCallbacks {
AnonymousClass1() {
}
@Override
public void onPaymentVerify(String orderID) {
CFDropSeamlessActivity.this.sendVerify(orderID);
}
@Override
public void onPaymentFailure(final CFErrorResponse cfErrorResponse, String orderID) {
ThreadUtil.runOnUIThread(new Runnable() {
@Override
public final void run() {
CFDropSeamlessActivity.AnonymousClass1.this.m222xbae1e565(cfErrorResponse);
}
});
}
void m222xbae1e565(CFErrorResponse cfErrorResponse) {
CFDropSeamlessActivity.this.hideLoader();
CFDropSeamlessActivity.this.handleError(cfErrorResponse);
}
@Override
public void onQRFetched(String base64Icon) {
}
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cf_ui_modal);
CFCorePaymentGatewayService.getInstance().setCheckoutCallback(this.cfNativeCoreCallbacks);
CFCorePaymentGatewayService.getInstance().setQRCallback(this.cfNativeCoreCallbacks);
this.loader = (CoordinatorLayout) findViewById(R.id.cf_loader);
this.cfDropSeamlessViewModel = new CFDropSeamlessViewModel(new INetworkChecks() {
@Override
public final boolean isNetworkConnected() {
return CFDropSeamlessActivity.this.m217xd7725b30();
}
}, this, this);
if (Build.VERSION.SDK_INT != 26) {
setRequestedOrientation(1);
}
this.cfTheme = this.cfDropSeamlessViewModel.getTheme();
setTheme();
showLoader();
this.cfDropSeamlessViewModel.fetchData();
}
boolean m217xd7725b30() {
return NetworkConnectivityUtil.isNetworkConnected(getApplicationContext());
}
@Override
protected BaseViewModel getViewModel() {
return this.cfDropSeamlessViewModel;
}
void m219x9ab0f4e6() {
this.loader.setVisibility(0);
}
public void showLoader() {
runOnUiThread(new Runnable() {
@Override
public final void run() {
CFDropSeamlessActivity.this.m219x9ab0f4e6();
}
});
}
public void hideLoader() {
runOnUiThread(new Runnable() {
@Override
public final void run() {
CFDropSeamlessActivity.this.m216xfebf9eac();
}
});
}
void m216xfebf9eac() {
this.loader.setVisibility(8);
}
public void sendVerify(final String orderId) {
finish();
if (!this.isResponseSent) {
this.isResponseSent = true;
if (orderId != null) {
ThreadUtil.runOnUIThread(new Runnable() {
@Override
public final void run() {
CFNativeCallbackEventBus.getInstance().publishEvent(new CFNativeCallbackEventBus.CFPaymentCallbackEvent(CFNativeCallbackEvents.onVerify, orderId, null));
}
});
}
}
}
@Override
protected void onResume() {
super.onResume();
if (this.isFresh) {
this.isFresh = false;
} else {
this.cfDropSeamlessViewModel.getOrderStatus();
}
}
public void handleError(CFErrorResponse cfErrorResponse) {
sendError(cfErrorResponse);
}
private void sendError(final CFErrorResponse cfErrorResponse) {
finish();
if (!this.isResponseSent) {
this.isResponseSent = true;
final String orderId = this.cfDropSeamlessViewModel.getOrderId();
if (orderId != null) {
ThreadUtil.runOnUIThread(new Runnable() {
@Override
public final void run() {
CFNativeCallbackEventBus.getInstance().publishEvent(new CFNativeCallbackEventBus.CFPaymentCallbackEvent(CFNativeCallbackEvents.onFailure, orderId, cfErrorResponse));
}
});
}
}
}
public void showUPIDialog() {
if (!isDestroyed()) {
hideLoader();
hideUPIDialog();
UPISeamlessBottomSheetDialog uPISeamlessBottomSheetDialog = new UPISeamlessBottomSheetDialog(this, this.upiAppList, this.orderedUPIAppList, this.blacklistedUPIAppList, this.orderDetails, this.merchantInfo, this.cfTheme, this);
this.upiDialog = uPISeamlessBottomSheetDialog;
uPISeamlessBottomSheetDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
CFDropSeamlessActivity.this.m220x5ac17479(dialogInterface);
}
});
this.upiDialog.show();
}
}
void m220x5ac17479(DialogInterface d) {
sendError(CFUtil.getResponseFromError(CFUtil.getCancelledResponse()));
}
private void hideUPIDialog() {
UPISeamlessBottomSheetDialog uPISeamlessBottomSheetDialog = this.upiDialog;
if (uPISeamlessBottomSheetDialog != null && uPISeamlessBottomSheetDialog.isShowing()) {
this.upiDialog.dismiss();
}
}
private void getUPIApps(CFUPIUtil.UPIAppsCallback upiAppsCallback) {
CFUPIUtil.getInstalledUPIApps(this, upiAppsCallback);
}
@Override
public void onPayInitiate(PaymentInitiationData paymentInitiationData) {
this.cfDropSeamlessViewModel.buildUPIPayment(paymentInitiationData);
}
@Override
public void onDataFetched(ConfigResponse configResponse, List<CFPaymentModes> cfPaymentModes, CFDropCheckoutPayment cfDropCheckoutPayment) {
this.orderDetails = configResponse.getOrderDetails();
this.merchantInfo = configResponse.getMerchantInfo();
this.orderedUPIAppList = configResponse.getFeatureConfig().getPaymentModeConfig().getUpiPriorityApps();
this.blacklistedUPIAppList = configResponse.getFeatureConfig().getPaymentModeConfig().getUpiBlacklistedApps();
if (cfPaymentModes.contains(CFPaymentModes.UPI)) {
startPayment();
} else {
sendError(CFUtil.getResponseFromError(CFUtil.getFailedResponse("UPI is not enabled for this order.")));
}
}
private void startPayment() {
if (this.upiAppList == null) {
getUPIApps(new CFUPIUtil.UPIAppsCallback() {
@Override
public final void onUPIAppsFetched(ArrayList arrayList) {
CFDropSeamlessActivity.this.m221x73f0213f(arrayList);
}
});
} else {
showUPIDialog();
}
}
void m221x73f0213f(ArrayList upiAppList) {
this.upiAppList = upiAppList;
ThreadUtil.runOnUIThread(new Runnable() {
@Override
public final void run() {
CFDropSeamlessActivity.this.showUPIDialog();
}
});
}
@Override
public void onDataFetchFailed(CFErrorResponse cfErrorResponse) {
sendError(cfErrorResponse);
}
@Override
public void onPaymentInitiate(final CFPayment cfPayment) {
ThreadUtil.runOnUIThread(new Runnable() {
@Override
public final void run() {
CFDropSeamlessActivity.this.m218x35d3d942(cfPayment);
}
});
}
void m218x35d3d942(CFPayment cfPayment) {
try {
showLoader();
CFCorePaymentGatewayService.getInstance().doPayment(this, cfPayment);
} catch (CFException e) {
e.printStackTrace();
}
}
private void setTheme() {
int toolbarColor = Color.parseColor(this.cfTheme.getNavigationBarBackgroundColor());
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progress_bar);
progressBar.getIndeterminateDrawable().setColorFilter(toolbarColor, PorterDuff.Mode.MULTIPLY);
}
}