Search in sources :

Example 1 with VideoData

use of com.zhjh.androidnews.bean.VideoData in project AndroidNews by zhjohow.

the class VideosFragment method initView.

@Override
protected void initView() {
    if (getArguments() != null) {
        mVideoType = getArguments().getString(AppConstant.VIDEO_TYPE);
    }
    irc.setLayoutManager(new LinearLayoutManager(getContext()));
    videoListAdapter = new CommonRecycleViewAdapter<VideoData>(getContext(), R.layout.item_video_list) {

        @Override
        public void convert(ViewHolderHelper helper, VideoData videoData) {
            helper.setImageRoundUrl(R.id.iv_logo, videoData.getTopicImg());
            helper.setText(R.id.tv_from, videoData.getTopicName());
            helper.setText(R.id.tv_play_time, String.format(getResources().getString(R.string.video_play_times), String.valueOf(videoData.getPlayCount())));
            JCVideoPlayerStandard jcVideoPlayerStandard = helper.getView(R.id.videoplayer);
            boolean setUp = jcVideoPlayerStandard.setUp(videoData.getMp4_url(), JCVideoPlayer.SCREEN_LAYOUT_LIST, TextUtils.isEmpty(videoData.getDescription()) ? videoData.getTitle() + "" : videoData.getDescription());
            if (setUp) {
                Glide.with(mContext).load(videoData.getCover()).diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().error(com.zhjh.common.R.drawable.ic_empty_picture).crossFade().into(jcVideoPlayerStandard.thumbImageView);
            }
        }
    };
    irc.setAdapter(videoListAdapter);
    irc.setOnRefreshListener(this);
    irc.setOnLoadMoreListener(this);
    // 视频监听
    irc.addOnChildAttachStateChangeListener(new RecyclerView.OnChildAttachStateChangeListener() {

        @Override
        public void onChildViewAttachedToWindow(View view) {
        }

        @Override
        public void onChildViewDetachedFromWindow(View view) {
            if (JCVideoPlayerManager.listener() != null) {
                JCVideoPlayer videoPlayer = (JCVideoPlayer) JCVideoPlayerManager.listener();
                if (((ViewGroup) view).indexOfChild(videoPlayer) != -1 && videoPlayer.currentState == JCVideoPlayer.CURRENT_STATE_PLAYING) {
                    JCVideoPlayer.releaseAllVideos();
                }
            }
        }
    });
    // 数据为空才重新发起请求
    if (videoListAdapter.getSize() <= 0) {
        // 发起请求
        mStartPage = 0;
        mPresenter.getVideosListDataRequest(mVideoType, mStartPage);
    }
}
Also used : ViewHolderHelper(com.aspsine.irecyclerview.universaladapter.ViewHolderHelper) JCVideoPlayerStandard(fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard) VideoData(com.zhjh.androidnews.bean.VideoData) JCVideoPlayer(fm.jiecao.jcvideoplayer_lib.JCVideoPlayer) IRecyclerView(com.aspsine.irecyclerview.IRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LoadMoreFooterView(com.aspsine.irecyclerview.widget.LoadMoreFooterView) View(android.view.View) IRecyclerView(com.aspsine.irecyclerview.IRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 IRecyclerView (com.aspsine.irecyclerview.IRecyclerView)1 ViewHolderHelper (com.aspsine.irecyclerview.universaladapter.ViewHolderHelper)1 LoadMoreFooterView (com.aspsine.irecyclerview.widget.LoadMoreFooterView)1 VideoData (com.zhjh.androidnews.bean.VideoData)1 JCVideoPlayer (fm.jiecao.jcvideoplayer_lib.JCVideoPlayer)1 JCVideoPlayerStandard (fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard)1