This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Create placeholder drawable | |
* */ | |
private void setDrawable() { | |
drawable = new Drawable() { | |
@Override | |
public void draw(@NonNull Canvas canvas) { | |
int centerX = Math.round(canvas.getWidth() * 0.5f); | |
int centerY = Math.round(canvas.getHeight() * 0.5f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Return user short name | |
* */ | |
public static String getShortName(String name) { | |
String[] strings = name.split(" ");//no i18n | |
String shortName; | |
if (strings.length == 1) { | |
shortName = strings[0].substring(0, 2); | |
} else { | |
shortName = strings[0].substring(0, 1) + strings[1].substring(0, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Initialize fields | |
* */ | |
protected void init() { | |
rectF = new RectF(); | |
clipPath = new Path(); | |
imageSize = getResources().getDimensionPixelSize(R.dimen.avatar_size); | |
cornerRadius = (int) Utils.dpToPixel(2, getResources()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Path of them image to be clipped (to be shown) | |
* */ | |
Path clipPath; | |
/* | |
* Place holder drawable (with background color and initials) | |
* */ | |
Drawable drawable; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout | |
android:id="@+id/speaker_avatar_container" | |
android:layout_width="40dp" | |
android:layout_height="40dp" | |
android:layout_gravity="center_vertical"> | |
<TextView | |
android:id="@+id/placeholder" | |
android:layout_width="40dp" | |
android:layout_height="40dp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<FrameLayout | |
android:id="@+id/speaker_avatar_container" | |
android:layout_width="40dp" | |
android:layout_height="40dp" | |
android:layout_gravity="center_vertical"> | |
<TextView | |
android:id="@+id/placeholder" | |
android:layout_width="40dp" | |
android:layout_height="40dp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
placeholder.setText(getInitials()); | |
ViewUtil.setVisibility(avatar, View.GONE); | |
Glide.with(context) | |
.load(member.getAvatar()) | |
.asBitmap() | |
.into(new SimpleTarget<Bitmap>() { | |
@Override | |
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { | |
avatar.setImageBitmap(resource); | |
ViewUtil.setVisibility(placeholder, View.GONE); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
android:shape="rectangle"> | |
<solid android:color="@color/grey" /> | |
<size | |
android:width="40dp" | |
android:height="40dp" /> | |
</shape> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
android:shape="rectangle"> | |
<corners android:radius="20dp" /> | |
<solid android:color="@color/grey" /> | |
<size | |
android:width="40dp" | |
android:height="40dp" /> | |
</shape> |