导航菜单

页面标题

页面副标题

Rilo v2.0.21 - CFDropSeamlessActivity.java 源代码

正在查看: Rilo v2.0.21 应用的 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 {
        @Override
        public void onQRFetched(String str) {
        }

        AnonymousClass1() {
        }

        @Override
        public void onPaymentVerify(String str) {
            CFDropSeamlessActivity.this.sendVerify(str);
        }

        @Override
        public void onPaymentFailure(final CFErrorResponse cFErrorResponse, String str) {
            ThreadUtil.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    CFDropSeamlessActivity.AnonymousClass1.this.m169xbae1e565(cFErrorResponse);
                }
            });
        }

        void m169xbae1e565(CFErrorResponse cFErrorResponse) {
            CFDropSeamlessActivity.this.hideLoader();
            CFDropSeamlessActivity.this.handleError(cFErrorResponse);
        }
    }

    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_cf_ui_modal);
        CFCorePaymentGatewayService.getInstance().setCheckoutCallback(this.cfNativeCoreCallbacks);
        CFCorePaymentGatewayService.getInstance().setQRCallback(this.cfNativeCoreCallbacks);
        this.loader = findViewById(R.id.cf_loader);
        this.cfDropSeamlessViewModel = new CFDropSeamlessViewModel(new INetworkChecks() {
            @Override
            public final boolean isNetworkConnected() {
                return CFDropSeamlessActivity.this.m164xd7725b30();
            }
        }, this, this);
        if (Build.VERSION.SDK_INT != 26) {
            setRequestedOrientation(1);
        }
        this.cfTheme = this.cfDropSeamlessViewModel.getTheme();
        setTheme();
        showLoader();
        this.cfDropSeamlessViewModel.fetchData();
    }

    boolean m164xd7725b30() {
        return NetworkConnectivityUtil.isNetworkConnected(getApplicationContext());
    }

    @Override
    protected BaseViewModel getViewModel() {
        return this.cfDropSeamlessViewModel;
    }

    void m166x9ab0f4e6() {
        this.loader.setVisibility(0);
    }

    public void showLoader() {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                CFDropSeamlessActivity.this.m166x9ab0f4e6();
            }
        });
    }

    public void hideLoader() {
        runOnUiThread(new Runnable() {
            @Override
            public final void run() {
                CFDropSeamlessActivity.this.m163xfebf9eac();
            }
        });
    }

    void m163xfebf9eac() {
        this.loader.setVisibility(8);
    }

    public void sendVerify(final String str) {
        finish();
        if (this.isResponseSent) {
            return;
        }
        this.isResponseSent = true;
        if (str != null) {
            ThreadUtil.runOnUIThread(new Runnable() {
                @Override
                public final void run() {
                    CFNativeCallbackEventBus.getInstance().publishEvent(new CFNativeCallbackEventBus.CFPaymentCallbackEvent(CFNativeCallbackEvents.onVerify, str, 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) {
            return;
        }
        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()) {
            return;
        }
        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.m167x5ac17479(dialogInterface);
            }
        });
        this.upiDialog.show();
    }

    void m167x5ac17479(DialogInterface dialogInterface) {
        sendError(CFUtil.getResponseFromError(CFUtil.getCancelledResponse()));
    }

    private void hideUPIDialog() {
        UPISeamlessBottomSheetDialog uPISeamlessBottomSheetDialog = this.upiDialog;
        if (uPISeamlessBottomSheetDialog == null || !uPISeamlessBottomSheetDialog.isShowing()) {
            return;
        }
        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> list, CFDropCheckoutPayment cFDropCheckoutPayment) {
        this.orderDetails = configResponse.getOrderDetails();
        this.merchantInfo = configResponse.getMerchantInfo();
        this.orderedUPIAppList = configResponse.getFeatureConfig().getPaymentModeConfig().getUpiPriorityApps();
        this.blacklistedUPIAppList = configResponse.getFeatureConfig().getPaymentModeConfig().getUpiBlacklistedApps();
        if (list.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.m168x73f0213f(arrayList);
                }
            });
        } else {
            showUPIDialog();
        }
    }

    void m168x73f0213f(ArrayList arrayList) {
        this.upiAppList = arrayList;
        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.m165x35d3d942(cFPayment);
            }
        });
    }

    void m165x35d3d942(CFPayment cFPayment) {
        try {
            showLoader();
            CFCorePaymentGatewayService.getInstance().doPayment(this, cFPayment);
        } catch (CFException e) {
            e.printStackTrace();
        }
    }

    private void setTheme() {
        ((ProgressBar) findViewById(R.id.progress_bar)).getIndeterminateDrawable().setColorFilter(Color.parseColor(this.cfTheme.getNavigationBarBackgroundColor()), PorterDuff.Mode.MULTIPLY);
    }
}