From fd0097a37e24c771d5ad271135e48e8f52e325e0 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 21 十二月 2021 16:59:55 +0800
Subject: [PATCH] 3.10.9

---
 BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java b/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
index a565d91..499037c 100644
--- a/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
+++ b/BuWanVideo/src/com/weikou/beibeivideo/ui/recommend/RecommendFragment.java
@@ -55,12 +55,14 @@
 import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
 import com.weikou.beibeivideo.entity.recommend.HomeClass;
 import com.weikou.beibeivideo.ui.category.bean.HotStar;
+import com.weikou.beibeivideo.ui.main.FeedVideoFragment;
 import com.weikou.beibeivideo.ui.main.MainActivity;
 import com.weikou.beibeivideo.ui.media.VideoDetailActivity;
 import com.weikou.beibeivideo.ui.mine.BrowserActivity;
 import com.weikou.beibeivideo.util.BeibeiConstant;
 import com.weikou.beibeivideo.util.CustomShareDialog;
 import com.weikou.beibeivideo.util.DimenUtils;
+import com.weikou.beibeivideo.util.JsonUtil;
 import com.weikou.beibeivideo.util.JumpActivityUtil;
 import com.weikou.beibeivideo.util.ad.AdUtil;
 import com.weikou.beibeivideo.util.ad.ExpressAdManager;
@@ -85,6 +87,8 @@
 
 public class RecommendFragment extends RetainViewFragment implements
         OnClickListener {
+
+    private final String TAG = "RecommendFragment";
 
     private SwipeRefreshLayout rl_recommend;
 
@@ -126,6 +130,8 @@
             bundle.putInt("position", Integer.parseInt(position));
             fragment.setArguments(bundle);
             return fragment;
+        } else if ("feedVideos".equalsIgnoreCase(type.getDataType())) {
+            return new FeedVideoFragment();
         } else {
             CategoryRecommendFragment fragment = new CategoryRecommendFragment();
             Bundle bundle = new Bundle();
@@ -189,7 +195,8 @@
             return;
         if (mRecommendNewAdapter.getAdCount() == 0) {
             if (adList != null && adList.size() > 0) {
-                mRecommendNewAdapter.addAdToPosition(adList.get(0), 3);
+                mRecommendNewAdapter.addAdToPosition(adList.get(0), 1);
+                adList.remove(0);
             }
             mRecommendNewAdapter.notifyDataSetChanged();
         }
@@ -377,7 +384,16 @@
 
     private List<ExpressAdContainer> adList;
 
-    private void loadAd() {
+    private synchronized void loadAd() {
+        //鏈夋病娑堣�楃殑骞垮憡
+        if (RecommendFragment.this.adList != null && RecommendFragment.this.adList.size() > 0) {
+            return;
+        }
+        if (position != 0)//鍙湁鎺ㄨ崘鎵嶆湁骞垮憡
+        {
+            return;
+        }
+        Log.i(TAG, "璇锋眰棣栭〉澶у箍鍛�");
         try {
             ExpressAdManager recommendAdManager = new ExpressAdManager(AdUtil.AD_TYPE.csj, context);
             recommendAdManager.loadRecommendLargeAd(new ExpressAdManager.IAdLoadListener() {
@@ -412,6 +428,7 @@
         } catch (Exception e) {
 
         }
+
     }
 
 
@@ -510,9 +527,7 @@
             try {
                 snapshot = cache.get(getKey("getHomeType") + type.getId());
                 if (snapshot != null) {
-                    Gson gson = new GsonBuilder().setFieldNamingPolicy(
-                            FieldNamingPolicy.UPPER_CAMEL_CASE).create();
-                    List<HomeType> homeTypes = gson.fromJson(
+                    List<HomeType> homeTypes = JsonUtil.videoGson.fromJson(
                             snapshot.getString(0),
                             new TypeToken<List<HomeType>>() {
                             }.getType());
@@ -679,14 +694,10 @@
                                                  Header[] headers, JSONObject jsonObject)
                             throws Exception {
                         if (jsonObject.getBoolean("IsPost")) {
-                            Gson gson = new GsonBuilder()
-                                    .setPrettyPrinting()
-                                    .setFieldNamingPolicy(
-                                            FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                    .create();
+
                             JSONObject data = jsonObject
                                     .getJSONObject("Data");
-                            List<HomeAd> homeAds = gson.fromJson(data.getJSONArray("data")
+                            List<HomeAd> homeAds = JsonUtil.videoGson.fromJson(data.getJSONArray("data")
                                     .toString(), new TypeToken<List<HomeAd>>() {
                             }.getType());
                             //鑾峰彇banner姣斾緥
@@ -738,9 +749,7 @@
                                                  Header[] headers, JSONObject jsonObject)
                             throws Exception {
                         if (jsonObject.getBoolean("IsPost")) {
-                            Gson gson = new GsonBuilder().setVersion(1.0).setFieldNamingPolicy(
-                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                    .create();
+
                             List<HomeType> homeTypes = new ArrayList<HomeType>();
                             JSONArray array = jsonObject.getJSONObject("Data")
                                     .getJSONArray("data");
@@ -764,7 +773,7 @@
 
 
                                 if (obj.optJSONObject("Ad") != null)
-                                    type.setAd(gson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class));
+                                    type.setAd(JsonUtil.videoGson.fromJson(obj.optJSONObject("Ad").toString(), HomeType.HomeTypeAd.class));
 
                                 JSONArray homeArray = obj
                                         .optJSONArray("HomeVideoList");
@@ -772,7 +781,7 @@
                                 if (homeArray != null && homeArray.length() > 0) {
                                     for (int j = 0; j < homeArray.length(); j++) {
 
-                                        homeList.add(gson.fromJson(homeArray
+                                        homeList.add(JsonUtil.videoGson.fromJson(homeArray
                                                         .optJSONObject(j).toString(),
                                                 HomeVideo.class));
                                     }
@@ -786,7 +795,7 @@
                                 if (itemArray != null && itemArray.length() > 0) {
                                     for (int k = 0; k < itemArray.length(); k++) {
                                         if (itemArray.optJSONObject(k) != null) {
-                                            itemList.add(gson.fromJson(
+                                            itemList.add(JsonUtil.videoGson.fromJson(
                                                     itemArray.optJSONObject(k)
                                                             .toString(),
                                                     HomeTypeItem.class));
@@ -880,10 +889,8 @@
                             throws Exception {
                         if (jsonObject.getBoolean("IsPost")) {
                             hotStars.clear();
-                            Gson gson = new GsonBuilder().setFieldNamingPolicy(
-                                    FieldNamingPolicy.UPPER_CAMEL_CASE)
-                                    .create();
-                            List<HotStar> hotStarList = gson.fromJson(
+
+                            List<HotStar> hotStarList = JsonUtil.videoGson.fromJson(
                                     jsonObject.getJSONObject("Data")
                                             .getJSONArray("data").toString(),
                                     new TypeToken<List<HotStar>>() {

--
Gitblit v1.8.0