| | |
| | | |
| | | import android.content.Context; |
| | | import android.content.Intent; |
| | | import android.database.Cursor; |
| | | import android.support.v4.widget.CursorAdapter; |
| | | import android.text.TextUtils; |
| | | import android.text.TextUtils.TruncateAt; |
| | | import android.util.Log; |
| | | import android.view.LayoutInflater; |
| | | import android.view.View; |
| | | import android.view.View.OnClickListener; |
| | | import android.view.ViewGroup; |
| | | import android.widget.BaseAdapter; |
| | | import android.widget.CheckBox; |
| | | import android.widget.FrameLayout; |
| | | import android.widget.ImageButton; |
| | |
| | | import android.widget.TextView; |
| | | |
| | | import com.bumptech.glide.Glide; |
| | | import com.bumptech.glide.RequestManager; |
| | | import com.google.gson.FieldNamingPolicy; |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.lcjian.library.util.common.StringUtils; |
| | | import com.mozillaonline.providers.DownloadManager; |
| | | import com.nostra13.universalimageloader.core.DisplayImageOptions; |
| | | import com.nostra13.universalimageloader.core.ImageLoader; |
| | | import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
| | | import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer; |
| | | import com.weikou.beibeivideo.R; |
| | | import com.weikou.beibeivideo.db.DownloadTable; |
| | | import com.weikou.beibeivideo.db.WatchHistoryTable; |
| | | import com.weikou.beibeivideo.entity.VideoDetailInfo; |
| | | import com.weikou.beibeivideo.entity.VideoInfo; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity; |
| | | import com.weikou.beibeivideo.entity.vo.WatchHistoryVO; |
| | | import com.weikou.beibeivideo.ui.media.VideoDetailActivity2; |
| | | import com.weikou.beibeivideo.util.VideoUtil; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Formatter; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | public class WatchHistoryAdapter extends CursorAdapter { |
| | | public class WatchHistoryAdapter extends BaseAdapter { |
| | | |
| | | private RequestManager glide; |
| | | private List<WatchHistoryVO> voList; |
| | | private Context context; |
| | | |
| | | private StringBuilder mFormatBuilder; |
| | | |
| | | private Formatter mFormatter; |
| | | |
| | | private Map<String, VideoInfo> mVideoInfos; |
| | | |
| | | private List<Long> mSelectedIds; |
| | | |
| | | private DownloadManager mDownloadManager; |
| | | private Set<String> mSelectedIds = new HashSet<>(); |
| | | |
| | | private boolean mSelectedMode; |
| | | private DownloadAdapter2.IGetDeleteCallback getdeleteNumber = null; |
| | |
| | | this.getdeleteNumber = getdeleteNumber; |
| | | } |
| | | |
| | | public WatchHistoryAdapter(Context context1, Context context, Cursor c, boolean autoRequery) { |
| | | super(context, c, autoRequery); |
| | | this.mFormatBuilder = new StringBuilder(); |
| | | this.mFormatter = new Formatter(mFormatBuilder, Locale.getDefault()); |
| | | this.mVideoInfos = new HashMap<String, VideoInfo>(); |
| | | this.mSelectedIds = new ArrayList<Long>(); |
| | | this.glide = Glide.with(context); |
| | | this.mDownloadManager = new DownloadManager( |
| | | context1.getContentResolver(), context1.getPackageName()); |
| | | this.mDownloadManager.setAccessAllDownloads(true);// true |
| | | |
| | | public WatchHistoryAdapter(Context context, List<WatchHistoryVO> voList) { |
| | | this.voList = voList; |
| | | this.context = context; |
| | | } |
| | | |
| | | @Override |
| | | public View newView(Context context, Cursor cursor, ViewGroup parent) { |
| | | View view = LayoutInflater.from(parent.getContext()).inflate( |
| | | R.layout.watch_history_item, parent, false); |
| | | ViewHolder holder = new ViewHolder(); |
| | | holder.iv_cover = (ImageView) view.findViewById(R.id.iv_cover); |
| | | holder.tv_title = (TextView) view.findViewById(R.id.tv_title); |
| | | holder.tv_watch_time = (TextView) view.findViewById(R.id.tv_watch_time); |
| | | // holder.btn_status = (ImageButton) view.findViewById(R.id.btn_status); |
| | | // holder.chb_watch_history = (CheckBox) view |
| | | // .findViewById(R.id.chb_watch_history); |
| | | holder.btn_delete = (ImageButton) view |
| | | .findViewById(R.id.btn_delete_download); |
| | | holder.chb_delete = (CheckBox) view.findViewById(R.id.chb_delete); |
| | | holder.fl_video_select = (FrameLayout) view |
| | | .findViewById(R.id.fl_video_select); |
| | | view.setTag(holder); |
| | | return view; |
| | | } |
| | | |
| | | @Override |
| | | public void bindView(View view, Context context, final Cursor cursor) { |
| | | final ViewHolder viewHolder = (ViewHolder) view.getTag(); |
| | | // viewHolder.tv_watch_time.setText(cursor.getString(cursor |
| | | // .getColumnIndex(WatchHistoryTable.VIDEO_RESOURCE)) + ""); |
| | | // String str = " "; |
| | | // for (int i = 0; i < cursor.getColumnNames().length; i++) { |
| | | // str += (cursor.getColumnNames()[i] + " "); |
| | | // } |
| | | // viewHolder.tv_watch_time.setText(str); |
| | | // Log.i("mResult", "列名为:" + str + "------第1列为:" + cursor.getString(0)); |
| | | final Long id = cursor.getLong(cursor |
| | | .getColumnIndex(WatchHistoryTable._ID)); |
| | | final String videoId = cursor.getString(cursor |
| | | .getColumnIndex(WatchHistoryTable.VIDEO_ID)); |
| | | final String videoDetailId = cursor.getString(cursor |
| | | .getColumnIndex(WatchHistoryTable.VIDEO_DETAIL_ID)); |
| | | String videoInfoStr = cursor.getString(cursor |
| | | .getColumnIndexOrThrow(WatchHistoryTable.VIDEO_DETAIL)); |
| | | if (!mSelectedMode) { |
| | | viewHolder.fl_video_select.setVisibility(View.GONE); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | Map<String, VideoInfo> videoInfos = getVideoInfos(); |
| | | VideoInfo videoInfo = videoInfos.get(videoId); |
| | | if (videoInfo != null) { |
| | | int playingPosition = 0; |
| | | for (int i = 0; i < videoInfo.getVideoDetailList() |
| | | .size(); i++) { |
| | | VideoDetailInfo item =videoInfo.getVideoDetailList().get(i); |
| | | if (item.getId().equals(videoDetailId)) { |
| | | playingPosition = i; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | Intent intent = new Intent(v.getContext(), |
| | | VideoDetailActivity2.class); |
| | | VideoInfo info = new VideoInfo(); |
| | | info.setId(videoInfo.getId()); |
| | | info.setShare(videoInfo.getShare()); |
| | | info.setThirdType(videoInfo.getThirdType()); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("video_detail_id", videoDetailId); |
| | | intent.putExtra("playing_position", playingPosition); |
| | | intent.putExtra("isFromWatchHistory", true); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | selectAll(false); |
| | | viewHolder.fl_video_select.setVisibility(View.GONE); |
| | | Cursor downloadCursor = context.getContentResolver().query( |
| | | DownloadTable.CONTENT_URI, null, |
| | | DownloadTable.VIDEO_ID + " = ? AND " |
| | | + DownloadTable.VIDEO_DETAIL_ID + " = ? ", |
| | | new String[]{videoId, videoDetailId}, null); |
| | | if (downloadCursor.moveToFirst()) { |
| | | // viewHolder.chb_watch_history.setVisibility(View.GONE); |
| | | // viewHolder.btn_status.setVisibility(View.GONE); |
| | | DownloadManager.Query baseQuery = new DownloadManager.Query() |
| | | .setOnlyIncludeVisibleInDownloadsUi(true); |
| | | baseQuery.setFilterById(downloadCursor.getLong(downloadCursor |
| | | .getColumnIndex(DownloadTable.TASK_ID))); |
| | | Cursor c = mDownloadManager.query(baseQuery); |
| | | if (c.moveToFirst()) { |
| | | // viewHolder.btn_status.setImageResource(R.drawable.ic_play); |
| | | // viewHolder.btn_status.setVisibility(View.GONE); |
| | | } |
| | | c.close(); |
| | | } |
| | | // else { |
| | | // viewHolder.chb_watch_history.setVisibility(View.INVISIBLE); |
| | | // viewHolder.btn_status.setVisibility(View.VISIBLE); |
| | | // viewHolder.btn_status.setImageResource(R.drawable.ic_download); |
| | | // viewHolder.btn_status.setOnClickListener(new OnClickListener() { |
| | | // |
| | | // @Override |
| | | // public void onClick(final View v) { |
| | | // final VideoInfo videoInfo = mVideoInfos.get(videoId); |
| | | // |
| | | // if (!videoInfo.isCanSave()) { |
| | | // Toast.makeText(mContext, "该视频暂不提供缓存", |
| | | // Toast.LENGTH_SHORT).show(); |
| | | // return; |
| | | // } |
| | | // viewHolder.btn_status.setVisibility(View.GONE); |
| | | // if (videoInfo != null) { |
| | | // VideoDetailInfo videoDetailInfoOrg = null; |
| | | // for (VideoDetailInfo item : videoInfo |
| | | // .getVideoDetailList()) { |
| | | // if (item.getId().equals(videoDetailId)) { |
| | | // videoDetailInfoOrg = item; |
| | | // break; |
| | | // } |
| | | // } |
| | | // if (videoDetailInfoOrg != null) { |
| | | // // 点击下载操作 |
| | | // final DownloadManager downloadManager = new DownloadManager( |
| | | // v.getContext().getContentResolver(), v |
| | | // .getContext().getPackageName()); |
| | | // final VideoDetailInfo videoDetailInfo = videoDetailInfoOrg; |
| | | // String url = ""; |
| | | //// VideoPlayUrlUtil.getVideoUrl( |
| | | //// videoDetailInfo).getUrl(); |
| | | // if (StringUtils.isBlank(videoInfo |
| | | // .getExtraData())) { |
| | | // videoInfo |
| | | // .setExtraData("http://cloud.letv.com"); |
| | | // } |
| | | // (new GetDownLoadTask(v.getContext()) { |
| | | // protected void onPostExecute(String[] result) { |
| | | // DownloadManager.Request request = new Request( |
| | | // Uri.parse(result[0])); |
| | | // try { |
| | | // Uri uri = Uri.fromFile(new File( |
| | | // SDCardUtil.getDownLoadPath(v |
| | | // .getContext()))); |
| | | // request.setDestinationUri(uri); |
| | | // request.setUserAgent(result[1]); |
| | | // |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // /* |
| | | // * request.setDestinationInExternalPublicDir |
| | | // * ( Environment.DIRECTORY_DOWNLOADS, |
| | | // * "/"); |
| | | // */ |
| | | // Cursor cursor = getContext() |
| | | // .getContentResolver() |
| | | // .query(DownloadTable.CONTENT_URI, |
| | | // new String[] { |
| | | // DownloadTable.VIDEO_ID, |
| | | // DownloadTable.VIDEO_DETAIL_ID }, |
| | | // DownloadTable.VIDEO_DETAIL_ID |
| | | // + "=?", |
| | | // new String[] { videoDetailInfo |
| | | // .getId() + "" }, |
| | | // DownloadTable.VIDEO_DETAIL_ID |
| | | // + " ASC");// 查询cursor |
| | | // if (cursor.getCount() > 0) { |
| | | // cursor.close(); |
| | | // return; |
| | | // } |
| | | // cursor.close(); |
| | | // |
| | | // if (getContext().getSharedPreferences( |
| | | // "settings", |
| | | // Context.MODE_PRIVATE) |
| | | // .getBoolean( |
| | | // "only_wifi_download", |
| | | // true)) { |
| | | // request.setAllowedNetworkTypes(Request.NETWORK_WIFI); |
| | | // } |
| | | // request.setTitle(videoInfo.getName()); |
| | | // request.setDescription(TextUtils |
| | | // .isEmpty(videoDetailInfo |
| | | // .getTag()) ? videoDetailInfo |
| | | // .getName() : videoDetailInfo |
| | | // .getTag()); |
| | | // long taskId = downloadManager |
| | | // .enqueue(request); |
| | | // |
| | | // ContentValues values = new ContentValues(); |
| | | // values.put(DownloadTable.TASK_ID, |
| | | // taskId); |
| | | // values.put(DownloadTable.VIDEO_ID, |
| | | // videoInfo.getId()); |
| | | // values.put( |
| | | // DownloadTable.VIDEO_DETAIL_ID, |
| | | // videoDetailInfo.getId()); |
| | | // values.put( |
| | | // DownloadTable.VIDEO_THIRD_TYPE, |
| | | // videoInfo.getThirdType()); |
| | | // Gson gson = new GsonBuilder() |
| | | // .setFieldNamingPolicy( |
| | | // FieldNamingPolicy.UPPER_CAMEL_CASE) |
| | | // .create(); |
| | | // values.put(DownloadTable.VIDEO_DETAIL, |
| | | // gson.toJson(videoInfo)); |
| | | // getContext() |
| | | // .getContentResolver() |
| | | // .insert(DownloadTable.CONTENT_URI, |
| | | // values); |
| | | // // Toast.makeText(getContext(), |
| | | // // "已加入下载列表", |
| | | // // Toast.LENGTH_LONG).show(); |
| | | // SingleToast.showToast(getContext(), |
| | | // "已加入下载列表"); |
| | | // notifyDataSetChanged(); |
| | | // }; |
| | | // |
| | | // }).execute( |
| | | // url, |
| | | // videoDetailInfo.getId(), |
| | | // GetRealPathTask |
| | | // .getNeedSecondConnectServerUrl(videoInfo |
| | | // .getExtraData())); |
| | | // } |
| | | // } |
| | | // } |
| | | // }); |
| | | // } |
| | | downloadCursor.close(); |
| | | } else { |
| | | viewHolder.fl_video_select.setVisibility(View.VISIBLE); |
| | | // viewHolder.chb_watch_history.setVisibility(View.GONE); |
| | | // viewHolder.btn_status.setVisibility(View.GONE); |
| | | // viewHolder.fl_video_select.setVisibility(View.VISIBLE); |
| | | // viewHolder.btn_delete.setVisibility(View.VISIBLE); |
| | | // viewHolder.chb_delete.setVisibility(View.VISIBLE); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (mSelectedIds.contains(id)) { |
| | | mSelectedIds.remove(id); |
| | | } else { |
| | | mSelectedIds.add(id); |
| | | } |
| | | viewHolder.chb_delete.setChecked(mSelectedIds.contains(id)); |
| | | if (getdeleteNumber != null) |
| | | getdeleteNumber.onGetNum(mSelectedIds.size()); |
| | | } |
| | | }); |
| | | viewHolder.chb_delete.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (mSelectedIds.contains(id)) { |
| | | mSelectedIds.remove(id); |
| | | } else { |
| | | mSelectedIds.add(id); |
| | | } |
| | | viewHolder.chb_delete.setChecked(mSelectedIds.contains(id)); |
| | | if (getdeleteNumber != null) |
| | | getdeleteNumber.onGetNum(mSelectedIds.size()); |
| | | } |
| | | }); |
| | | viewHolder.chb_delete.setChecked(mSelectedIds.contains(id)); |
| | | |
| | | } |
| | | viewHolder.iv_cover.setImageResource(R.drawable.ic_default_cover); |
| | | viewHolder.tv_title.setText(""); |
| | | getVideoDetail(context, videoId, videoDetailId, videoInfoStr, |
| | | viewHolder); |
| | | } |
| | | |
| | | private void bindView(ViewHolder viewHolder, String videoDetailId, |
| | | private void bindView(ViewHolder viewHolder, int position, |
| | | VideoInfo videoInfo) { |
| | | String subName = ""; |
| | | for (VideoDetailInfo videoDetailInfo : videoInfo.getVideoDetailList()) { |
| | | if (videoDetailId.equals(videoDetailInfo.getId())) { |
| | | subName = TextUtils.isEmpty(videoDetailInfo.getTag()) ? videoDetailInfo |
| | | .getName() : videoDetailInfo.getTag(); |
| | | } |
| | | } |
| | | if (StringUtils.isEmpty(videoInfo.getName())) { |
| | | videoInfo.setName("."); |
| | | } |
| | | if (subName.equalsIgnoreCase(videoInfo.getName())) { |
| | | viewHolder.tv_title.setSingleLine(true); |
| | | viewHolder.tv_title.setEllipsize(TruncateAt.END); |
| | |
| | | } |
| | | viewHolder.tv_title.setText(videoInfo.getName() |
| | | + System.getProperty("line.separator")); |
| | | viewHolder.tv_watch_time.setText(mContext.getResources().getString( |
| | | viewHolder.tv_watch_time.setText(context.getResources().getString( |
| | | R.string.watch_history_time, subName)); |
| | | } |
| | | |
| | | // imageLoader.displayImage(videoInfo.getPicture(), viewHolder.iv_cover, |
| | | // options); |
| | | if (StringUtils.isEmpty(videoInfo.getPicture())) |
| | | videoInfo.setPicture(""); |
| | | try { |
| | | glide.load(videoInfo.getPicture()) |
| | | Glide.with(context).load(videoInfo.getPicture()) |
| | | .placeholder(R.drawable.ic_default_cover) |
| | | .error(R.drawable.ic_default_cover).into(viewHolder.iv_cover); |
| | | } catch (IllegalArgumentException e) { |
| | |
| | | } |
| | | } |
| | | |
| | | private void getVideoDetail(Context context, final String videoId, |
| | | final String videoDetailId, String videoInfoStr, |
| | | private void getVideoDetail(WatchHistoryVO vo, |
| | | final ViewHolder viewHolder) { |
| | | viewHolder.tv_title.setTag(videoId); |
| | | VideoInfo videoInfo = mVideoInfos.get(videoId); |
| | | viewHolder.tv_title.setTag(vo.getId()); |
| | | VideoInfo videoInfo = vo.getVideoInfo(); |
| | | if (videoInfo != null) { |
| | | bindView(viewHolder, videoDetailId, videoInfo); |
| | | } else { |
| | | Gson gson = new GsonBuilder().setFieldNamingPolicy( |
| | | FieldNamingPolicy.UPPER_CAMEL_CASE).create(); |
| | | videoInfo = gson.fromJson(videoInfoStr, new TypeToken<VideoInfo>() { |
| | | }.getType()); |
| | | mVideoInfos.put(videoId, videoInfo); |
| | | if (viewHolder.tv_title.getTag().equals(videoId)) { |
| | | bindView(viewHolder, videoDetailId, videoInfo); |
| | | } |
| | | bindView(viewHolder, vo.getPosition(), videoInfo); |
| | | } |
| | | } |
| | | |
| | | private String stringForTime(int timeMs) { |
| | | int totalSeconds = timeMs / 1000; |
| | | |
| | | int seconds = totalSeconds % 60; |
| | | int minutes = (totalSeconds / 60) % 60; |
| | | int hours = totalSeconds / 3600; |
| | | |
| | | mFormatBuilder.setLength(0); |
| | | if (hours > 0) { |
| | | return mFormatter.format("%d:%02d:%02d", hours, minutes, seconds) |
| | | .toString(); |
| | | } else { |
| | | return mFormatter.format("%02d:%02d", minutes, seconds).toString(); |
| | | } |
| | | @Override |
| | | public int getCount() { |
| | | return 0; |
| | | } |
| | | |
| | | public Map<String, VideoInfo> getVideoInfos() { |
| | | return mVideoInfos; |
| | | @Override |
| | | public Object getItem(int position) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public long getItemId(int position) { |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public View getView(int position, View convertView, ViewGroup parent) { |
| | | final WatchHistoryVO vo = voList.get(position); |
| | | |
| | | View view = LayoutInflater.from(parent.getContext()).inflate( |
| | | R.layout.watch_history_item, parent, false); |
| | | |
| | | if (view.getTag() == null) { |
| | | ViewHolder holder = new ViewHolder(); |
| | | holder.iv_cover = (ImageView) view.findViewById(R.id.iv_cover); |
| | | holder.tv_title = (TextView) view.findViewById(R.id.tv_title); |
| | | holder.tv_watch_time = (TextView) view.findViewById(R.id.tv_watch_time); |
| | | holder.btn_delete = (ImageButton) view |
| | | .findViewById(R.id.btn_delete_download); |
| | | holder.chb_delete = (CheckBox) view.findViewById(R.id.chb_delete); |
| | | holder.fl_video_select = (FrameLayout) view |
| | | .findViewById(R.id.fl_video_select); |
| | | view.setTag(holder); |
| | | } |
| | | |
| | | final ViewHolder holder = (ViewHolder) view.getTag(); |
| | | |
| | | //非编辑模式 |
| | | if (!mSelectedMode) { |
| | | holder.fl_video_select.setVisibility(View.GONE); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | VideoInfo videoInfo = vo.getVideoInfo(); |
| | | if (videoInfo != null) { |
| | | int playingPosition = vo.getPosition(); |
| | | |
| | | Intent intent = new Intent(v.getContext(), |
| | | VideoDetailActivity2.class); |
| | | VideoInfo info = new VideoInfo(); |
| | | info.setId(videoInfo.getId()); |
| | | info.setShare(videoInfo.getShare()); |
| | | info.setThirdType(videoInfo.getThirdType()); |
| | | intent.putExtra("video_info", info); |
| | | intent.putExtra("playing_position", playingPosition); |
| | | intent.putExtra("isFromWatchHistory", true); |
| | | v.getContext().startActivity(intent); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | selectAll(false); |
| | | holder.fl_video_select.setVisibility(View.GONE); |
| | | } else { |
| | | holder.fl_video_select.setVisibility(View.VISIBLE); |
| | | view.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (mSelectedIds.contains(vo.getId())) { |
| | | mSelectedIds.remove(vo.getId()); |
| | | } else { |
| | | mSelectedIds.add(vo.getId()); |
| | | } |
| | | holder.chb_delete.setChecked(mSelectedIds.contains(vo.getId())); |
| | | if (getdeleteNumber != null) |
| | | getdeleteNumber.onGetNum(mSelectedIds.size()); |
| | | } |
| | | }); |
| | | holder.chb_delete.setOnClickListener(new OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (mSelectedIds.contains(vo.getId())) { |
| | | mSelectedIds.remove(vo.getId()); |
| | | } else { |
| | | mSelectedIds.add(vo.getId()); |
| | | } |
| | | holder.chb_delete.setChecked(mSelectedIds.contains(vo.getId())); |
| | | if (getdeleteNumber != null) |
| | | getdeleteNumber.onGetNum(mSelectedIds.size()); |
| | | } |
| | | }); |
| | | holder.chb_delete.setChecked(mSelectedIds.contains(vo.getId())); |
| | | } |
| | | holder.iv_cover.setImageResource(R.drawable.ic_default_cover); |
| | | holder.tv_title.setText(""); |
| | | getVideoDetail(vo, |
| | | holder); |
| | | |
| | | |
| | | return view; |
| | | } |
| | | |
| | | private static class ViewHolder { |
| | | ImageView iv_cover; |
| | | TextView tv_title; |
| | | TextView tv_watch_time; |
| | | // ImageButton btn_status; |
| | | // CheckBox chb_watch_history; |
| | | ImageButton btn_delete; |
| | | CheckBox chb_delete; |
| | | FrameLayout fl_video_select; |
| | | } |
| | | |
| | | public List<Long> getSelectedIds() { |
| | | public Set<String> getSelectedIds() { |
| | | return mSelectedIds; |
| | | } |
| | | |
| | |
| | | public void selectAll(boolean isSelected) { |
| | | mSelectedIds.clear(); |
| | | if (isSelected) { |
| | | if (mCursor.moveToFirst()) { |
| | | do { |
| | | mSelectedIds.add(mCursor.getLong(mCursor |
| | | .getColumnIndex(WatchHistoryTable._ID))); |
| | | } while (mCursor.moveToNext()); |
| | | for (WatchHistoryVO vo : voList) { |
| | | vo.setSelected(true); |
| | | mSelectedIds.add(vo.getId()); |
| | | } |
| | | |
| | | } else { |
| | | if (mCursor.moveToFirst()) { |
| | | do { |
| | | mSelectedIds.remove(mCursor.getLong(mCursor |
| | | .getColumnIndex(WatchHistoryTable._ID))); |
| | | } while (mCursor.moveToNext()); |
| | | for (WatchHistoryVO vo : voList) { |
| | | vo.setSelected(false); |
| | | } |
| | | } |
| | | if (getdeleteNumber != null) |