admin
2021-12-24 f6b84428fce7453689956eae44e71b33a69a4665
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
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
package com.hanju.video.app.ui.media;
 
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
 
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.gson.FieldNamingPolicy;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.hanju.video.app.util.JsonUtil;
import com.hanju.video.app.util.http.BasicTextHttpResponseHandler;
import com.hanju.video.app.util.http.HttpApiUtil;
import com.hanju.video.app.R;
import com.hanju.video.app.entity.video.Play;
import com.hanju.video.app.entity.video.PlayUrl;
import com.hanju.video.app.entity.video.Playlocation;
import com.hanju.video.app.entity.video.VideoDetailInfo;
import com.hanju.video.app.entity.video.VideoInfo;
import com.hanju.video.app.entity.video.VideoResource;
import com.hanju.video.app.entity.ad.ExpressAdContainer;
import com.hanju.video.app.ui.login.LoginActivity;
import com.hanju.video.app.ui.video.EpisodeNewAdapter;
import com.hanju.video.app.ui.video.IVideoClickListener;
import com.hanju.video.app.ui.video.VideoColumn2Adapter;
import com.hanju.video.app.util.video.VideoUtil;
import com.hanju.video.app.util.ad.AdUtil;
import com.hanju.video.app.util.ad.ExpressAdManager;
import com.hanju.lib.library.RetainViewFragment;
import com.hanju.lib.library.util.SingleToast;
import com.hanju.lib.library.util.common.DimenUtils;
import com.hanju.lib.library.util.common.StringUtils;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
 
import org.apache.http.Header;
import org.json.JSONObject;
 
import java.util.List;
 
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import de.greenrobot.event.EventBus;
 
/**
 * 节目选集列表,可设置电视剧6列;电影,综艺1列
 */
public class EpisodeFragment extends RetainViewFragment implements View.OnClickListener {
    private int mStart;
    private int mEnd;
    private int mPlayingPosition;
    private VideoInfo mVideoInfo = null;
    private RecyclerView rv_episode, rv_video_related_video, rv_video_guess_like;
 
    private ImageView iv_moive_img;
 
    private TextView tv_star_name, tv_update_time, tv_cancle_follow, tv_title, tv_desc, tv_play_num, tv_score;
 
    private LinearLayout ll_add_attention;
 
    private FrameLayout fl_native_ad1;
 
    private EpisodeNewAdapter episodeAdapter;
 
    private ProgressDialog pd;
 
    private LinearLayout ll_score;
    private per.wsj.library.AndRatingBar arb_score;
 
    final String TAG = "EpisodeFragment";
 
    private LinearLayout ll_indicator;
 
    private String resourceId;
 
    public static DisplayImageOptions option = new DisplayImageOptions.Builder()
            .showImageForEmptyUri(R.drawable.from_other)
            .showImageOnFail(R.drawable.from_other)
            .showImageOnLoading(R.drawable.from_other)
            .resetViewBeforeLoading(false) // default
            .cacheInMemory(true) // default
            .cacheOnDisk(true) // default
            .considerExifParams(false) // default
            .imageScaleType(ImageScaleType.EXACTLY) // default
            .bitmapConfig(Bitmap.Config.ARGB_8888) // default
            .handler(new Handler()) // default
            .build();
 
    public static EpisodeFragment newInstance(VideoInfo videoInfo,
                                              int playingPosition, String resourceId, int start, int end) {
        EpisodeFragment episodeFragment = new EpisodeFragment();
        Bundle args = new Bundle();
        args.putSerializable("video_info", videoInfo);
        args.putInt("playing_position", playingPosition);
        args.putInt("start", start);
        args.putInt("end", end);
        args.putString("resourceId", resourceId);
        episodeFragment.setArguments(args);
        return episodeFragment;
    }
 
    @Override
    public int getContentResource() {
        return R.layout.fragment_episode;
    }
 
 
    /**
     * 设置视频信息
     */
    private void setVideoInfo() {
        if (mVideoInfo == null)
            return;
        tv_title.setText(mVideoInfo.getName());
        tv_desc.setText(mVideoInfo.getIntroduction() == null ? "" : mVideoInfo.getIntroduction());
 
        if (!StringUtils.isBlank(mVideoInfo.getScore())) {
            tv_score.setText("评分:" + mVideoInfo.getScore());
            tv_score.setVisibility(View.VISIBLE);
            ll_score.setVisibility(View.VISIBLE);
            arb_score.setRating(Float.parseFloat(mVideoInfo.getScore()) / 2);
        } else {
            tv_score.setVisibility(View.GONE);
            ll_score.setVisibility(View.GONE);
        }
        tv_play_num.setText(VideoUtil.getWatchCountShortName(mVideoInfo.getWatchCount()) + " 次播放");
 
        setIndicatorSelectedEvent();
        ll_indicator.post(new Runnable() {
            @Override
            public void run() {
                ll_indicator.getChildAt(0).performClick();
            }
        });
        guessLike();
        getRelativeVideos();
    }
 
    public class SpacesItemDecoration extends RecyclerView.ItemDecoration {
        private int space;
 
        public SpacesItemDecoration(int space) {
            this.space = space;
        }
 
        @Override
        public void getItemOffsets(Rect outRect, View view,
                                   RecyclerView parent, RecyclerView.State state) {
            int position = parent.getChildAdapterPosition(view);
            outRect.left = space;
            if (mVideoInfo != null && position == mVideoInfo.getVideoDetailList().size() - 1)
                outRect.right = space;
        }
    }
 
    private void loadEpisode() {
 
        int type = 0;
 
        if (mVideoInfo.getShowType() == 1) {
            // 综艺或者电影
            type = EpisodeNewAdapter.TYPE_ZONGYI;
 
        } else if (mVideoInfo.getShowType() == 2) {
            // 电视剧动漫
            type = EpisodeNewAdapter.TYPE_DIANSHIJU;
        }
        episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, type, mPlayingPosition, new EpisodeNewAdapter.ISelectVideoEpisodeListener() {
            @Override
            public void onClick(int position, VideoDetailInfo detailInfo) {
                VideoDetailInfo videoDetailInfo = detailInfo;
                mPlayingPosition = position;
                episodeAdapter.setPlayingPosition(mPlayingPosition);
                refresh();
                Playlocation playlocation = new Playlocation();
                playlocation.setPosition(position);
                EventBus.getDefault().post(playlocation);
                getUrl(videoDetailInfo);
            }
        });
        LinearLayoutManager ms = new LinearLayoutManager(getContext());
        ms.setOrientation(LinearLayoutManager.HORIZONTAL);
 
        rv_episode.setHasFixedSize(true);
        rv_episode.setNestedScrollingEnabled(false);
 
        rv_episode.setLayoutManager(ms);
        rv_episode.addItemDecoration(new SpacesItemDecoration(DimenUtils.dip2px(getContext(), 10)));
    }
 
    private void setFollowData(boolean attention) {
        if (attention) {
            tv_cancle_follow.setText("已追剧");
        } else {
            tv_cancle_follow.setText("追剧");
        }
    }
 
    @Override
    public void onCreateView(View contentView, Bundle savedInstanceState) {
        Log.i(TAG, "onCreateView");
        EventBus.getDefault().register(this);
        mVideoInfo = (VideoInfo) getArguments()
                .getSerializable("video_info");
        mPlayingPosition = getArguments().getInt("playing_position");
        mStart = getArguments().getInt("start");
        mEnd = getArguments().getInt("end");
        resourceId = getArguments().getString("resourceId");
 
        pd = new ProgressDialog(getContext());
        pd.setProgressStyle(ProgressDialog.STYLE_SPINNER);// 设置进度条的形式为圆形转动的进度条
        pd.setCancelable(true);// 设置是否可以通过点击Back键取消
        pd.setCanceledOnTouchOutside(false);// 设置在点击Dialog外是否取消Dialog进度条
        pd.setMessage("网络加载中·······");
 
 
        ll_add_attention = contentView.findViewById(R.id.ll_add_attention);
        tv_title = contentView.findViewById(R.id.tv_title);
        tv_desc = contentView.findViewById(R.id.tv_desc);
        tv_desc.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tv_desc.setMaxLines(100);
            }
        });
        tv_score = contentView.findViewById(R.id.tv_score);
        ll_score = contentView.findViewById(R.id.ll_score);
        arb_score = contentView.findViewById(R.id.arb_score);
 
        tv_score = contentView.findViewById(R.id.tv_score);
        tv_play_num = contentView.findViewById(R.id.tv_play_num);
 
        ll_indicator = contentView.findViewById(R.id.ll_indicator);
 
 
        if (mVideoInfo.getAttention() == null) {
            ll_add_attention.setVisibility(View.GONE);
        } else {
            ll_add_attention.setVisibility(View.VISIBLE);
            iv_moive_img = contentView.findViewById(R.id.iv_moive_img);
            tv_star_name = contentView.findViewById(R.id.tv_star_name);
            tv_update_time = contentView.findViewById(R.id.tv_update_time);
            tv_cancle_follow = contentView.findViewById(R.id.tv_cancle_follow);
            try {
                Glide.with(getActivity().getApplicationContext()).load(mVideoInfo.getAttention().getMoviePicture())
                        .apply(new RequestOptions().centerCrop().placeholder(R.drawable.ic_default).error(R.drawable.ic_default))
                        .into(iv_moive_img);
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            tv_star_name.setText(mVideoInfo.getAttention().getMovieName() + "");
            tv_update_time.setText(mVideoInfo.getAttention().getUpdateInfo() + "");
            setFollowData(mVideoInfo.getAttention().isAttention());
 
            tv_cancle_follow.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    SharedPreferences sp = getContext().getSharedPreferences("user", Context.MODE_PRIVATE);
                    String uid = sp.getString("uid", "");
                    String loginid = sp.getString("LoginUid", "");
                    if (StringUtils.isEmpty(loginid)) {
                        Toast.makeText(ll_add_attention.getContext(), "登录成功后才能进行追剧!", Toast.LENGTH_LONG).show();
                        getContext().startActivity(new Intent(ll_add_attention.getContext(), LoginActivity.class));
                        return;
                    }
                    if (mVideoInfo.getAttention().isAttention()) {//取消关注
                        cancleAttention(uid, loginid);
                    } else {//关注
                        addAttention(uid, loginid);
                    }
                }
            });
        }
 
        setVideoInfo();
 
 
        fl_native_ad1 = contentView
                .findViewById(R.id.fl_native_ad_1);
        rv_episode = contentView.findViewById(R.id.rv_episode);
        rv_video_related_video = contentView.findViewById(R.id.rv_video_related_video);
        rv_video_guess_like = contentView.findViewById(R.id.rv_video_guess_like);
 
 
        rv_video_guess_like.setHasFixedSize(true);
        rv_video_guess_like.setNestedScrollingEnabled(false);
        rv_video_related_video.setHasFixedSize(true);
        rv_video_related_video.setNestedScrollingEnabled(false);
 
 
        loadEpisode();
        refresh();
        loadAD1();
        if (mVideoInfo.getVideoDetailList() != null && mVideoInfo.getVideoDetailList().size() > 1) {
            rv_episode.setVisibility(View.VISIBLE);
        } else
            rv_episode.setVisibility(View.GONE);
    }
 
 
    public void onEventMainThread(Playlocation playlocation) {
        mPlayingPosition = playlocation.getPosition();
        loadEpisode();
        refresh();
    }
 
    private void addAttention(String uid, String loginId) {
        HttpApiUtil.addAttention(ll_add_attention.getContext(), uid, loginId, mVideoInfo.getId(), new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optBoolean("IsPost")) {
                    SingleToast.showToast(ll_add_attention.getContext(), "追剧成功!");
                    mVideoInfo.getAttention().setAttention(true);
                    setFollowData(mVideoInfo.getAttention().isAttention());
 
                }
            }
        });
    }
 
    private void cancleAttention(String uid, String loginId) {
        HttpApiUtil.cancelAttention(ll_add_attention.getContext(), uid, loginId, mVideoInfo.getId(), new BasicTextHttpResponseHandler() {
            @Override
            public void onSuccessPerfect(int statusCode, Header[] headers, JSONObject jsonObject) throws Exception {
                if (jsonObject.optBoolean("IsPost")) {
                    SingleToast.showToast(ll_add_attention.getContext(), "取消追剧成功!");
                    mVideoInfo.getAttention().setAttention(false);
                    setFollowData(mVideoInfo.getAttention().isAttention());
                }
            }
        });
    }
 
    @Override
    public void onResume() {
        super.onResume();
    }
 
    @Override
    public void onDestroyView() {
        super.onDestroyView();
        EventBus.getDefault().unregister(this);
    }
 
    @Override
    public void onPause() {
        super.onPause();
    }
 
    private void getUrl(VideoDetailInfo info) {
        SharedPreferences preferences = getContext().getSharedPreferences(
                "user", Context.MODE_PRIVATE);
        String uid = preferences.getString("uid", "");
        HttpApiUtil.getPlayUrl(getContext(), uid, info.getType(), mVideoInfo.getId(),
                info.getId(), resourceId, info.geteId(),
                new BasicTextHttpResponseHandler() {
 
                    @Override
                    public void onSuccessPerfect(int statusCode,
                                                 Header[] headers, JSONObject jsonObject)
                            throws Exception {
                        if (jsonObject.getBoolean("IsPost")) {
 
                            VideoResource resource =  JsonUtil.videoGson.fromJson(
                                    jsonObject.getJSONObject("Data")
                                            .getJSONObject("Resource")
                                            .toString(),
                                    new TypeToken<VideoResource>() {
                                    }.getType());
                            PlayUrl info = new PlayUrl();
                            info.setResource(resource);
                            info.setPlayType(Integer.parseInt(jsonObject
                                    .getJSONObject("Data")
                                    .optString("PlayType")));
                            info.setUrl(jsonObject.getJSONObject("Data")
                                    .optString("Url"));
                            info.setParams(jsonObject.getJSONObject("Data")
                                    .optString("Params"));
                            Play play = new Play();
                            play.setPlayUrl(info);
                            EventBus.getDefault().post(play);
                        }else{
                            Toast.makeText(getContext(), jsonObject.optString("Error"), Toast.LENGTH_SHORT).show();
                        }
                    }
 
                    @Override
                    public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                        super.onFailure(statusCode, headers, responseString, throwable);
 
                    }
 
                    @Override
                    public void onFinish() {
                        super.onFinish();
                        if (pd != null && pd.isShowing())
                            pd.dismiss();
                    }
                });
    }
 
    public boolean isPlaying() {
        return mStart <= mPlayingPosition && mPlayingPosition < mEnd;
    }
 
    /**
     * 刷新adapter
     */
    public void refresh() {
        if (rv_episode.getAdapter() != null)
            rv_episode.getAdapter().notifyDataSetChanged();
        else
            rv_episode.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Log.i(TAG, "refresh");
                    rv_episode.setAdapter(episodeAdapter);
                    if (mPlayingPosition > 4)
                        rv_episode.scrollToPosition(mPlayingPosition);
                }
            }, 500);
 
 
    }
 
    // 加载播放页第一条广告,先设置加载上下文环境和条件
    private void loadAD1() {
        ExpressAdManager expressAdManager = null;
        try {
            expressAdManager = new ExpressAdManager(AdUtil.AD_TYPE.gdt2, getContext());
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        if (expressAdManager == null)
            return;
 
        expressAdManager.loadVideoDetailPlayerBottomAd(new ExpressAdManager.IAdLoadListener() {
            @Override
            public void onSuccess(List<ExpressAdContainer> adList) {
                if (adList != null && adList.size() > 0) {
                    fl_native_ad1.setVisibility(View.VISIBLE);
                    final ExpressAdContainer ad = adList.get(0);
                    if (getActivity() == null)
                        return;
 
                    ExpressAdManager.renderAd(getActivity(), adList.get(0), new ExpressAdManager.IAdRenderListener() {
                        @Override
                        public void onRenderSuccess(List<ExpressAdContainer> adList) {
                            ExpressAdManager.fillAd(adList.get(0), fl_native_ad1);
                        }
 
                        @Override
                        public void onRenderFail(List<ExpressAdContainer> adList) {
 
                        }
                    }, new ExpressAdManager.IAdEventListener() {
                        @Override
                        public void closeAd(ExpressAdContainer ad) {
                            fl_native_ad1.removeAllViews();
                        }
                    });
 
                } else {
                    fl_native_ad1.setVisibility(View.GONE);
                }
            }
        });
    }
 
 
    @Override
    public void onClick(View v) {
        SharedPreferences preferences = getContext()
                .getSharedPreferences("user", Context.MODE_PRIVATE);
        switch (v.getId()) {
 
 
        }
    }
 
 
    public void onEventMainThread(VideoInfo videoInfo) {
        mVideoInfo = videoInfo;
        if (mVideoInfo.getVideoDetailList() != null && mVideoInfo.getVideoDetailList().size() > 1) {
            rv_episode.setVisibility(View.VISIBLE);
        } else
            rv_episode.setVisibility(View.GONE);
        rv_episode.setAdapter(episodeAdapter);
    }
 
 
    private void setIndicatorSelected(int index) {
 
        for (int i = 0; i < ll_indicator.getChildCount(); i++) {
            LinearLayout child = (LinearLayout) ll_indicator.getChildAt(i);
            TextView tv = (TextView) child.getChildAt(0);
            View view = child.getChildAt(1);
            if (i == index) {
                tv.setTextColor(getContext().getColor(R.color.theme));
                view.setVisibility(View.VISIBLE);
            } else {
                tv.setTextColor(Color.parseColor("#FF999999"));
                view.setVisibility(View.GONE);
            }
        }
    }
 
    private void setIndicatorSelectedEvent() {
 
        for (int i = 0; i < ll_indicator.getChildCount(); i++) {
            final int p = i;
            View view = ll_indicator.getChildAt(i);
            view.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    rv_episode.setVisibility(View.GONE);
                    rv_video_related_video.setVisibility(View.GONE);
                    rv_video_guess_like.setVisibility(View.GONE);
 
 
                    switch (p) {
                        case 0:
                            setIndicatorSelected(0);
                            rv_episode.setVisibility(View.VISIBLE);
                            break;
                        case 1:
                            setIndicatorSelected(1);
                            rv_video_related_video.setVisibility(View.VISIBLE);
                            break;
                        case 2:
                            setIndicatorSelected(2);
                            rv_video_guess_like.setVisibility(View.VISIBLE);
                            break;
                    }
                }
            });
 
 
        }
    }
 
 
    private void getRelativeVideos() {
        SharedPreferences preferences = getContext().getSharedPreferences(
                "user", Context.MODE_PRIVATE);
        String uid = preferences.getString("uid", "");
        HttpApiUtil.getRelativeVideos(getContext(), uid,
                mVideoInfo.getId(), new BasicTextHttpResponseHandler() {
 
                    @Override
                    public void onSuccessPerfect(int statusCode,
                                                 Header[] headers, JSONObject jsonObject)
                            throws Exception {
                        if (jsonObject.getBoolean("IsPost")) {
 
                            final List<VideoInfo> videoInfos =  JsonUtil.videoGson.fromJson(
                                    jsonObject.getJSONObject("Data")
                                            .getJSONArray("data").toString(),
                                    new TypeToken<List<VideoInfo>>() {
                                    }.getType());
 
                            if (videoInfos == null || videoInfos.size() == 0) {
                            } else {
                                final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() {
                                    @Override
                                    public void onClick(VideoInfo video) {
                                        VideoDetailActivity.ChangeVideoEvent changeVideoEvent = new VideoDetailActivity.ChangeVideoEvent();
                                        changeVideoEvent.setVideoInfo(video);
                                        changeVideoEvent.setTag("VideoPlayerFragment");
                                        EventBus.getDefault().post(changeVideoEvent);
                                    }
                                });
                                adapter.initRecyclerViewDisplayWidthColumn2(rv_video_related_video);
 
                                if (getActivity() == null)
                                    return;
                                getActivity().runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (rv_video_related_video != null) {
                                            rv_video_related_video.setAdapter(adapter);
                                        }
                                    }
                                });
                            }
                        }
                    }
                });
    }
 
 
    private void guessLike() {
        SharedPreferences preferences = getContext().getSharedPreferences(
                "user", Context.MODE_PRIVATE);
        String uid = preferences.getString("uid", "");
        HttpApiUtil.guessLike(getContext(), uid, mVideoInfo.getId(),
                new BasicTextHttpResponseHandler() {
 
                    @Override
                    public void onSuccessPerfect(int statusCode,
                                                 Header[] headers, JSONObject jsonObject)
                            throws Exception {
                        if (jsonObject.getBoolean("IsPost")) {
 
                            List<VideoInfo> videoInfos =  JsonUtil.videoGson.fromJson(
                                    jsonObject.getJSONObject("Data")
                                            .getJSONArray("data").toString(),
                                    new TypeToken<List<VideoInfo>>() {
                                    }.getType());
                            final VideoColumn2Adapter adapter = new VideoColumn2Adapter(getActivity(), getContext(), videoInfos, false, 2, new IVideoClickListener() {
                                @Override
                                public void onClick(VideoInfo video) {
                                    VideoDetailActivity.ChangeVideoEvent changeVideoEvent = new VideoDetailActivity.ChangeVideoEvent();
                                    changeVideoEvent.setVideoInfo(video);
                                    changeVideoEvent.setTag("VideoPlayerFragment");
                                    EventBus.getDefault().post(changeVideoEvent);
                                }
                            });
                            adapter.initRecyclerViewDisplayWidthColumn2(rv_video_guess_like);
                            if (getActivity() != null)
                                getActivity().runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        if (rv_video_guess_like != null)
                                            rv_video_guess_like
                                                    .setAdapter(adapter);
                                    }
                                });
                        }
                    }
                });
    }
 
 
}