From 2f9e1cb327b1d58e4035b77bd903a452774ce66b Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期六, 17 十月 2020 17:28:57 +0800 Subject: [PATCH] 广告控制完善 --- BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java index 404d563..4065590 100644 --- a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java +++ b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java @@ -27,6 +27,7 @@ public final static String POSITION_SPLASH = "splash";//寮�灞� public final static String POSITION_VIDEO_PLAY_PRE = "videoPlayPre";//瑙嗛鎾斁鍓嶈创 public final static String POSITION_EXIT_APP = "exitApp";//APP閫�鍑哄箍鍛� + public final static String POSITION_SEARCH = "videoSearch";//鎼滅储椤靛箍鍛� public static AD_TYPE getSmallExpressAdType() { if (BeibeiConstant.AD_TYPE != null && AdTypeVO.TYPE_CSJ.equalsIgnoreCase(BeibeiConstant.AD_TYPE.getExpressSmallType())) { @@ -70,7 +71,9 @@ if (!StringUtils.isNullOrEmpty(config)) {//涓囦竴娌¤缃捣灏辩敤骞跨偣閫� try { JSONObject object = new JSONObject(config); - return AD_TYPE.valueOf(object.optString(positionName)); + object = object.optJSONObject(positionName); + if (object != null) + return AD_TYPE.valueOf(object.optString("type")); } catch (JSONException e) { e.printStackTrace(); } catch (Exception e1) { @@ -82,5 +85,25 @@ return null; } + public static String getAdPid(Context context, String positionName) { + SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE); + String config = share.getString("config", ""); + if (!StringUtils.isNullOrEmpty(config)) {//涓囦竴娌¤缃捣灏辩敤骞跨偣閫� + try { + JSONObject object = new JSONObject(config); + object = object.optJSONObject(positionName); + if (object != null) + return object.optString("pid"); + } catch (JSONException e) { + e.printStackTrace(); + } catch (Exception e1) { + return null; + } + } else { + return null; + } + return null; + } + } -- Gitblit v1.8.0