From 3c853e808d9e617662fd4ce207d609daa8681df3 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 13 三月 2021 16:42:04 +0800
Subject: [PATCH] 添加PPTV视频前贴中的免广告权益

---
 BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java b/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
index 3797b3f..5dd1aa3 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
@@ -66,6 +66,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -117,6 +118,7 @@
             Bundle bundle = new Bundle();
             bundle.putSerializable("videotype", type);
             bundle.putString("id", type.getId());
+            bundle.putInt("position", Integer.parseInt(position));
             fragment.setArguments(bundle);
             return fragment;
         }
@@ -134,8 +136,6 @@
         } catch (IOException e) {
             e.printStackTrace();
         }
-
-
 
 
     }
@@ -192,8 +192,6 @@
         vp_recommend = view.findViewById(R.id.vp_recommend);
         ll_ad_containner = view.findViewById(R.id.ll_ad_containner);
         rl_recommend_top = view.findViewById(R.id.rl_recommend_top);
-        if (position > 0)
-            rl_recommend_top.setRatio(0.56f);
         indicator_recommend = view.findViewById(R.id.indicator_recommend);
         mRecommendNewAdapter.setHeaderView(view);
         autoPlayBanner(vp_recommend);
@@ -390,6 +388,11 @@
             indicator_recommend.setViewPager(vp_recommend);
         } else
             vp_recommend.getAdapter().notifyDataSetChanged();
+        if (vp_recommend.getChildCount() == 1) {
+            indicator_recommend.setVisibility(View.GONE);
+        } else
+            indicator_recommend.setVisibility(View.VISIBLE);
+
     }
 
     private void loadCacheData() {
@@ -630,11 +633,16 @@
                                     .setFieldNamingPolicy(
                                             FieldNamingPolicy.UPPER_CAMEL_CASE)
                                     .create();
-                            List<HomeAd> homeAds = gson.fromJson(jsonObject
-                                    .getJSONObject("Data").getJSONArray("data")
+                            JSONObject data = jsonObject
+                                    .getJSONObject("Data");
+                            List<HomeAd> homeAds = gson.fromJson(data.getJSONArray("data")
                                     .toString(), new TypeToken<List<HomeAd>>() {
                             }.getType());
-
+                            //鑾峰彇banner姣斾緥
+                            String bannerSizeRate = data.optString("bannerSizeRate");
+                            if (!StringUtils.isEmpty(bannerSizeRate)) {
+                                rl_recommend_top.setRatio(new BigDecimal(bannerSizeRate).floatValue());
+                            }
                             if (homeAds != null) {
                                 mHomeAds.clear();
                                 mHomeAds.addAll(homeAds);
@@ -693,6 +701,7 @@
                                 type.setActivity(obj.optString("Activity"));
                                 type.setParams(obj.optString("Params"));
                                 type.setIcon(obj.optString("Icon"));
+                                type.setNeedAd(obj.optBoolean("NeedAd", false));
 
                                 JSONArray homeArray = obj
                                         .optJSONArray("HomeVideoList");

--
Gitblit v1.8.0