From a62905c725c5ffd88f29dfac644591cde18751e1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 10 九月 2020 13:40:09 +0800
Subject: [PATCH] 广告优化

---
 BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java |   74 +++++++++++++++++++++++++++++++++---
 1 files changed, 67 insertions(+), 7 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
index dc44f86..404d563 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
@@ -1,26 +1,86 @@
 package com.weikou.beibeivideo.util.ad;
 
+import android.content.Context;
+import android.content.SharedPreferences;
+
 import com.weikou.beibeivideo.entity.ad.AdTypeVO;
 import com.weikou.beibeivideo.util.BeibeiConstant;
+import com.weikou.beibeivideo.util.downutil.StringUtils;
 
-//绌垮北鐢插箍鍛�
+import org.json.JSONException;
+import org.json.JSONObject;
+
+//骞垮憡甯姪
 public class AdUtil {
 
+    public enum AD_TYPE {
+        gdt("骞跨偣閫�"), csj("绌垮北鐢�"), gdt2("骞跨偣閫�2.0");
 
-    public static int getSmallExpressAdType() {
+        private String name;
+
+        private AD_TYPE(String name) {
+            this.name = name;
+        }
+
+    }
+
+    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 static AD_TYPE getSmallExpressAdType() {
         if (BeibeiConstant.AD_TYPE != null && AdTypeVO.TYPE_CSJ.equalsIgnoreCase(BeibeiConstant.AD_TYPE.getExpressSmallType())) {
-            return ExpressAdManager.SOURCE_CSJ;
+            return AD_TYPE.csj;
         } else {
-            return ExpressAdManager.SOURCE_GDT;
+            return AD_TYPE.gdt;
         }
     }
 
-    public static int getBigExpressAdType() {
+    public static AD_TYPE getBigExpressAdType() {
         if (BeibeiConstant.AD_TYPE != null && AdTypeVO.TYPE_CSJ.equalsIgnoreCase(BeibeiConstant.AD_TYPE.getExpressBigType())) {
-            return ExpressAdManager.SOURCE_CSJ;
+            return AD_TYPE.csj;
         } else {
-            return ExpressAdManager.SOURCE_GDT2;
+            return AD_TYPE.gdt2;
         }
     }
 
+    /**
+     * 淇濆瓨骞垮憡閰嶇疆
+     *
+     * @param context
+     * @param json
+     */
+    public static void saveAdConfig(Context context, JSONObject json) {
+        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = share.edit();
+        editor.putString("config", json.toString());
+        editor.commit();
+    }
+
+    /**
+     * 鑾峰彇骞垮憡绫诲瀷
+     *
+     * @param context
+     * @param positionName
+     * @return
+     */
+    public static AD_TYPE getAdType(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);
+                return AD_TYPE.valueOf(object.optString(positionName));
+            } catch (JSONException e) {
+                e.printStackTrace();
+            } catch (Exception e1) {
+                return null;
+            }
+        } else {
+            return AD_TYPE.gdt;
+        }
+        return null;
+    }
+
+
 }

--
Gitblit v1.8.0