admin
2021-12-21 fd0097a37e24c771d5ad271135e48e8f52e325e0
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>>() {