PlayerUgcLiveFragment.java
2.54 KB
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
package com.cnlive.gundam.video.fragment;
import android.content.res.Configuration;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.cnlive.gundam.R;
import com.cnlive.gundam.databinding.FragmentPlayerUgcVodBinding;
import com.cnlive.gundam.main.model.VideoListProgram;
import com.cnlive.gundam.video.model.VideoModel;
import com.cnlive.gundam.video.utils.PlayerUtils;
import com.cnlive.gundam.video.view.VideoView;
/**
* Created by gujun on 2017/4/5.
*/
public class PlayerUgcLiveFragment extends Fragment {
private FragmentPlayerUgcVodBinding binding;
private VideoListProgram program;
private String title;
private String id;
private String rates;
public static PlayerUgcLiveFragment newInstance(VideoListProgram program) {
Bundle args = new Bundle();
args.putSerializable("program", program);
PlayerUgcLiveFragment fragment = new PlayerUgcLiveFragment();
fragment.setArguments(args);
return fragment;
}
private void initData() {
program = (VideoListProgram) getArguments().getSerializable("program");
title = program.getTitle();
id = program.getChannelId();
rates = program.getRates();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_ugc_live, container, false);
initData();
return binding.getRoot();
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
binding.videoView.setVideoInfo(new VideoModel(title, id, VideoView.TYPE_UGC_LIVE, rates));
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
boolean isPortrait = PlayerUtils.isPortrait(getActivity());
binding.videoView.onScreenChange(isPortrait);
}
@Override
public void onResume() {
super.onResume();
binding.videoView.onResume();
}
@Override
public void onPause() {
super.onPause();
binding.videoView.onPause();
}
@Override
public void onDestroyView() {
binding.videoView.onDestroy();
super.onDestroyView();
}
}