Search in sources :

Example 1 with ViewHolderHelper

use of com.aspsine.irecyclerview.universaladapter.ViewHolderHelper in project AndroidNews by zhjohow.

the class MultiItemAblistViewAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (mMultiItemTypeSupport == null)
        return super.getView(position, convertView, parent);
    int layoutId = mMultiItemTypeSupport.getLayoutId(position, getItem(position));
    ViewHolderHelper viewHolder = ViewHolderHelper.get(mContext, convertView, parent, layoutId, position);
    convert(viewHolder, getItem(position));
    return viewHolder.getConvertView();
}
Also used : ViewHolderHelper(com.aspsine.irecyclerview.universaladapter.ViewHolderHelper)

Example 2 with ViewHolderHelper

use of com.aspsine.irecyclerview.universaladapter.ViewHolderHelper in project AndroidNews by zhjohow.

the class CommonRecycleViewAdapter method onCreateViewHolder.

@Override
public ViewHolderHelper onCreateViewHolder(final ViewGroup parent, int viewType) {
    ViewHolderHelper viewHolder = ViewHolderHelper.get(mContext, null, parent, mLayoutId, -1);
    setListener(parent, viewHolder, viewType);
    return viewHolder;
}
Also used : ViewHolderHelper(com.aspsine.irecyclerview.universaladapter.ViewHolderHelper)

Example 3 with ViewHolderHelper

use of com.aspsine.irecyclerview.universaladapter.ViewHolderHelper in project AndroidNews by zhjohow.

the class CommonAblistViewAdapter method getView.

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolderHelper holder = ViewHolderHelper.get(mContext, convertView, parent, layoutId, position);
    convert(holder, getItem(position));
    return holder.getConvertView();
}
Also used : ViewHolderHelper(com.aspsine.irecyclerview.universaladapter.ViewHolderHelper)

Example 4 with ViewHolderHelper

use of com.aspsine.irecyclerview.universaladapter.ViewHolderHelper in project AndroidNews by zhjohow.

the class MultiItemRecycleViewAdapter method onCreateViewHolder.

@Override
public ViewHolderHelper onCreateViewHolder(ViewGroup parent, int viewType) {
    if (mMultiItemTypeSupport == null)
        return super.onCreateViewHolder(parent, viewType);
    int layoutId = mMultiItemTypeSupport.getLayoutId(viewType);
    ViewHolderHelper holder = ViewHolderHelper.get(mContext, null, parent, layoutId, -1);
    setListener(parent, holder, viewType);
    return holder;
}
Also used : ViewHolderHelper(com.aspsine.irecyclerview.universaladapter.ViewHolderHelper)

Example 5 with ViewHolderHelper

use of com.aspsine.irecyclerview.universaladapter.ViewHolderHelper 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

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