admin
2021-07-15 49982f5a1a305c0cc7da04735e1c604b802d2a22
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
89
90
91
package com.yeshi.video.ui.adapter;
 
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
 
import com.yeshi.base.entity.video.VideoDetailInfo;
import com.yeshi.base.entity.video.VideoInfo;
import com.yeshi.base.utils.downutil.DownloadUtils;
import com.yeshi.video.R;
import com.yeshi.video.ui.VideoEpisodeFragment;
 
/**
 * 查看更多时的剧集适配器
 */
public class EpisodeAdapter extends BaseAdapter {
 
    private VideoInfo mVideoInfo;
 
    private int mPlayingPosition;
 
    public EpisodeAdapter(VideoInfo videoInfo, int playingPosition) {
        super();
        this.mVideoInfo = videoInfo;
        this.mPlayingPosition = playingPosition;
    }
 
    @Override
    public int getCount() {
        if (mVideoInfo.getShowType() == 1) {// 综艺
            if (VideoEpisodeFragment.page_varietyshow * 10 <= mVideoInfo
                    .getVideoDetailList().size()) {
                return VideoEpisodeFragment.page_varietyshow * 10;
            } else {
                return mVideoInfo.getVideoDetailList().size();
            }
        }
        return mVideoInfo.getVideoDetailList().size();
    }
 
    @Override
    public Object getItem(int position) {
        return mVideoInfo.getVideoDetailList().get(position);
    }
 
    @Override
    public long getItemId(int position) {
        return position;
    }
 
    @Override
    public View getView(int position, View view, ViewGroup parent) {
        view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_episode, null);
        TextView tv_episode = (TextView) view.findViewById(R.id.tv_episode);
 
        VideoDetailInfo videoDetailInfo = (VideoDetailInfo) getItem(position);
        if (position == mPlayingPosition) {
            tv_episode.setBackgroundResource(R.drawable.episode_playing);
//            tv_episode.setTextColor(parent.getResources()
//                    .getColor(R.color.yellow));
        } else {
            if (TextUtils.isEmpty(DownloadUtils.getOfflinePath(
                    parent.getContext(), mVideoInfo.getId(),
                    videoDetailInfo.getId()))) {
                tv_episode.setBackgroundResource(R.drawable.episode_offlined);
//                tv_episode.setTextColor(parent.getResources()
//                        .getColor(android.R.color.white));
            }
            tv_episode.setBackgroundResource(R.drawable.episode_unwatched);
//            tv_episode.setTextColor(parent.getResources()
//                    .getColor(android.R.color.black));
        }
        if (mVideoInfo.getShowType() == 1) {
            // ((TextView) convertView).setText(videoDetailInfo.getName());
            // } else if (mStretch == 1) {
            if (videoDetailInfo.getIntroduction() == null) {
                videoDetailInfo.setIntroduction("");
            }
            tv_episode.setText(TextUtils.isEmpty(videoDetailInfo
                    .getTag()) ? ""
                    : (videoDetailInfo.getTag() + videoDetailInfo
                    .getIntroduction()));
        } else {
            tv_episode.setText(videoDetailInfo.getTag());
        }
        return view;
    }
}