Skip to content

Instantly share code, notes, and snippets.

@virendersran01
Forked from muthuraj57/SetAvatar.java
Created July 11, 2020 11:30
Show Gist options
  • Save virendersran01/eaa76b95d3aacb47956a4ff820634ff7 to your computer and use it in GitHub Desktop.
Save virendersran01/eaa76b95d3aacb47956a4ff820634ff7 to your computer and use it in GitHub Desktop.
if(circleTheme){
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.circle);
placeholder.setBackground(drawable);
} else {
Drawable drawable = ContextCompat.getDrawable(context, R.drawable.square);
placeholder.setBackground(drawable);
}
placeholder.setText(getInitials());
ViewUtil.setVisibility(avatar, View.GONE);
ViewUtil.setVisibility(squareAvatar, View.GONE);
Glide.with(context)
.load(member.getAvatar())
.asBitmap()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
if(circleTheme){
avatar.setImageBitmap(resource);
ViewUtil.setVisibility(avatar, View.VISIBLE);
} else {
squareAvatar.setImageBitmap(resource);
ViewUtil.setVisibility(squareAvatar, View.VISIBLE);
}
ViewUtil.setVisibility(placeholder, View.GONE);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment