mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-27 09:27:25 +00:00
41 lines
1.0 KiB
Java
41 lines
1.0 KiB
Java
package org.thoughtcrime.securesms.contacts.avatars;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.widget.ImageView;
|
|
|
|
import com.makeramen.roundedimageview.RoundedDrawable;
|
|
|
|
public class BitmapContactPhoto implements ContactPhoto {
|
|
|
|
private final Bitmap bitmap;
|
|
|
|
BitmapContactPhoto(Bitmap bitmap) {
|
|
this.bitmap = bitmap;
|
|
}
|
|
|
|
@Override
|
|
public Drawable asDrawable(Context context, int color) {
|
|
return asDrawable(context, color, false);
|
|
}
|
|
|
|
@Override
|
|
public Drawable asDrawable(Context context, int color, boolean inverted) {
|
|
return RoundedDrawable.fromBitmap(bitmap)
|
|
.setScaleType(ImageView.ScaleType.CENTER_CROP)
|
|
.setOval(true);
|
|
}
|
|
|
|
@Override
|
|
public Drawable asCallCard(Context context) {
|
|
return new BitmapDrawable(context.getResources(), bitmap);
|
|
}
|
|
|
|
@Override
|
|
public boolean isGenerated() {
|
|
return false;
|
|
}
|
|
}
|