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/ad/AdUtil.java |   85 +++++++++++++++++++++++++++++++++++++-----
 1 files changed, 74 insertions(+), 11 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
index 144f247..c97041c 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
@@ -2,7 +2,9 @@
 
 import android.content.Context;
 import android.content.SharedPreferences;
+import android.os.Build;
 
+import com.weikou.beibeivideo.entity.ad.AdPositionEnum;
 import com.weikou.beibeivideo.entity.ad.AdTypeVO;
 import com.weikou.beibeivideo.util.BeibeiConstant;
 import com.weikou.beibeivideo.util.downutil.StringUtils;
@@ -23,12 +25,6 @@
         }
 
     }
-
-    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 final static String POSITION_VIDEO_DETAIL_FULL_VIDEO = "videoDetailFullVideo";//瑙嗛鍏ㄥ睆骞垮憡
 
     public static AD_TYPE getSmallExpressAdType() {
         if (BeibeiConstant.AD_TYPE != null && AdTypeVO.TYPE_CSJ.equalsIgnoreCase(BeibeiConstant.AD_TYPE.getExpressSmallType())) {
@@ -63,16 +59,16 @@
      * 鑾峰彇骞垮憡绫诲瀷
      *
      * @param context
-     * @param positionName
+     * @param position
      * @return
      */
-    public static AD_TYPE getAdType(Context context, String positionName) {
+    public static AD_TYPE getAdType(Context context, AdPositionEnum position) {
         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);
+                object = object.optJSONObject(position.getPositionName());
                 if (object != null)
                     return AD_TYPE.valueOf(object.optString("type"));
             } catch (JSONException e) {
@@ -86,13 +82,13 @@
         return null;
     }
 
-    public static String getAdPid(Context context, String positionName) {
+    public static String getAdPid(Context context, AdPositionEnum position) {
         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);
+                object = object.optJSONObject(position.getPositionName());
                 if (object != null)
                     return object.optString("pid");
             } catch (JSONException e) {
@@ -106,5 +102,72 @@
         return null;
     }
 
+    /**
+     * 鏄惁鏄剧ずPPTV鍏嶅箍鍛婃潈鐩�
+     *
+     * @return
+     */
+    public static boolean showPPTVNoAdReward(Context context) {
+        return getAdType(context, AdPositionEnum.pptvNoAdReward) != null;
+    }
+
+    //鏄惁宸茬粡鑾峰緱pptv瑙嗛鍏嶅箍鍛婃潈鐩�
+    public static boolean isGetPPTVNoAdReward(Context context) {
+        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
+        long expireTime = share.getLong("pptvNoAdReward", 0);
+        if (System.currentTimeMillis() > expireTime) {
+            return false;
+        }
+        return true;
+    }
+
+    public static int getPPTVNoAdRewardLeftTimeWithMinute(Context context) {
+        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
+        long expireTime = share.getLong("pptvNoAdReward", 0);
+        if (System.currentTimeMillis() > expireTime) {
+            return 0;
+        } else {
+            return (int) ((expireTime - System.currentTimeMillis()) / (1000 * 60));
+        }
+    }
+
+    public static void setPPTVNoAdRewardSuccess(Context context) {
+        int hour = getPPTVNoAdRewardHour(context);
+        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = share.edit();
+        editor.putLong("pptvNoAdReward", System.currentTimeMillis() + 1000 * 60 * 60L * hour);
+        editor.commit();
+    }
+
+    //鑾峰彇pptv鍏嶅箍鍛婃潈鐩婄殑鏃堕棿锛堝皬鏃惰锛�
+    public static int getPPTVNoAdRewardHour(Context context) {
+        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
+        return share.getInt("pptvNoAdRewardHour", 3);
+    }
+
+    /**
+     * 璁剧疆pptv鏃犲箍鍛婃潈鐩婄殑鏃堕棿锛堝皬鏃惰锛�
+     *
+     * @param context
+     * @param hour
+     */
+    public static void setPPTVNoAdRewardHour(Context context, int hour) {
+        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
+        SharedPreferences.Editor editor = share.edit();
+        editor.putInt("pptvNoAdRewardHour", hour);
+        editor.commit();
+    }
+
+
+    /**
+     * 绌垮北鐢插箍鍛婃槸鍚﹂渶瑕佸垵濮嬪寲
+     *
+     * @return
+     */
+    public static boolean isCanInitCSJ() {
+        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
+//        return true;
+    }
+
 
 }

--
Gitblit v1.8.0