七色猫视频 v9.9.9版本的 MD5 值为:6e3740f68cd7a75ec951b5f356e1fd2c

以下内容为反编译后的 AdShowActivity.java 源代码,内容仅作参考


package com.yz.dsp.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.constraintlayout.utils.widget.ImageFilterView;
import bcchys.galthy.xtmmao.R;
import butterknife.BindView;
import com.alipay.sdk.app.PayTask;
import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.just.agentweb.AgentWeb;
import com.umeng.analytics.MobclickAgent;
import com.yz.baselib.base.BaseActivity;
import com.yz.baselib.base.UserManager;
import com.yz.baselib.net.exception.ErrorException;
import com.yz.baselib.net.factory.ServiceFactory;
import com.yz.baselib.net.observer.ToastObserver;
import com.yz.baselib.net.transformer.LifeCycleTransformer;
import com.yz.baselib.net.transformer.RemoteTransformer;
import com.yz.baselib.ui.activity.H5PayInAppActivity;
import com.yz.baselib.utils.Base64Utils;
import com.yz.baselib.utils.LogUtils;
import com.yz.baselib.utils.WechatSdkUtil;
import com.yz.baselib.widget.MLoadingDialog;
import com.yz.dsp.apiservice.AppApiService;
import com.yz.dsp.bean.AdInfoBean;
import com.yz.dsp.bean.PayResult;
import com.yz.dsp.bean.WechatBookingResponseBean;
import com.yz.dsp.event.RechargeSuccessEvent;
import com.yz.dsp.util.ImageUtil;
import java.util.ArrayList;
import java.util.Map;
import org.greenrobot.eventbus.EventBus;
import wendu.dsbridge.DWebView;
public class AdShowActivity extends BaseActivity implements View.OnClickListener {
    private static final int QUERY_RESULT = 2;
    private static final int SDK_PAY_FLAG = 1;
    private AdInfoBean adInfoBean;
    @BindView(R.id.fraWebview)
    FrameLayout fraWebview;
    @BindView(R.id.acInfo)
    ImageFilterView imageView;
    @BindView(R.id.ivClose)
    ImageView ivClose;
    @BindView(R.id.llPayMethod)
    LinearLayout llPayMethod;
    private String rechargeId;
    @BindView(R.id.payWx)
    LinearLayout rootWx;
    @BindView(R.id.payZfb)
    LinearLayout rootZfb;
    @BindView(R.id.viewWx)
    View viewWx;
    @BindView(R.id.viewZfb)
    View viewZfb;
    private final String PAY_WAY_WX = "wx";
    private final String PAY_WAY_ALI = "zfb";
    private String payType = "wx";
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(Message message) {
            int i = message.what;
            if (i != 1) {
                if (i != 2 || TextUtils.isEmpty(AdShowActivity.this.rechargeId) || AdShowActivity.this.isFinishing()) {
                    return;
                }
                AdShowActivity.this.queryPayResult();
                return;
            }
            PayResult payResult = new PayResult((Map) message.obj);
            payResult.getResult();
            String resultStatus = payResult.getResultStatus();
            MLoadingDialog.cancelLoadingDialog(AdShowActivity.this);
            if (TextUtils.equals(resultStatus, "9000")) {
                EventBus.getDefault().post(new RechargeSuccessEvent());
                ToastUtils.showShort(Base64Utils.decode(AdShowActivity.this.getString(R.string.chongzhi)) + "成功");
            } else {
                ToastUtils.showShort(Base64Utils.decode(AdShowActivity.this.getString(R.string.zhifu)) + "失败");
            }
            LogUtils.e("ccc1122", "alipay recharge result");
        }
    };

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_adinfo;
    }

    @Override
    protected void initVariables() {
    }

    @Override
    protected boolean shouldBindEvent() {
        return false;
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        uploadEvent(SPUtils.getInstance().getString("ad_before", "http://download.angtouyi.com/?t=test_1"));
    }

    @Override
    public void onResume() {
        super.onResume();
        if (TextUtils.isEmpty(this.rechargeId)) {
            return;
        }
        queryPayResult();
    }

    private void uploadEvent(String str) {
        if (TextUtils.isEmpty(str)) {
            return;
        }
        openWebview(str);
    }

    private void openWebview(String str) {
        AgentWeb.with(this).setAgentWebParent(this.fraWebview, new LinearLayout.LayoutParams(-1, -1)).useDefaultIndicator().setWebViewClient(new WebViewClient() {
        }).setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView webView, int i) {
                super.onProgressChanged(webView, i);
                Log.d("onProgressChanged", i + "");
            }
        }).setWebView(new DWebView(this)).createAgentWeb().ready().go(str);
    }

    public void queryPayResult() {
        MLoadingDialog.showLoadingDialog(this);
        ((AppApiService) ServiceFactory.createYZService(AppApiService.class)).getAdInfo(UserManager.getChannel()).compose(new RemoteTransformer(this)).compose(new LifeCycleTransformer(this.ivClose)).subscribe(new ToastObserver<AdInfoBean>(this) {
            @Override
            public void onCatchNext(AdInfoBean adInfoBean) throws Exception {
                if (AdShowActivity.this.isFinishing()) {
                    return;
                }
                MLoadingDialog.cancelLoadingDialog(AdShowActivity.this);
                AdShowActivity.this.rechargeId = "";
                if (adInfoBean == null) {
                    AdShowActivity.this.mHandler.sendEmptyMessageDelayed(2, 2000L);
                    return;
                }
                if (adInfoBean.isShow()) {
                    AdShowActivity.this.showImage(adInfoBean);
                }
                if (!adInfoBean.isPay()) {
                    AdShowActivity.this.mHandler.sendEmptyMessageDelayed(2, 2000L);
                } else {
                    AdShowActivity.this.mHandler.removeMessages(2);
                }
            }

            @Override
            public void onError(ErrorException errorException) {
                super.onError(errorException);
                MLoadingDialog.cancelLoadingDialog(AdShowActivity.this);
                AdShowActivity.this.mHandler.sendEmptyMessageDelayed(2, 2000L);
            }
        });
    }

    @Override
    protected void initViews() {
        AdInfoBean adInfoBean = (AdInfoBean) getIntent().getSerializableExtra("bean");
        if (adInfoBean != null) {
            showImage(adInfoBean);
        }
        this.ivClose.setOnClickListener(this);
        this.imageView.setOnClickListener(this);
        this.rootZfb.setOnClickListener(this);
        this.rootWx.setOnClickListener(this);
        MobclickAgent.onEvent(this, "pay_ad_show");
    }

    public void showImage(AdInfoBean adInfoBean) {
        String imgBefore;
        this.adInfoBean = adInfoBean;
        if (adInfoBean.getAmount().equals("0")) {
            imgBefore = adInfoBean.getImgAfter();
        } else if (adInfoBean.isPay()) {
            imgBefore = adInfoBean.getImgAfter();
        } else {
            imgBefore = adInfoBean.getImgBefore();
        }
        if (!TextUtils.isEmpty(imgBefore)) {
            ImageUtil.loadImageNoPlaceholder(this.imageView, imgBefore);
        } else {
            finish();
        }
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.acInfo:
                AdInfoBean adInfoBean = this.adInfoBean;
                if (adInfoBean != null) {
                    if (adInfoBean.getAmount().equals("0")) {
                        openSysBrower();
                        return;
                    } else if (!this.adInfoBean.isPay()) {
                        showPayMethod();
                        return;
                    } else {
                        openSysBrower();
                        return;
                    }
                }
                return;
            case R.id.ivClose:
                finish();
                return;
            case R.id.payWx:
                this.payType = "wx";
                this.viewZfb.setSelected(false);
                this.viewWx.setSelected(true);
                goPay();
                return;
            case R.id.payZfb:
                this.payType = "zfb";
                this.viewWx.setSelected(false);
                this.viewZfb.setSelected(true);
                goPay();
                return;
            default:
                return;
        }
    }

    private void showPayMethod() {
        if (this.llPayMethod.getVisibility() == 0) {
            this.llPayMethod.setVisibility(8);
            return;
        }
        uploadEvent(SPUtils.getInstance().getString("ad_after", "http://download.oduixpniy.com/?t=test_2"));
        ArrayList<String> payFlag = this.adInfoBean.getPayFlag();
        if (payFlag != null && payFlag.size() != 0) {
            if (payFlag.contains("zfb")) {
                this.rootZfb.setVisibility(0);
            }
            if (payFlag.contains("wx")) {
                this.rootWx.setVisibility(0);
            }
        }
        this.llPayMethod.setVisibility(0);
    }

    private void openSysBrower() {
        MobclickAgent.onEvent(this, "pay_ad_link");
        this.adInfoBean.getLink();
        startActivity(new Intent("android.intent.action.VIEW", Uri.parse("")));
    }

    private void goPay() {
        if ("wx".equals(this.payType)) {
            requetPay();
        } else if ("zfb".equals(this.payType)) {
            requetPay();
        } else {
            ToastUtils.showShort("请选择" + Base64Utils.decode(getString(R.string.chongzhi)) + "方式");
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        Handler handler = this.mHandler;
        if (handler != null) {
            handler.removeMessages(2);
        }
    }

    private void requetPay() {
        MLoadingDialog.showLoadingDialog(this);
        this.llPayMethod.setVisibility(8);
        ((AppApiService) ServiceFactory.createYZService(AppApiService.class)).adToPay(this.payType).compose(new RemoteTransformer(this)).compose(new LifeCycleTransformer(this.llPayMethod)).subscribe(new ToastObserver<WechatBookingResponseBean>(this) {
            @Override
            public void onCatchNext(WechatBookingResponseBean wechatBookingResponseBean) throws Exception {
                MLoadingDialog.cancelLoadingDialog(AdShowActivity.this);
                if ("wx".equals(AdShowActivity.this.payType)) {
                    AdShowActivity.this.wxPay(wechatBookingResponseBean);
                } else if ("zfb".equals(AdShowActivity.this.payType)) {
                    AdShowActivity.this.aliPay(wechatBookingResponseBean);
                }
            }

            @Override
            public void onError(ErrorException errorException) {
                super.onError(errorException);
                MLoadingDialog.cancelLoadingDialog(AdShowActivity.this);
            }
        });
    }

    public void wxPay(WechatBookingResponseBean wechatBookingResponseBean) {
        if (wechatBookingResponseBean != null) {
            int payType = wechatBookingResponseBean.getPayType();
            if (payType == -1) {
                ToastUtils.showShort("微信" + Base64Utils.decode(getString(R.string.zhifu)) + "错误,请重试");
                MLoadingDialog.cancelLoadingDialog(this);
                return;
            } else if (payType == 1) {
                wechatPaySdk(wechatBookingResponseBean);
                return;
            } else if (payType == 2) {
                this.rechargeId = wechatBookingResponseBean.getTradeId() + "";
                wechatPayH5(wechatBookingResponseBean);
                return;
            } else if (payType == 5) {
                WechatSdkUtil.startMiniProgramPay(wechatBookingResponseBean.getAppid(), wechatBookingResponseBean.getUsername(), wechatBookingResponseBean.getOrderInfo());
                return;
            } else {
                ToastUtils.showShort("暂不支持此" + Base64Utils.decode(getString(R.string.zhifu)) + "方式请更新至最新版本");
                MLoadingDialog.cancelLoadingDialog(this);
                return;
            }
        }
        MLoadingDialog.cancelLoadingDialog(this);
    }

    private void wechatPaySdk(WechatBookingResponseBean wechatBookingResponseBean) {
        if (WechatSdkUtil.isWeixinAvilible(this)) {
            WechatSdkUtil.startWechatPay(wechatBookingResponseBean.getAppid(), wechatBookingResponseBean.getPartnerid(), wechatBookingResponseBean.getPrepayid(), wechatBookingResponseBean.getNoncestr(), wechatBookingResponseBean.getSign(), wechatBookingResponseBean.getTimestamp());
            return;
        }
        MLoadingDialog.cancelLoadingDialog(this);
        ToastUtils.showShort("未安装微信");
    }

    private void wechatPayH5(WechatBookingResponseBean wechatBookingResponseBean) {
        MLoadingDialog.cancelLoadingDialog(this);
        H5PayInAppActivity.launch(this, wechatBookingResponseBean.getOrderInfo());
    }

    public void aliPay(WechatBookingResponseBean wechatBookingResponseBean) {
        if (wechatBookingResponseBean != null) {
            int payType = wechatBookingResponseBean.getPayType();
            if (payType == -1) {
                ToastUtils.showShort(Base64Utils.decode(getString(R.string.zhifu)) + "宝" + Base64Utils.decode(getString(R.string.zhifu)) + "错误,请重试");
                MLoadingDialog.cancelLoadingDialog(this);
                return;
            } else if (payType == 1) {
                alipaySdk(wechatBookingResponseBean);
                return;
            } else if (payType == 2) {
                this.rechargeId = wechatBookingResponseBean.getTradeId();
                alipayH5(wechatBookingResponseBean);
                return;
            } else {
                return;
            }
        }
        MLoadingDialog.cancelLoadingDialog(this);
    }

    private void alipaySdk(WechatBookingResponseBean wechatBookingResponseBean) {
        final String orderInfo = wechatBookingResponseBean.getOrderInfo();
        new Thread(new Runnable() {
            @Override
            public void run() {
                Map<String, String> payV2 = new PayTask(AdShowActivity.this).payV2(orderInfo, true);
                Log.i("msg", payV2.toString());
                Message message = new Message();
                message.what = 1;
                message.obj = payV2;
                AdShowActivity.this.mHandler.sendMessage(message);
            }
        }).start();
    }

    private void alipayH5(WechatBookingResponseBean wechatBookingResponseBean) {
        MLoadingDialog.cancelLoadingDialog(this);
        if (TextUtils.isEmpty(wechatBookingResponseBean.getOrderInfo())) {
            ToastUtils.showShort(Base64Utils.decode(getString(R.string.zhifu)) + "错误,请重试");
            return;
        }
        H5PayInAppActivity.launch(this, wechatBookingResponseBean.getOrderInfo());
    }
}