导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - ChargeActivity.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 ChargeActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.luanxingyuan.app.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import com.luanxingyuan.app.base.AppManager;
import com.luanxingyuan.app.base.BaseActivity;
import com.luanxingyuan.app.base.BaseListResponse;
import com.luanxingyuan.app.base.BaseResponse;
import com.luanxingyuan.app.bean.BalanceBean;
import com.luanxingyuan.app.bean.ChargeListBean;
import com.luanxingyuan.app.bean.PayOptionBean;
import com.luanxingyuan.app.util.CodeUtil;
import com.luanxingyuan.app.util.ParamUtil;
import com.luanxingyuan.app.util.ToastUtil;
import com.pay.paytypelibrary.OrderInfo;
import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.tencent.open.SocialConstants;
import com.unionpay.UPPayAssistEx;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import k6.e0;
import x8.c0;

public class ChargeActivity extends BaseActivity {
    private k6.h mAdapter;

    @BindView
    RecyclerView mContentRv;

    @BindView
    TextView mGoldNumberTv;
    private g mMyBroadcastReceiver;
    private e0 mOptionRecyclerAdapter;
    private List<PayOptionBean> mPayOptionBeans = new ArrayList();

    @BindView
    RecyclerView mPayOptionRv;
    private PayOptionBean mSelectedBean;
    private List<ChargeListBean> removeList;

    class a implements e0.c {
        a() {
        }

        @Override
        public void a(PayOptionBean payOptionBean) {
            if (payOptionBean != null) {
                ChargeActivity.this.mSelectedBean = payOptionBean;
                ChargeActivity.this.getChargeList(payOptionBean.payType);
            }
        }
    }

    class b extends r6.a<BaseListResponse<PayOptionBean>> {
        b() {
        }

        public void onResponse(BaseListResponse<PayOptionBean> baseListResponse, int i8) {
            List<PayOptionBean> list;
            if (ChargeActivity.this.isFinishing() || baseListResponse == null || baseListResponse.m_istatus != 1 || (list = baseListResponse.m_object) == null || list.size() <= 0) {
                return;
            }
            Iterator<PayOptionBean> it = list.iterator();
            while (true) {
                if (!it.hasNext()) {
                    break;
                }
                PayOptionBean next = it.next();
                if (next.isdefault == 1) {
                    ChargeActivity.this.mSelectedBean = next;
                    ChargeActivity.this.mSelectedBean.isSelected = true;
                    break;
                }
            }
            ChargeActivity.this.mPayOptionBeans = list;
            if (ChargeActivity.this.mSelectedBean == null) {
                ChargeActivity chargeActivity = ChargeActivity.this;
                chargeActivity.mSelectedBean = (PayOptionBean) chargeActivity.mPayOptionBeans.get(0);
                ChargeActivity.this.mSelectedBean.isSelected = true;
            }
            ChargeActivity.this.mOptionRecyclerAdapter.b(ChargeActivity.this.mPayOptionBeans);
        }
    }

    class c extends r6.a<BaseResponse<BalanceBean>> {
        c() {
        }

        public void onResponse(BaseResponse<BalanceBean> baseResponse, int i8) {
            BalanceBean balanceBean;
            if (ChargeActivity.this.isFinishing() || baseResponse == null || baseResponse.m_istatus != 1 || (balanceBean = baseResponse.m_object) == null) {
                return;
            }
            ChargeActivity.this.mGoldNumberTv.setText(String.valueOf(balanceBean.amount));
        }
    }

    class d extends r6.a<BaseListResponse<ChargeListBean>> {

        class a implements Comparator<ChargeListBean> {
            a() {
            }

            @Override
            public int compare(ChargeListBean chargeListBean, ChargeListBean chargeListBean2) {
                return (int) (chargeListBean.jiesu - chargeListBean2.jiesu);
            }
        }

        class b implements Comparator<ChargeListBean> {
            b() {
            }

            @Override
            public int compare(ChargeListBean chargeListBean, ChargeListBean chargeListBean2) {
                return (int) (Double.parseDouble(chargeListBean.t_gold) - Double.parseDouble(chargeListBean2.t_gold));
            }
        }

        class c implements Comparator<ChargeListBean> {
            c() {
            }

            @Override
            public int compare(ChargeListBean chargeListBean, ChargeListBean chargeListBean2) {
                return (int) (Double.parseDouble(chargeListBean.t_gold) - Double.parseDouble(chargeListBean2.t_gold));
            }
        }

        d() {
        }

        public void onResponse(BaseListResponse<ChargeListBean> baseListResponse, int i8) {
            List<ChargeListBean> list;
            if (ChargeActivity.this.isFinishing() || baseListResponse == null || baseListResponse.m_istatus != 1 || (list = baseListResponse.m_object) == null) {
                return;
            }
            ChargeActivity.this.removeList = new ArrayList();
            for (ChargeListBean chargeListBean : list) {
                if (chargeListBean.t_describe.equals("%%")) {
                    String[] split = chargeListBean.t_money.split(",");
                    chargeListBean.chushi = Double.parseDouble(split[0]);
                    chargeListBean.jiesu = Double.parseDouble(split[1]);
                    ChargeActivity.this.removeList.add(chargeListBean);
                }
            }
            if (ChargeActivity.this.removeList.size() > 0) {
                Collections.sort(ChargeActivity.this.removeList, new a());
                list.removeAll(ChargeActivity.this.removeList);
                Collections.sort(list, new b());
                list.add((ChargeListBean) ChargeActivity.this.removeList.get(0));
            } else {
                Collections.sort(list, new c());
            }
            ChargeActivity.this.mAdapter.d();
            if (list.size() > 1) {
                list.get(1).isSelected = true;
            }
            ChargeActivity.this.mAdapter.f14333c = ChargeActivity.this.removeList;
            ChargeActivity.this.mAdapter.f(list);
        }

        public void onAfter(int i8) {
            super.onAfter(i8);
            ChargeActivity.this.dismissLoadingDialog();
        }

        public void onBefore(c0 c0Var, int i8) {
            super.onBefore(c0Var, i8);
            ChargeActivity.this.showLoadingDialog();
        }
    }

    class e extends z7.c {

        final ProgressDialog f6256a;

        final String f6257b;

        e(ProgressDialog progressDialog, String str) {
            this.f6256a = progressDialog;
            this.f6257b = str;
        }

        public void onError(x8.e eVar, Exception exc, int i8) {
            this.f6256a.dismiss();
            ToastUtil.showToast(2131821363);
        }

        public void onResponse(String str, int i8) {
            this.f6256a.dismiss();
            o6.g.L(((BaseActivity) ChargeActivity.this).mContext, "客服", 1, ChargeActivity.this.mSelectedBean.payName, this.f6257b);
        }
    }

    class f implements DialogInterface.OnClickListener {
        f() {
        }

        @Override
        public void onClick(DialogInterface dialogInterface, int i8) {
            dialogInterface.dismiss();
        }
    }

    class g extends BroadcastReceiver {
        g() {
        }

        @Override
        public void onReceive(Context context, Intent intent) {
            ChargeActivity.this.finish();
        }
    }

    public void getChargeList(int i8) {
        this.mAdapter.c();
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        hashMap.put("t_end_type", String.valueOf(i8));
        x7.a.h().c(m6.a.k0()).e("param", ParamUtil.getParam(hashMap)).f().c(new d());
    }

    private void getChargeOption() {
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        x7.a.h().c(m6.a.b0()).e("param", ParamUtil.getParam(hashMap)).f().c(new b());
    }

    private void getMyGold() {
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        x7.a.h().c(m6.a.z0()).e("param", ParamUtil.getParam(hashMap)).f().c(new c());
    }

    private void initStart() {
        this.mMyBroadcastReceiver = new g();
        registerReceiver(this.mMyBroadcastReceiver, new IntentFilter("com.newslapp.live.chargeclose"));
        e0 e0Var = new e0(this);
        this.mOptionRecyclerAdapter = e0Var;
        this.mPayOptionRv.setAdapter(e0Var);
        this.mPayOptionRv.setLayoutManager(new LinearLayoutManager(this));
        this.mPayOptionRv.setNestedScrollingEnabled(false);
        this.mOptionRecyclerAdapter.c(new a());
        this.mContentRv.setLayoutManager(new GridLayoutManager(getApplicationContext(), 3));
        k6.h hVar = new k6.h(this);
        this.mAdapter = hVar;
        this.mContentRv.setAdapter(hVar);
        this.mContentRv.setNestedScrollingEnabled(false);
    }

    public void lambda$onContentAdded$0(View view) {
        CodeUtil.jumpToQQ(this.mContext);
    }

    public void lambda$onContentAdded$1(View view) {
        CodeUtil.jumpToQQ(this.mContext);
    }

    private void payFor(Activity activity, String str, int i8, int i9, int i10, String str2) {
        ProgressDialog showLoading = showLoading(activity);
        HashMap hashMap = new HashMap();
        hashMap.put("userId", Integer.valueOf(AppManager.f().k().t_id));
        hashMap.put("setMealId", String.valueOf(i8));
        hashMap.put("payType", String.valueOf(i9));
        hashMap.put("payDeployId", String.valueOf(i10));
        if (!TextUtils.isEmpty(str2)) {
            hashMap.put("money", str2);
        }
        x7.a.h().c(str).e("param", ParamUtil.getParam(hashMap)).f().c(new e(showLoading, str2));
    }

    private static ProgressDialog showLoading(Activity activity) {
        ProgressDialog progressDialog = new ProgressDialog(activity);
        progressDialog.setMessage("请稍候...");
        progressDialog.setCancelable(false);
        progressDialog.show();
        return progressDialog;
    }

    public static void startUnionpay(Context context, String str) {
        UPPayAssistEx.startPay(context, (String) null, (String) null, str, "00");
    }

    public static void startWxpay(Context context, OrderInfo orderInfo) {
        String wxAppId = orderInfo.getWxAppId();
        IWXAPI createWXAPI = WXAPIFactory.createWXAPI(context, wxAppId);
        createWXAPI.registerApp(wxAppId);
        WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
        req.userName = orderInfo.getGhOriId();
        req.path = orderInfo.getPathUrl() + "token_id=" + orderInfo.getTokenId();
        req.miniprogramType = Integer.parseInt(orderInfo.getMiniProgramType());
        createWXAPI.sendReq(req);
    }

    @Override
    protected View getContentView() {
        return inflate(2131492912);
    }

    @Override
    protected void onActivityResult(int i8, int i9, Intent intent) {
        String str;
        OrderInfo orderInfo;
        super.onActivityResult(i8, i9, intent);
        if (intent != null && i9 == -1) {
            if (i8 != 10) {
                if (i8 == 100 && (orderInfo = (OrderInfo) intent.getSerializableExtra("orderInfo")) != null) {
                    if (!TextUtils.isEmpty(orderInfo.getTokenId())) {
                        startWxpay(this.mContext, orderInfo);
                        return;
                    } else {
                        if (TextUtils.isEmpty(orderInfo.getTradeNo())) {
                            return;
                        }
                        startUnionpay(this.mContext, orderInfo.getTradeNo());
                        return;
                    }
                }
                return;
            }
            Bundle extras = intent.getExtras();
            if (extras == null) {
                return;
            }
            String string = extras.getString("pay_result");
            if (string != null) {
                if (string.equalsIgnoreCase("success")) {
                    str = "支付成功";
                } else if (string.equalsIgnoreCase("fail")) {
                    str = "支付失败";
                } else if (string.equalsIgnoreCase("cancel")) {
                    str = "用户取消支付";
                }
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setMessage(str);
                builder.setInverseBackgroundForced(true);
                builder.setNegativeButton("确定", new f());
                builder.create().show();
            }
            str = "支付异常";
            AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
            builder2.setMessage(str);
            builder2.setInverseBackgroundForced(true);
            builder2.setNegativeButton("确定", new f());
            builder2.create().show();
        }
    }

    @OnClick
    public void onClick(View view) {
        switch (view.getId()) {
            case 2131296308:
                startActivity(new Intent(getApplicationContext(), (Class<?>) AccountBalanceActivity.class));
                break;
            case 2131296729:
                if (this.mSelectedBean != null) {
                    ChargeListBean e8 = this.mAdapter.e();
                    if (e8 != null) {
                        String str = "https://xincz.wangyuekeji.cn?userid=" + getUserId() + "&money=" + e8.t_money + "&zfpay=" + this.mSelectedBean.payType;
                        Intent intent = new Intent(this, (Class<?>) WebActivity.class);
                        intent.putExtra(SocialConstants.PARAM_URL, str);
                        startActivity(intent);
                        break;
                    } else {
                        ToastUtil.showToast(this.mContext, 2131821160);
                        break;
                    }
                } else {
                    ToastUtil.showToast(getApplicationContext(), 2131821161);
                    break;
                }
            case 2131297055:
            case 2131297170:
                CodeUtil.jumpToQQ(this);
                break;
        }
    }

    @Override
    protected void onContentAdded() {
        setTitle(2131820725);
        setRightText(2131821300);
        initStart();
        getMyGold();
        getChargeOption();
        this.mRightTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChargeActivity.this.lambda$onContentAdded$0(view);
            }
        });
        findViewById(2131297055).setOnClickListener(new View.OnClickListener() {
            @Override
            public final void onClick(View view) {
                ChargeActivity.this.lambda$onContentAdded$1(view);
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        g gVar = this.mMyBroadcastReceiver;
        if (gVar != null) {
            unregisterReceiver(gVar);
        }
    }
}