| | |
| | | import android.content.SharedPreferences; |
| | | import android.database.Cursor; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.Rect; |
| | | import android.graphics.drawable.ColorDrawable; |
| | | import android.os.Bundle; |
| | | import android.os.Handler; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | | import android.support.v7.widget.StaggeredGridLayoutManager; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | |
| | | private int mEnd; |
| | | private int mPlayingPosition; |
| | | private VideoInfo mVideoInfo = null; |
| | | private static RecyclerView rv_episode; |
| | | private RecyclerView rv_episode; |
| | | |
| | | private LinearLayout fl_report; |
| | | private ImageView iv_favourite; |
| | |
| | | tv_score.setVisibility(View.GONE); |
| | | } |
| | | tv_play_num.setText("播放:" + VideoUtil.getWatchCountShortName(mVideoInfo.getWatchCount())); |
| | | } |
| | | |
| | | 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(){ |
| | | if (mVideoInfo.getShowType() == 1) { |
| | | // 综艺或者电影 |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, EpisodeNewAdapter.TYPE_ZONGYI, mPlayingPosition); |
| | | } else if (mVideoInfo.getShowType() == 2) { |
| | | // 电视剧动漫 |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, EpisodeNewAdapter.TYPE_DIANSHIJU, mPlayingPosition); |
| | | } |
| | | LinearLayoutManager ms = new LinearLayoutManager(getContext()); |
| | | ms.setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | |
| | | rv_episode.setLayoutManager(ms); |
| | | rv_episode.addItemDecoration(new SpacesItemDecoration(DimenUtils.dip2px(getContext(), 10))); |
| | | } |
| | | |
| | | @Override |
| | |
| | | fl_native_ad1 = contentView |
| | | .findViewById(R.id.fl_native_ad_1); |
| | | rv_episode = contentView.findViewById(R.id.rv_episode); |
| | | if (mVideoInfo.getShowType() == 1) { |
| | | // 综艺或者电影 |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, EpisodeNewAdapter.TYPE_ZONGYI, mPlayingPosition); |
| | | } else if (mVideoInfo.getShowType() == 2) { |
| | | // 电视剧动漫 |
| | | episodeAdapter = new EpisodeNewAdapter(getContext(), mVideoInfo, EpisodeNewAdapter.TYPE_DIANSHIJU, mPlayingPosition); |
| | | } |
| | | LinearLayoutManager ms = new LinearLayoutManager(getContext()); |
| | | ms.setOrientation(LinearLayoutManager.HORIZONTAL); |
| | | |
| | | rv_episode.setLayoutManager(ms); |
| | | //设置间距 |
| | | DividerItemDecoration decoration = new DividerItemDecoration(); |
| | | decoration.setSize(com.weikou.beibeivideo.util.DimenUtils.dip2px(getContext(), 10)); |
| | | rv_episode.addItemDecoration(decoration); |
| | | rv_episode.setAdapter(episodeAdapter); |
| | | |
| | | loadEpisode(); |
| | | |
| | | //TODO 点击事件响应 |
| | | // rv_episode.setOnItemClickListener(new OnItemClickListener() { |
| | |
| | | /** |
| | | * 刷新adapter |
| | | */ |
| | | public void refresh() { |
| | | public void refresh() { |
| | | rv_episode.setAdapter(episodeAdapter); |
| | | } |
| | | |