package com.weikou.beibeivideo.ui.media;
|
|
import android.text.TextUtils;
|
import android.view.Gravity;
|
import android.view.View;
|
import android.view.ViewGroup;
|
import android.widget.BaseAdapter;
|
import android.widget.TextView;
|
|
import com.weikou.beibeivideo.R;
|
import com.weikou.beibeivideo.entity.VideoDetailInfo;
|
import com.weikou.beibeivideo.entity.VideoInfo;
|
import com.weikou.beibeivideo.util.DownloadUtils;
|
import com.weikou.beibeivideo.util.VideoUtil;
|
|
public class GridEpisodeAdapter2 extends BaseAdapter {
|
|
private VideoInfo mVideoInfo;
|
|
private int mPlayingPosition;
|
|
public GridEpisodeAdapter2(VideoInfo videoInfo, int playingPosition) {
|
super();
|
this.mVideoInfo = videoInfo;
|
this.mPlayingPosition = playingPosition;
|
}
|
|
@Override
|
public int getCount() {
|
return mVideoInfo == null ? 0
|
: (VideoUtil.videoEpisodeList == null ? 0 : VideoUtil.videoEpisodeList.size());
|
}
|
|
@Override
|
public Object getItem(int position) {
|
return VideoUtil.videoEpisodeList.get(position);
|
}
|
|
@Override
|
public long getItemId(int position) {
|
return position;
|
}
|
|
@Override
|
public View getView(int position, View convertView, ViewGroup parent) {
|
if (convertView == null) {
|
convertView = new TextView(parent.getContext());
|
((TextView) convertView).setGravity(Gravity.CENTER);
|
}
|
VideoDetailInfo videoDetailInfo = (VideoDetailInfo) getItem(position);
|
if (position == mPlayingPosition) {
|
((TextView) convertView)
|
.setBackgroundResource(R.drawable.episode_playing2);
|
} else {
|
if (TextUtils.isEmpty(DownloadUtils.getOfflinePath(
|
parent.getContext(), mVideoInfo.getId(),
|
videoDetailInfo.getId()))) {
|
((TextView) convertView)
|
.setBackgroundResource(R.drawable.episode_unwatched2);
|
} else {
|
((TextView) convertView)
|
.setBackgroundResource(R.drawable.episode_offlined2);
|
}
|
}
|
((TextView) convertView).setTextColor(parent.getResources().getColor(
|
android.R.color.white));
|
((TextView) convertView).setText(TextUtils.isEmpty(videoDetailInfo
|
.getTag()) ? videoDetailInfo.getName() : videoDetailInfo
|
.getTag());
|
return convertView;
|
}
|
|
public int getPlayingPosition() {
|
return mPlayingPosition;
|
}
|
|
public void setPlayingPosition(int playingPosition) {
|
this.mPlayingPosition = playingPosition;
|
}
|
}
|