use of com.bumptech.glide.request.target.BitmapImageViewTarget in project GestureViews by alexvasilkov.
the class GlideHelper method loadResource.
public static void loadResource(@DrawableRes int drawableId, @NonNull ImageView image) {
DisplayMetrics metrics = image.getResources().getDisplayMetrics();
final int displayWidth = metrics.widthPixels;
final int displayHeight = metrics.heightPixels;
Glide.with(image.getContext()).load(drawableId).asBitmap().dontAnimate().diskCacheStrategy(DiskCacheStrategy.NONE).into(new BitmapImageViewTarget(image) {
@Override
public void getSize(final SizeReadyCallback cb) {
// We don't want to load very big images on devices with small screens.
// This will help Glide correctly choose images scale when reading them.
super.getSize(new SizeReadyCallback() {
@Override
public void onSizeReady(int width, int height) {
cb.onSizeReady(displayWidth / 2, displayHeight / 2);
}
});
}
});
}
use of com.bumptech.glide.request.target.BitmapImageViewTarget in project android by nextcloud.
the class AvatarGroupLayout method showFederatedShareAvatar.
private void showFederatedShareAvatar(Context context, String user, float avatarRadius, Resources resources, ImageView avatar) {
// maybe federated share
String[] split = user.split("@");
String userId = split[0];
String server = split[1];
String url = "https://" + server + "/index.php/avatar/" + userId + "/" + resources.getInteger(R.integer.file_avatar_px);
Drawable placeholder;
try {
placeholder = TextDrawable.createAvatarByUserId(userId, avatarRadius);
} catch (Exception e) {
Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
placeholder = ThemeDrawableUtils.tintDrawable(ResourcesCompat.getDrawable(resources, R.drawable.account_circle_white, null), R.color.black);
}
avatar.setTag(null);
Glide.with(context).load(url).asBitmap().placeholder(placeholder).error(placeholder).into(new BitmapImageViewTarget(avatar) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(resources, resource);
circularBitmapDrawable.setCircular(true);
avatar.setImageDrawable(circularBitmapDrawable);
}
});
}
use of com.bumptech.glide.request.target.BitmapImageViewTarget in project MovieGuide by esoxjem.
the class MoviesListingAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
holder.itemView.setOnClickListener(holder);
holder.movie = movies.get(position);
holder.name.setText(holder.movie.getTitle());
RequestOptions options = new RequestOptions().centerCrop().diskCacheStrategy(DiskCacheStrategy.AUTOMATIC).priority(Priority.HIGH);
Glide.with(context).asBitmap().load(Api.getPosterPath(holder.movie.getPosterPath())).apply(options).into(new BitmapImageViewTarget(holder.poster) {
@Override
public void onResourceReady(Bitmap bitmap, @Nullable Transition<? super Bitmap> transition) {
super.onResourceReady(bitmap, transition);
Palette.from(bitmap).generate(palette -> setBackgroundColor(palette, holder));
}
});
}
use of com.bumptech.glide.request.target.BitmapImageViewTarget in project JustAndroid by chinaltz.
the class PictureAlbumDirectoryAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
final LocalMediaFolder folder = folders.get(position);
String name = folder.getName();
int imageNum = folder.getImageNum();
String imagePath = folder.getFirstImagePath();
boolean isChecked = folder.isChecked();
int checkedNum = folder.getCheckedNum();
holder.tv_sign.setVisibility(checkedNum > 0 ? View.VISIBLE : View.INVISIBLE);
holder.itemView.setSelected(isChecked);
Glide.with(holder.itemView.getContext()).load(imagePath).asBitmap().error(R.drawable.ic_placeholder).centerCrop().override(150, 150).diskCacheStrategy(DiskCacheStrategy.RESULT).into(new BitmapImageViewTarget(holder.first_image) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), resource);
circularBitmapDrawable.setCornerRadius(8);
holder.first_image.setImageDrawable(circularBitmapDrawable);
}
});
holder.image_num.setText("(" + imageNum + ")");
holder.tv_folder_name.setText(name);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (onItemClickListener != null)
for (LocalMediaFolder mediaFolder : folders) {
mediaFolder.setChecked(false);
}
folder.setChecked(true);
notifyDataSetChanged();
onItemClickListener.onItemClick(folder.getName(), folder.getImages());
}
});
}
use of com.bumptech.glide.request.target.BitmapImageViewTarget in project iosched by google.
the class MyIODialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Context context = getContext();
AlertDialog.Builder builder = new AlertDialog.Builder(context);
boolean signedIn = AccountUtils.hasActiveAccount(context);
if (signedIn) {
LayoutInflater inflater = LayoutInflater.from(context);
View titleView = inflater.inflate(R.layout.myio_auth_dialog_signedin_title, null);
TextView name = (TextView) titleView.findViewById(R.id.name);
TextView email = (TextView) titleView.findViewById(R.id.email);
final ImageView avatar = (ImageView) titleView.findViewById(R.id.avatar);
name.setText(AccountUtils.getActiveAccountDisplayName(context));
email.setText(AccountUtils.getActiveAccountName(context));
// Note: this may be null if the user has not set up a profile photo.
Uri url = AccountUtils.getActiveAccountPhotoUrl(context);
if (url != null) {
Glide.with(context).load(url.toString()).asBitmap().fitCenter().placeholder(R.drawable.ic_default_avatar).into(new BitmapImageViewTarget(avatar) {
@Override
protected void setResource(Bitmap resource) {
RoundedBitmapDrawable roundedBmp = RoundedBitmapDrawableFactory.create(context.getResources(), resource);
roundedBmp.setCircular(true);
avatar.setImageDrawable(roundedBmp);
}
});
}
builder.setCustomTitle(titleView);
builder.setMessage(buildDialogText(context, R.string.my_io_body_intro_signed_in, R.string.my_io_dialog_first_bullet_point_signed_in, R.string.my_io_dialog_second_bullet_point_signed_in, R.string.my_io_dialog_third_bullet_point_signed_in, Color.BLACK));
} else {
builder.setMessage(buildDialogText(getContext(), R.string.my_io_body_intro_signed_out, R.string.my_io_dialog_first_bullet_point_signed_out, R.string.my_io_dialog_second_bullet_point_signed_out, R.string.my_io_dialog_third_bullet_point_signed_out, Color.BLACK));
}
builder.setPositiveButton(signedIn ? R.string.signout_prompt : R.string.signin_prompt, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
MyIOActivity myIOActivity = ((MyIOActivity) getActivity());
if (AccountUtils.hasActiveAccount(myIOActivity)) {
myIOActivity.signOut();
} else {
myIOActivity.signIn();
}
dismiss();
}
});
return builder.create();
}
Aggregations