| | |
| | | |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.yeshi.buwanshequ.R; |
| | | import com.weikou.beibeivideo.util.DimenUtils; |
| | | import com.weikou.beibeivideo.R; |
| | | |
| | | public class EpisodeNewAdapter extends RecyclerView.Adapter { |
| | | |
| | |
| | | private LayoutInflater layoutInflater; |
| | | private Context mContext; |
| | | |
| | | private ISelectVideoEpisodeListener selectVideoEpisodeListener; |
| | | |
| | | |
| | | private int displayType; |
| | | |
| | | public EpisodeNewAdapter(Context context, VideoInfo videoInfo, int displayType, int playingPosition) { |
| | | public EpisodeNewAdapter(Context context, VideoInfo videoInfo, int displayType, int playingPosition, ISelectVideoEpisodeListener selectVideoEpisodeListener) { |
| | | this.videoInfo = videoInfo; |
| | | this.playingPosition = playingPosition; |
| | | layoutInflater = LayoutInflater.from(context); |
| | | this.mContext = context; |
| | | this.displayType = displayType; |
| | | this.selectVideoEpisodeListener = selectVideoEpisodeListener; |
| | | } |
| | | |
| | | public void setPlayingPosition(int position){ |
| | | this.playingPosition = position; |
| | | } |
| | | |
| | | @NonNull |
| | |
| | | |
| | | private void setDisplaySize(TextView tv) { |
| | | if (displayType == TYPE_DIANSHIJU || displayType == TYPE_DONGMAN) { |
| | | tv.setMinWidth(52); |
| | | tv.setMinWidth(DimenUtils.dip2px(mContext, 52)); |
| | | } else { |
| | | tv.setMaxLines(3); |
| | | tv.setLines(3); |
| | | tv.setEllipsize(TextUtils.TruncateAt.END); |
| | | tv.setMinWidth(180); |
| | | tv.setMinWidth(DimenUtils.dip2px(mContext, 180)); |
| | | tv.setGravity(Gravity.START); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { |
| | | public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, final int position) { |
| | | final VideoDetailInfo info = videoInfo.getVideoDetailList().get(position); |
| | | EpisodeViewHolder viewHolder = (EpisodeViewHolder) holder; |
| | | setDisplaySize(viewHolder.tv_episode); |
| | |
| | | viewHolder.tv_episode.setTextColor(Color.parseColor("#232323")); |
| | | } |
| | | |
| | | if (videoInfo.getShowType() == 1) { |
| | | if (videoInfo.getIntroduction() == null) { |
| | | videoInfo.setIntroduction(""); |
| | | viewHolder.tv_episode.setText(info.getTag()); |
| | | viewHolder.tv_episode.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (selectVideoEpisodeListener != null) |
| | | selectVideoEpisodeListener.onClick(position, info); |
| | | } |
| | | viewHolder.tv_episode.setText(TextUtils.isEmpty(videoInfo |
| | | .getTag()) ? "" |
| | | : (videoInfo.getTag() + videoInfo |
| | | .getIntroduction())); |
| | | } else { |
| | | viewHolder.tv_episode.setText(info.getTag()); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public interface ISelectVideoEpisodeListener { |
| | | public void onClick(int position, VideoDetailInfo detailInfo); |
| | | } |
| | | |
| | | } |