From 2eec3de87b6b616a69a46c1f97c2397159031d2f Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 21 十一月 2023 18:01:43 +0800 Subject: [PATCH] 广告升级/bug修复 --- BuWanVideo/src/com/weikou/beibeivideo/util/JumpActivityUtil.java | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 155 insertions(+), 7 deletions(-) diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/JumpActivityUtil.java b/BuWanVideo/src/com/weikou/beibeivideo/util/JumpActivityUtil.java index 6109337..99d60a4 100644 --- a/BuWanVideo/src/com/weikou/beibeivideo/util/JumpActivityUtil.java +++ b/BuWanVideo/src/com/weikou/beibeivideo/util/JumpActivityUtil.java @@ -1,22 +1,42 @@ package com.weikou.beibeivideo.util; import android.app.Activity; +import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.webkit.WebChromeClient; +import android.webkit.WebView; import android.webkit.WebViewClient; import com.alibaba.baichuan.android.trade.AlibcTrade; -import com.alibaba.baichuan.android.trade.callback.AlibcTradeCallback; +import com.alibaba.baichuan.android.trade.AlibcTradeSDK; import com.alibaba.baichuan.android.trade.model.AlibcShowParams; import com.alibaba.baichuan.android.trade.model.OpenType; import com.alibaba.baichuan.android.trade.page.AlibcDetailPage; import com.alibaba.baichuan.trade.biz.AlibcConstants; +import com.alibaba.baichuan.trade.biz.AlibcTradeCallback; +import com.alibaba.baichuan.trade.biz.applink.adapter.AlibcFailModeType; import com.alibaba.baichuan.trade.biz.context.AlibcTradeResult; import com.alibaba.baichuan.trade.biz.core.taoke.AlibcTaokeParams; import com.alibaba.fastjson.JSONObject; import com.lcjian.library.util.common.StringUtils; +import com.tencent.mm.opensdk.constants.ConstantsAPI; +import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram; +import com.tencent.mm.opensdk.openapi.IWXAPI; +import com.tencent.mm.opensdk.openapi.WXAPIFactory; +import com.weikou.beibeivideo.BeibeiVideoApplication; import com.weikou.beibeivideo.entity.JumpDetail; +import com.weikou.beibeivideo.entity.VideoType; +import com.weikou.beibeivideo.entity.ad.RewardVideoAdContainer; +import com.weikou.beibeivideo.ui.category.MVideosActivity; +import com.weikou.beibeivideo.ui.dialog.LoadingDialogUtil; +import com.weikou.beibeivideo.ui.login.LoginActivity; +import com.weikou.beibeivideo.ui.mine.BrowserActivity; +import com.weikou.beibeivideo.util.ad.AdUtil; +import com.weikou.beibeivideo.util.ad.RewardVideoAdManager; +import com.weikou.beibeivideo.util.ad.RewardVideoAdUtil; +import com.weikou.beibeivideo.util.goldcorn.GoldCornUtil; import org.json.JSONException; @@ -93,7 +113,7 @@ AlibcDetailPage basePage = new AlibcDetailPage(auctionId); AlibcTrade.openByBizCode(mActivity, basePage, null, new WebViewClient(), new WebChromeClient(), "nativeDetail", alibcShowParams, - alibcTaokeParams, null, new AlibcTradeCallback(){ + alibcTaokeParams, null, new AlibcTradeCallback() { @Override public void onTradeSuccess(AlibcTradeResult alibcTradeResult) { @@ -120,6 +140,10 @@ return; if (detail == null) return; + if (detail.isNeedLogin() && !UserUtil.isLogin(context)) { + context.startActivity(new Intent(context, LoginActivity.class)); + return; + } String type = detail.getType(); switch (type) { @@ -129,20 +153,132 @@ String url = params.getString("url"); if (StringUtils.isEmpty(url)) return; + //璺宠浆鐧惧窛 AlibcShowParams alibcShowParams = new AlibcShowParams(); alibcShowParams.setOpenType(OpenType.Auto); - JumpActivityUtil.jumpBaiChuan(context, null, url, "", alibcShowParams); + alibcShowParams.setNativeOpenFailedMode(AlibcFailModeType.AlibcNativeFailModeJumpBROWER); +// AlibcTrade.openByUrl(GoodsDetailActivityTB.this, "", +// url, null, new WebViewClient(), new WebChromeClient(), +// alibcShowParams, alibcTaokeParams, exParams, new MiDuoTradeCallback("")); + + AlibcTaokeParams alibcTaokeParams = new AlibcTaokeParams("", "", ""); + alibcTaokeParams.setPid(BeibeiConstant.BAICHUAN_PID); + alibcTaokeParams.setAdzoneid(BeibeiConstant.BAICHUAN_ADZONE_ID); + alibcTaokeParams.pid = BeibeiConstant.BAICHUAN_PID; + alibcTaokeParams.adzoneid = BeibeiConstant.BAICHUAN_ADZONE_ID; + alibcTaokeParams.extraParams = new HashMap<>(); + alibcTaokeParams.extraParams.put("taokeAppkey", BeibeiConstant.BAICHUAN_APPKEY); + + AlibcTradeSDK.setTaokeParams(alibcTaokeParams); + AlibcTradeUtil.openByUrl(context, + url, null, new WebViewClient(), new WebChromeClient(), + alibcShowParams, alibcTaokeParams, null); break; + + case "wxxcx": + if (params == null) + return; + //寰俊灏忕▼搴� + String path = params.getString("path"); + String userName = params.getString("userName"); + if (StringUtils.isEmpty(userName)) { + return; + } + IWXAPI api = WXAPIFactory.createWXAPI(context, BeibeiConstant.WECHAT_ID, true); + WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req(); + req.userName = userName; // 濉皬绋嬪簭鍘熷id + req.path = path; ////鎷夎捣灏忕▼搴忛〉闈㈢殑鍙甫鍙傝矾寰勶紝涓嶅~榛樿鎷夎捣灏忕▼搴忛椤碉紝瀵逛簬灏忔父鎴忥紝鍙互鍙紶鍏� query 閮ㄥ垎锛屾潵瀹炵幇浼犲弬鏁堟灉锛屽锛氫紶鍏� "?foo=bar"銆� + req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE;// 鍙�夋墦寮� 寮�鍙戠増锛屼綋楠岀増鍜屾寮忕増 + api.sendReq(req); + + + break; + + case "web": + if (params == null) + return; + { + String webUrl = params.getString("url").toString(); + String title = params.getString("title"); + String close = params.getString("close"); + context.startActivity(new Intent(context, BrowserActivity.class).putExtra("url", webUrl).putExtra("title", title).putExtra("close", close)); + } + + + break; + + case "rewardVideo": { + LoadingDialogUtil.show(context); + AdUtil.AD_TYPE adType = AdUtil.AD_TYPE.valueOf(params.getString("adType")); + String pid = params.getString("pid"); + + RewardVideoAdManager.IAdShowListener showListener = new RewardVideoAdManager.IAdShowListener() { + + @Override + public void onShow() { + + } + + @Override + public void onReward() { + String code = params.getString("goldcorn"); + if (!StringUtils.isEmpty(code)) { + GoldCornUtil.makeGoldCorn(code, null, null, null); + } + } + + @Override + public void onError(String msg) { + LoadingDialogUtil.dismiss(); + } + + @Override + public void onClose() { + LoadingDialogUtil.dismiss(); + } + }; + + RewardVideoAdUtil.showAd(context, adType, pid, new RewardVideoAdManager.IAdLoadListener() { + + @Override + public void onSuccess(RewardVideoAdContainer ad) { + LoadingDialogUtil.dismiss(); + if (context != null) + context.runOnUiThread(new Runnable() { + @Override + public void run() { + LoadingDialogUtil.dismiss(); + RewardVideoAdManager.showAd(context, ad, showListener); + } + }); + } + + @Override + public void onError(String msg) { + LoadingDialogUtil.dismiss(); + } + }, showListener); + } + break; default: { try { Intent intent = new Intent(context, Class.forName(JumpActivityUtil.filterActivityName(detail.getActivity()))); - if (params != null) - for (Iterator<String> keys = params.keySet().iterator(); keys.hasNext(); ) { - String key = keys.next(); - intent.putExtra(key, params.getString(key)); + if (params != null) { + //鐗规畩澶勭悊 + if (MVideosActivity.class.getName().equalsIgnoreCase(JumpActivityUtil.filterActivityName(detail.getActivity())) && !StringUtils.isEmpty(params.getString("Id"))) { + VideoType videoType = new VideoType(); + videoType.setId(params.getString("Id")); + videoType.setName(params.getString("Name")); + intent.putExtra("video_type", videoType); + } else { + for (Iterator<String> keys = params.keySet().iterator(); keys.hasNext(); ) { + String key = keys.next(); + intent.putExtra(key, params.getString(key)); + } } + } context.startActivity(intent); } catch (Exception e) { e.printStackTrace(); @@ -159,4 +295,16 @@ return activity; } + public static JSONObject getParamsJSON(String params) { + if (params == null || StringUtils.isEmpty(params)) + return null; + String fparams = params.replace( + "\\" + "\"", "\""); + try { + return JSONObject.parseObject(fparams); + } catch (Exception e) { + return null; + } + } + } -- Gitblit v1.8.0