use of com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions in project 91Pop by DanteAndroid.
the class DownloadVideoAdapter method convert.
@Override
protected void convert(BaseViewHolder helper, UnLimit91PornItem item) {
helper.setText(R.id.tv_91porn_item_title, item.getTitleWithDuration());
ImageView simpleDraweeView = helper.getView(R.id.iv_91porn_item_img);
Uri uri = Uri.parse(item.getImgUrl());
GlideApp.with(helper.itemView).load(uri).placeholder(R.drawable.placeholder).transition(new DrawableTransitionOptions().crossFade(300)).into(simpleDraweeView);
helper.setProgress(R.id.progressBar_download, item.getProgress());
helper.setText(R.id.tv_download_progress, String.valueOf(item.getProgress()) + "%");
helper.setText(R.id.tv_download_filesize, Formatter.formatFileSize(helper.itemView.getContext(), item.getSoFarBytes()).replace("MB", "") + "/ " + Formatter.formatFileSize(helper.itemView.getContext(), item.getTotalFarBytes()));
if (item.getStatus() == FileDownloadStatus.completed) {
helper.setText(R.id.tv_download_speed, "已完成");
helper.setVisible(R.id.iv_download_control, false);
} else {
// 未下载完成,显示控制
helper.setVisible(R.id.iv_download_control, true);
if (FileDownloader.getImpl().isServiceConnected()) {
helper.setImageResource(R.id.iv_download_control, R.drawable.pause_download);
if (item.getStatus() == FileDownloadStatus.progress) {
helper.setText(R.id.tv_download_speed, item.getSpeed() + " KB/s");
} else if (item.getStatus() == FileDownloadStatus.paused) {
helper.setText(R.id.tv_download_speed, "暂停中");
helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
} else if (item.getStatus() == FileDownloadStatus.pending) {
helper.setText(R.id.tv_download_speed, "准备中");
} else if (item.getStatus() == FileDownloadStatus.started) {
helper.setText(R.id.tv_download_speed, "开始下载");
} else if (item.getStatus() == FileDownloadStatus.connected) {
helper.setText(R.id.tv_download_speed, "连接中");
} else if (item.getStatus() == FileDownloadStatus.error) {
helper.setText(R.id.tv_download_speed, "下载错误");
helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
} else if (item.getStatus() == FileDownloadStatus.retry) {
helper.setText(R.id.tv_download_speed, "重试中");
} else if (item.getStatus() == FileDownloadStatus.warn) {
helper.setText(R.id.tv_download_speed, "警告");
helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
}
} else {
helper.setText(R.id.tv_download_speed, "暂停中");
helper.setImageResource(R.id.iv_download_control, R.drawable.start_download);
}
}
helper.addOnClickListener(R.id.iv_download_control);
helper.addOnClickListener(R.id.right_menu_delete);
}
use of com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions in project 91Pop by DanteAndroid.
the class PictureAdapter method instantiateItem.
@NonNull
@Override
public View instantiateItem(@NonNull ViewGroup container, final int position) {
View contentView = LayoutInflater.from(container.getContext()).inflate(R.layout.item_picture_adapter, container, false);
PhotoView photoView = contentView.findViewById(R.id.photoView);
final ProgressBar progressBar = contentView.findViewById(R.id.progressBar);
String url = imageList.get(position);
if (url.contains("meizitu.net")) {
GlideApp.with(container).load(buildGlideUrl(url)).transition(new DrawableTransitionOptions().crossFade(300)).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
}).into(photoView);
} else {
GlideApp.with(container).load(Uri.parse(url)).transition(new DrawableTransitionOptions().crossFade(300)).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
progressBar.setVisibility(View.GONE);
return false;
}
}).into(photoView);
}
// Now just add PhotoView to ViewPager and return it
container.addView(contentView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
photoView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (onImageClickListener != null) {
onImageClickListener.onImageClick(v, position);
}
}
});
photoView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (onImageClickListener != null) {
onImageClickListener.onImageLongClick(v, position);
}
return true;
}
});
Logger.t(TAG).d("instantiateItem");
return contentView;
}
Aggregations