use of com.bumptech.glide.request.RequestOptions in project MLib by DaoBillTang.
the class PhotoPagerAdapter method instantiateItem.
@Override
public Object instantiateItem(ViewGroup container, int position) {
final Context context = container.getContext();
View itemView = LayoutInflater.from(context).inflate(R.layout.__picker_picker_item_pager, container, false);
final ImageView imageView = (ImageView) itemView.findViewById(R.id.iv_pager);
final String path = paths.get(position);
final Uri uri;
if (path.startsWith("http")) {
uri = Uri.parse(path);
} else {
uri = Uri.fromFile(new File(path));
}
boolean canLoadImage = AndroidLifecycleUtils.canLoadImage(context);
if (canLoadImage) {
final RequestOptions options = new RequestOptions();
options.dontAnimate().dontTransform().override(800, 800).placeholder(R.drawable.__picker_ic_photo_black_48dp).error(R.drawable.__picker_ic_broken_image_black_48dp);
mGlide.setDefaultRequestOptions(options).load(uri).thumbnail(0.1f).into(imageView);
}
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (context instanceof Activity) {
if (!((Activity) context).isFinishing()) {
((Activity) context).onBackPressed();
}
}
}
});
container.addView(itemView);
return itemView;
}
use of com.bumptech.glide.request.RequestOptions in project Rocket by mozilla-tw.
the class TabTrayAdapter method loadCachedFavicon.
private void loadCachedFavicon(final Tab tab, final ViewHolder holder) {
RequestOptions options = new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE).dontAnimate();
Bitmap favicon = tab.getFavicon();
FaviconModel model = new FaviconModel(tab.getUrl(), FavIconUtils.getFavIconType(holder.itemView.getResources(), favicon), favicon);
requestManager.load(model).apply(options).listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
loadGeneratedFavicon(tab, holder);
return true;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
}).into(new SimpleTarget<Drawable>() {
@Override
public void onResourceReady(Drawable resource, Transition<? super Drawable> transition) {
updateFavicon(holder, resource);
}
});
}
use of com.bumptech.glide.request.RequestOptions in project KL2 by jweihao.
the class GridImageAdapter method onBindViewHolder.
/**
* 设置值
*/
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position) {
// 少于8张,显示继续添加的图标
if (getItemViewType(position) == TYPE_CAMERA) {
viewHolder.mImg.setImageResource(R.drawable.addimg_1x);
viewHolder.mImg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnAddPicClickListener.onAddPicClick();
}
});
viewHolder.ll_del.setVisibility(View.INVISIBLE);
} else {
viewHolder.ll_del.setVisibility(View.VISIBLE);
viewHolder.ll_del.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int index = viewHolder.getAdapterPosition();
// 通过源码分析应该是bindViewHolder()暂未绘制完成导致,知道原因的也可联系我~感谢
if (index != RecyclerView.NO_POSITION) {
list.remove(index);
notifyItemRemoved(index);
notifyItemRangeChanged(index, list.size());
}
}
});
LocalMedia media = list.get(position);
int mimeType = media.getMimeType();
String path = "";
if (media.isCut() && !media.isCompressed()) {
// 裁剪过
path = media.getCutPath();
} else if (media.isCompressed() || (media.isCut() && media.isCompressed())) {
// 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
path = media.getCompressPath();
} else {
// 原图
path = media.getPath();
}
// 图片
if (media.isCompressed()) {
Log.i("compress image result:", new File(media.getCompressPath()).length() / 1024 + "k");
Log.i("压缩地址::", media.getCompressPath());
}
Log.i("原图地址::", media.getPath());
int pictureType = PictureMimeType.isPictureType(media.getPictureType());
if (media.isCut()) {
Log.i("裁剪地址::", media.getCutPath());
}
long duration = media.getDuration();
viewHolder.tv_duration.setVisibility(pictureType == PictureConfig.TYPE_VIDEO ? View.VISIBLE : View.GONE);
if (mimeType == PictureMimeType.ofAudio()) {
viewHolder.tv_duration.setVisibility(View.VISIBLE);
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.picture_audio);
StringUtils.modifyTextViewDrawable(viewHolder.tv_duration, drawable, 0);
} else {
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.video_icon);
StringUtils.modifyTextViewDrawable(viewHolder.tv_duration, drawable, 0);
}
viewHolder.tv_duration.setText(DateUtils.timeParse(duration));
if (mimeType == PictureMimeType.ofAudio()) {
viewHolder.mImg.setImageResource(R.drawable.audio_placeholder);
} else {
RequestOptions options = new RequestOptions().centerCrop().placeholder(R.color.color_f6).diskCacheStrategy(DiskCacheStrategy.ALL);
Glide.with(viewHolder.itemView.getContext()).load(path).apply(options).into(viewHolder.mImg);
}
// itemView 的点击事件
if (mItemClickListener != null) {
viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int adapterPosition = viewHolder.getAdapterPosition();
mItemClickListener.onItemClick(adapterPosition, v);
}
});
}
}
}
use of com.bumptech.glide.request.RequestOptions in project LabDayApp by jakdor.
the class TimetableViewHolder method bind.
public void bind(Timetable timetable, Event event, int pos) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm", Locale.GERMAN);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT+1"));
Date start = new Date((long) timetable.getTimeStart() * 1000);
Date end = new Date((long) timetable.getTimeEnd() * 1000);
glide.load(event.getImg()).apply(new RequestOptions().placeholder(R.mipmap.ic_launcher_foreground).centerCrop()).transition(withCrossFade()).into(binding.timetableItemImage);
binding.setIsNow(isNow(start, end));
binding.setIsDarkColor(pos % 2 == 0);
binding.setTimeStart(simpleDateFormat.format(start));
binding.setTimeEnd(simpleDateFormat.format(end));
binding.setTimetable(timetable);
binding.setEvent(event);
binding.executePendingBindings();
}
use of com.bumptech.glide.request.RequestOptions in project Camera-Roll-Android-App by kollerlukas.
the class AlbumHolder method loadImage.
void loadImage(final ImageView image) {
if (album.getAlbumItems().size() == 0) {
Glide.with(getContext()).load(R.drawable.error_placeholder).apply(new RequestOptions().skipMemoryCache(true)).into(image);
return;
}
final AlbumItem coverImage = album.getAlbumItems().get(0);
Glide.with(getContext()).asBitmap().load(coverImage.getPath()).listener(new RequestListener<Bitmap>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Bitmap> target, boolean isFirstResource) {
coverImage.error = true;
if (image instanceof ParallaxImageView) {
((ParallaxImageView) image).setParallaxTranslation();
}
return false;
}
@Override
public boolean onResourceReady(Bitmap resource, Object model, Target<Bitmap> target, DataSource dataSource, boolean isFirstResource) {
if (!coverImage.hasFadedIn) {
coverImage.hasFadedIn = true;
ColorFade.fadeSaturation(image);
}
if (image instanceof ParallaxImageView) {
((ParallaxImageView) image).setParallaxTranslation();
}
return false;
}
}).apply(coverImage.getGlideRequestOptions(getContext())).into(image);
}
Aggregations