admin
2020-08-14 bbe126bc62902f3bb5d6d9db48d398efcb7f98c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
package com.weikou.beibeivideo.ui.recommend;
 
import android.app.Activity;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
 
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bytedance.sdk.openadsdk.TTAdDislike;
import com.bytedance.sdk.openadsdk.TTNativeExpressAd;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.lcjian.library.util.SystemCommon;
import com.lcjian.library.util.common.DimenUtils;
import com.lcjian.library.util.common.StringUtils;
import com.lcjian.library.widget.RatioLayout;
import com.viewpagerindicator.LinePageIndicator;
import com.weikou.beibeivideo.entity.HomeType;
import com.weikou.beibeivideo.entity.HomeVideo;
import com.weikou.beibeivideo.entity.VideoInfo;
import com.weikou.beibeivideo.entity.VideoType;
import com.weikou.beibeivideo.entity.ad.ExpressAdContainer;
import com.weikou.beibeivideo.entity.recommend.HomeTypeContent;
import com.weikou.beibeivideo.entity.recommend.RecommendContent;
import com.weikou.beibeivideo.entity.recommend.holder.RecommendVideoAdHolder;
import com.weikou.beibeivideo.entity.video.holder.VideoHolder;
import com.weikou.beibeivideo.ui.common.VideosLiveActivity;
import com.weikou.beibeivideo.ui.discover.StarsActivity;
import com.weikou.beibeivideo.ui.media.VideoDetailActivity;
import com.weikou.beibeivideo.util.VideoUtil;
import com.weikou.beibeivideo.util.ad.AdUtil;
import com.weikou.beibeivideo.util.ad.ExpressAdManager;
import com.yeshi.buwanshequ.R;
 
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
 
public class RecommendNewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
 
    private final static String TAG = "RecommendNewAdapter";
 
    private Activity mContext;
    List<RecommendContent> contentList;
    private LayoutInflater inflater;
 
    public RecommendNewAdapter(Activity context, List<RecommendContent> contentList) {
        this.mContext = context;
        this.contentList = contentList;
        inflater = LayoutInflater.from(mContext);
    }
 
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case RecommendContent.TYPE_BANNER:
                return new HomeBannerHolder(inflater.inflate(R.layout.recommend_top, parent, false));
            case RecommendContent.TYPE_HOMETYPE:
                return new HomeTypeHolder(inflater.inflate(R.layout.item_recommend_home_type, null, false), new RecyclerView.RecycledViewPool());
            case RecommendContent.TYPE_AD:
                return new AdHolder(inflater.inflate(R.layout.item_recommend_home_type_ad, parent, false));
        }
        return null;
    }
 
 
    private Runnable autoPlayBanner = null;
 
    private synchronized void autoPlayBanner(final ViewPager viewPager) {
 
        if (autoPlayBanner == null) {
            autoPlayBanner = new Runnable() {
                @Override
                public void run() {
                    try {
                        if (contentList != null && contentList.size() > 0 && contentList.get(0).getType() == RecommendContent.TYPE_BANNER)
                            if (contentList.get(0).getHomeBannerList() == null || contentList.get(0).getHomeBannerList().size() <= 0)
                                return;
                        if (viewPager.getCurrentItem() >= contentList.get(0).getHomeBannerList().size() - 1) {
                            viewPager.setCurrentItem(0, true);
                        } else {
                            viewPager.setCurrentItem(viewPager.getCurrentItem() + 1, true);
                        }
                        autoPlayBanner(viewPager);
                    } catch (Exception e) {
 
                    }
                }
            };
            viewPager.postDelayed(autoPlayBanner, 3000);
        } else {
            viewPager.removeCallbacks(autoPlayBanner);
            viewPager.postDelayed(autoPlayBanner, 3000);
        }
    }
 
    RecyclerView.ItemDecoration itemDecoration = new RecyclerView.ItemDecoration() {
        @Override
        public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
            super.onDraw(c, parent, state);
        }
 
        @Override
        public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
            super.onDrawOver(c, parent, state);
        }
 
        @Override
        public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
            super.getItemOffsets(outRect, view, parent, state);
            int index = parent.getChildAdapterPosition(view);
            int total = parent.getAdapter().getItemCount();
            if (index % 2 == 0) {
                outRect.left = 0; //第一列左边贴边
                outRect.right = DimenUtils.dipToPixels(5, view.getContext());
            } else {
                outRect.right = 0; //第一列左边贴边
                outRect.left = DimenUtils.dipToPixels(5, view.getContext());
            }
 
            if (index - 1 > 0) {
                outRect.top = DimenUtils.dipToPixels(5, view.getContext());
            } else
                outRect.top = 0;
 
            if (total % 2 == 0) {
                if (total > 2 && (index < total - 2))
                    outRect.bottom = DimenUtils.dipToPixels(5, view.getContext());
                else
                    outRect.bottom = 0;
            } else {
                if (total > 2 && (index < total - 1))
                    outRect.bottom = DimenUtils.dipToPixels(5, view.getContext());
                else
                    outRect.bottom = 0;
            }
 
//                    if (parent.getChildAdapterPosition(view) >= 3) {
//                        outRect.top = SizeUtils.dp2px(mContext, 10);
//                    } else {
//                        outRect.top = 0;
//                    }
        }
    };
 
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
        final RecommendContent content = contentList.get(i);
        if (viewHolder instanceof HomeBannerHolder) {
            int width = (int) SystemCommon.getScreenWidth(mContext);
            HomeBannerHolder holder = (HomeBannerHolder) viewHolder;
            if (holder.vp_recommend.getAdapter() != null) {
                holder.vp_recommend.getAdapter().notifyDataSetChanged();
//                if (holder.vp_recommend.getAdapter().getCount() > 0)
//                    holder.vp_recommend.setCurrentItem(0);
            } else {
                holder.vp_recommend.setAdapter(new RecommendTopAdapter(content.getHomeBannerList(), mContext, false));
            }
            holder.indicator_recommend.setScreenWidth(width);
            holder.indicator_recommend.setSelectedColor(holder.vp_recommend.getContext().getResources()
                    .getColor(R.color.yellow));
            holder.indicator_recommend.setUnselectedColor(0xbbADA9A7);
            holder.indicator_recommend.setViewPager(holder.vp_recommend);
            autoPlayBanner(holder.vp_recommend);
        } else if (viewHolder instanceof HomeTypeHolder) {
            final HomeType homeType = content.getHomeType();
            HomeTypeHolder holder = (HomeTypeHolder) viewHolder;
            if (homeType == null) {
                holder.view.setVisibility(View.GONE);
                return;
            }
            holder.view.setVisibility(View.VISIBLE);
 
            if (holder.rv_content.getLayoutManager() == null || !(holder.rv_content.getLayoutManager() instanceof GridLayoutManager)) {
                RecyclerView.LayoutManager layoutManager = new GridLayoutManager(mContext, 4);
                holder.rv_content.setLayoutManager(layoutManager);
            }
            //统一分为2列
            ((GridLayoutManager) holder.rv_content.getLayoutManager()).setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
                @Override
                public int getSpanSize(int position) {
                    return 2;
                }
            });
            boolean isFirst = false;
            for (RecommendContent content1 : contentList)
                if (content1.getType() == RecommendContent.TYPE_HOMETYPE) {
                    if (content1.getHomeType().getId().equalsIgnoreCase(content.getHomeType().getId())) {
                        isFirst = true;
                    }
                    break;
                }
 
            HomeTypeContentAdapter adapter = new HomeTypeContentAdapter(mContext, homeType.getHomeVideoList(), isFirst ? true : false, 8);
            holder.rv_content.setAdapter(adapter);
 
            //设置间距
            holder.rv_content.removeItemDecoration(itemDecoration);
            holder.rv_content.addItemDecoration(itemDecoration);
 
            Glide.with(mContext).load(homeType.getIcon())
                    .diskCacheStrategy(DiskCacheStrategy.SOURCE).placeholder(R.drawable.ic_stars_collection).into(holder.tv_category_icon);
            holder.tv_category_name.setText(homeType.getName());
            if (Boolean.parseBoolean(homeType.getHasMore())) {
                holder.tv_more.setVisibility(View.VISIBLE);
            } else {
                holder.tv_more.setVisibility(View.GONE);
            }
 
            holder.tv_more
                    .setOnClickListener(new OnClickListener() {
 
                        @Override
                        public void onClick(View v) {
                            Intent intent = null;
                            if (homeType.getId().equalsIgnoreCase("1111")) {
                                intent = new Intent(v.getContext(),
                                        VideosLiveActivity.class);
                                intent.putExtra("home_type", homeType.getId());
                                intent.putExtra("title", homeType.getName());
                                v.getContext().startActivity(intent);
                            } else if (homeType.getId().equalsIgnoreCase("9998")) {
                                intent = new Intent(v.getContext(), StarsActivity.class);
                                v.getContext().startActivity(intent);
                            } else {
                                Gson gson = new GsonBuilder()
                                        .setFieldNamingPolicy(FieldNamingPolicy.UPPER_CAMEL_CASE)
                                        .create();
                                VideoType type = gson.fromJson(homeType.getParams().replace(
                                        "\\" + "\"", "\""), VideoType.class);
                                try {
                                    intent = new Intent(v.getContext(), Class.forName(homeType.getActivity()));
                                    intent.putExtra("video_type", type);
                                    intent.putExtra("type_name", type.getName());
                                    intent.putExtra("isPush", false);
                                    v.getContext().startActivity(intent);
                                } catch (ClassNotFoundException e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    });
 
 
        } else if (viewHolder instanceof AdHolder) {
            final AdHolder holder = (AdHolder) viewHolder;
            holder.fl_ad.removeAllViews();
            final ExpressAdContainer ad = content.getAd();
 
            if (ad != null) {
                holder.ll_container.setVisibility(View.VISIBLE);
                if (ad.getGdt() != null) {
//                    ad.getGdt().setAdEventListener(new AdEventListener() {
//                        @Override
//                        public void onClick() {
//
//                        }
//
//                        @Override
//                        public void onExposed() {
//
//                        }
//
//                        @Override
//                        public void onRenderSuccess() {
//                            holder.fl_ad.addView(ad.getGdt().getAdView());
//                        }
//
//                        @Override
//                        public void onRenderFail() {
//
//                        }
//
//                        @Override
//                        public void onAdClosed() {
//                            ad.getGdt().destroy();
//                            contentList.remove(content);
//                            notifyDataSetChanged();
//                        }
//                    });
                    ad.getGdt().render();
                    holder.fl_ad.addView(ad.getGdt());
                } else if (ad.getCsj() != null) {
                    ViewParent parent = ad.getCsj().getExpressAdView().getParent();
                    if (parent != null) {
                        FrameLayout parentContainer = (FrameLayout) parent;
                        parentContainer.removeAllViews();
                    }
                    ad.getCsj().setDislikeCallback(mContext, new TTAdDislike.DislikeInteractionCallback() {
                        @Override
                        public void onSelected(int i, String s) {
                            contentList.remove(content);
                            notifyDataSetChanged();
                        }
 
                        @Override
                        public void onCancel() {
 
                        }
 
                        @Override
                        public void onRefuse() {
 
                        }
                    });
                    ad.getCsj().setExpressInteractionListener(new TTNativeExpressAd.ExpressAdInteractionListener() {
 
                        @Override
                        public void onAdClicked(View view, int i) {
 
                        }
 
                        @Override
                        public void onAdShow(View view, int i) {
                            Log.i(TAG, "onAdShow");
                        }
 
                        @Override
                        public void onRenderFail(View view, String s, int i) {
 
                        }
 
                        @Override
                        public void onRenderSuccess(View view, float v, float v1) {
//                            holder.rl_title_item.setVisibility(View.VISIBLE);
                            Log.i(TAG, "onRenderSuccess");
//                            holder.rl_title_item.setVisibility(View.VISIBLE);
                        }
                    });
 
                    ad.getCsj().render();
                    holder.fl_ad.addView(ad.getCsj().getExpressAdView());
                }
            } else {
                holder.ll_container.setVisibility(View.GONE);
            }
        }
    }
 
    @Override
    public int getItemCount() {
        return this.contentList.size();
    }
 
    /**
     * banner第一栏,视频内容第二栏,广告第三栏和最后一栏
     *
     * @param position
     * @return
     */
    //获取类型
    @Override
    public int getItemViewType(int position) {
        return this.contentList.get(position).getType();
    }
 
    class HomeBannerHolder extends RecyclerView.ViewHolder {
        ViewPager vp_recommend;
        LinearLayout ll_ad_containner;
        RatioLayout rl_recommend_top;
        LinePageIndicator indicator_recommend;
        FrameLayout fl_ad;
 
        public HomeBannerHolder(View view) {
            super(view);
            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);
            indicator_recommend = view.findViewById(R.id.indicator_recommend);
            fl_ad = view.findViewById(R.id.fl_ad);
        }
    }
 
    class HomeTypeHolder extends RecyclerView.ViewHolder {
        TextView tv_category_name;
        ImageView tv_category_icon;
        TextView tv_more;
        RecyclerView rv_content;
        RelativeLayout rl_title_item;
        View view;
 
        public HomeTypeHolder(View convertView, RecyclerView.RecycledViewPool recycledViewPool) {
            super(convertView);
            this.view = convertView;
            rl_title_item = convertView
                    .findViewById(R.id.rl_title_item);
            tv_category_name = convertView
                    .findViewById(R.id.tv_category_name);
            tv_category_icon = convertView
                    .findViewById(R.id.tv_category_icon);
            tv_more = convertView
                    .findViewById(R.id.tv_more);
            rv_content = convertView
                    .findViewById(R.id.rv_content);
            if (recycledViewPool != null)
                rv_content.setRecycledViewPool(recycledViewPool);
        }
    }
 
    class AdHolder extends RecyclerView.ViewHolder {
 
        FrameLayout fl_ad;
        RelativeLayout rl_title_item;
        LinearLayout ll_container;
 
 
        public AdHolder(View view) {
            super(view);
            ll_container = view.findViewById(R.id.ll_container);
            fl_ad = view.findViewById(R.id.fl_ad);
            rl_title_item = view.findViewById(R.id.rl_title_item);
        }
 
    }
 
 
    public class HomeTypeContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
        private Activity mContext;
        private List<HomeTypeContent> contentList;
        private int maxItemNum;
 
        private ExpressAdManager expressAdManager;
 
        private boolean needAd;
 
 
        public HomeTypeContentAdapter(final Activity context, List<HomeVideo> videoList, boolean needAd, int maxItemNum) {
            this.needAd = needAd;
            this.mContext = context;
            if (contentList == null)
                this.contentList = new ArrayList<>();
            this.contentList.clear();
            for (HomeVideo hv : videoList) {
                this.contentList.add(new HomeTypeContent(HomeTypeContent.TYPE_CONTENT, hv));
            }
 
 
            if (needAd) {
                if (expressAdManager == null)
                    expressAdManager = new ExpressAdManager(AdUtil.getSmallExpressAdType(), mContext);
                expressAdManager.loadRecommendSmallAd(new ExpressAdManager.IAdLoadListener() {
                    @Override
                    public void onSuccess(List<ExpressAdContainer> adList) {
                        if (adList != null && adList.size() > 0) {
                            if (contentList != null && contentList.size() > 0 && contentList.get(0).getType() == HomeTypeContent.TYPE_CONTENT) {
                                contentList.add(0, new HomeTypeContent(HomeTypeContent.TYPE_AD, adList.get(0)));
                                notifyDataSetChanged();
                            }
                        }
                    }
                });
            }
 
 
            this.maxItemNum = maxItemNum;
        }
 
        @Override
        public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int type) {
            switch (type) {
                case HomeTypeContent.TYPE_AD:
                    return new RecommendVideoAdHolder(inflater.inflate(R.layout.item_ad_list_small, parent, false));
                case HomeTypeContent.TYPE_CONTENT:
                    return new VideoHolder(inflater.inflate(R.layout.item_movie, parent, false));
            }
            return null;
        }
 
        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int p) {
            final HomeTypeContent content = contentList.get(p);
            if (viewHolder instanceof VideoHolder) {
                VideoHolder holder = (VideoHolder) viewHolder;
                final HomeVideo info = content.getHomeVideo();
                //设置内容
                holder.ll_video_show.setVisibility(View.VISIBLE);
                if (StringUtils.isEmpty(info.getPicture())) {
                    Glide.with(mContext).load(info.getVideo().getPicture())
                            .placeholder(R.drawable.ic_default_cover)
                            .error(R.drawable.ic_default_cover)
                            .centerCrop().crossFade()
                            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                            .into(holder.iv_movie_cover);
                } else {
                    try {
                        Glide.with(mContext).load(info.getPicture())
                                .placeholder(R.drawable.ic_default_cover)
                                .error(R.drawable.ic_default_cover)
                                .centerCrop().crossFade()
                                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                                .into(holder.iv_movie_cover);
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    }
                }
                holder.tv_movie_title.setText(info.getVideo().getName());
                holder.tv_movie_rating.setText(StringUtils.isBlank(info
                        .getVideo().getTag()) ? "" : info.getVideo()
                        .getTag());
                DecimalFormat df = new DecimalFormat("###.0");
                holder.tv_movie_play_num.setText(VideoUtil.getWatchCountShortName(info.getVideo().getWatchCount()));
                holder.tv_movie_comment_num.setText(StringUtils.isBlank(info.getVideo().getCommentCount()) ? "0" : info.getVideo().getCommentCount());
                holder.ll_video_show
                        .setOnClickListener(new OnClickListener() {
                            @Override
                            public void onClick(final View v) {
                                //跳转到商品视频播放页
                                myClick(info.getVideo(), v);
                            }
                        });
            } else if (viewHolder instanceof RecommendVideoAdHolder) {//广告
                final RecommendVideoAdHolder holder = (RecommendVideoAdHolder) viewHolder;
                holder.fl_container.removeAllViews();
 
                final ExpressAdContainer ad = content.getAd();
                if (ad == null) {//广告为空
                    holder.view.setVisibility(View.GONE);
                } else {
                    holder.view.setVisibility(View.VISIBLE);
                    if (ad.getGdt() != null) {
                        holder.rl_container.setRatio(0.88f);
                        holder.tv_movie_title.setVisibility(View.GONE);
//                        ad.getGdt().setAdEventListener(new AdEventListener() {
//                            @Override
//                            public void onClick() {
//
//                            }
//
//                            @Override
//                            public void onExposed() {
//
//                            }
//
//                            @Override
//                            public void onRenderSuccess() {
//                                holder.fl_container.addView(ad.getGdt().getAdView());
//                            }
//
//                            @Override
//                            public void onRenderFail() {
//
//                            }
//
//                            @Override
//                            public void onAdClosed() {
//                                ad.getGdt().destroy();
//                                contentList.remove(content);
//                                notifyDataSetChanged();
//                            }
//                        });
                        ad.getGdt().render();
                        holder.fl_container.addView(ad.getGdt());
                        holder.tv_movie_play_num.setText("112");
                    } else if (ad.getCsj() != null) {
                        holder.rl_container.setRatio(0.88f);
                        holder.tv_movie_title.setVisibility(View.GONE);
                        ad.getCsj().setDislikeCallback(mContext, new TTAdDislike.DislikeInteractionCallback() {
 
                            @Override
                            public void onSelected(int i, String s) {
                                contentList.remove(content);
                                notifyDataSetChanged();
                            }
 
                            @Override
                            public void onCancel() {
 
                            }
 
                            @Override
                            public void onRefuse() {
 
                            }
                        });
                        ad.getCsj().render();
                        holder.fl_container.addView(ad.getCsj().getExpressAdView());
                    }
                }
            }
        }
 
        @Override
        public int getItemCount() {
            int count = contentList.size();
            if (count > maxItemNum)
                return maxItemNum;
            else
                return count % 2 == 0 ? count : count - 1;
        }
 
        @Override
        public int getItemViewType(int position) {
            return this.contentList.get(position).getType();
        }
 
 
        private void myClick(VideoInfo info, final View v) {
            Intent intent = new Intent(v.getContext(), VideoDetailActivity.class);
            intent.putExtra("video_info", info);
            v.getContext().startActivity(intent);
        }
 
    }
 
}