@Override public void onBindViewHolder(final ItemViewHolder itemViewHolder, final int position) { final DownloadTask downloadTask = datas.get(position); String sid = downloadTask.getTid(); String imageUrl = HttpUtil.getSkinThemePreviewImageByID(sid); ImageLoadUtil.loadImageFormUrl( imageUrl, itemViewHolder.getImavPic(), R.drawable.picture_manager_default, true); itemViewHolder.getMainTextView().setText(downloadTask.gettName() + ""); itemViewHolder.getSkinSizeTextView().setText(getFileSize(downloadTask.getFileSize()) + ""); itemViewHolder.getSkinProgressBar().setMax((int) downloadTask.getFileSize()); itemViewHolder.getSkinProgressBar().setProgress((int) downloadTask.getDownloadedSize()); reshViewHolder(position, itemViewHolder, downloadTask); }
/** * 刷新ui * * @param position * @param itemViewHolder * @param downloadTask */ private void reshViewHolder( final int position, final ItemViewHolder itemViewHolder, final DownloadTask downloadTask) { if (SkinThemeDB.getSkinThemeDB(context).skinThemeIsExists(downloadTask.getTid())) { // itemViewHolder.getDownloadstatusRelativeLayout().setVisibility( // View.INVISIBLE); // itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE); if (!downloadTask.getTid().equals(Constants.skinID)) { itemViewHolder.getselectImageView().setVisibility(View.INVISIBLE); itemViewHolder .getItembg() .setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // 加载皮肤数据 loadSkin(position, downloadTask, itemViewHolder); } }); } else { itemViewHolder.getItembg().setOnClickListener(null); // selectedIndex = position; itemViewHolder.getselectImageView().setVisibility(View.VISIBLE); } itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE); itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.INVISIBLE); } else { itemViewHolder.getselectImageView().setVisibility(View.INVISIBLE); if (downloadTask.getStatus() == DownloadTask.DOWNLOAD_FINISH) { itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE); itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.INVISIBLE); itemViewHolder .getItembg() .setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // 加载皮肤数据 loadSkin(position, downloadTask, itemViewHolder); } }); } else if (downloadTask.getStatus() == DownloadTask.DOWNLOING || downloadTask.getStatus() == DownloadTask.WAITING) { itemViewHolder.getSkinProgressBar().setVisibility(View.VISIBLE); itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.INVISIBLE); itemViewHolder.getItembg().setOnClickListener(null); } else { itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE); itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.VISIBLE); itemViewHolder .getItembg() .setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { // 下载皮肤 downloadSkin(position, downloadTask); } }); } } }