aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/AvatarService.java
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/services/AvatarService.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/services/AvatarService.java b/src/main/java/de/pixart/messenger/services/AvatarService.java
index f4a9b9818..4ed01c42a 100644
--- a/src/main/java/de/pixart/messenger/services/AvatarService.java
+++ b/src/main/java/de/pixart/messenger/services/AvatarService.java
@@ -14,6 +14,7 @@ import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.support.annotation.ColorInt;
import android.support.annotation.Nullable;
import android.support.v4.content.res.ResourcesCompat;
import android.text.TextUtils;
@@ -72,6 +73,19 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
return (int) (SYSTEM_UI_AVATAR_SIZE * context.getResources().getDisplayMetrics().density);
}
+ public Bitmap get(final Avatarable avatarable, final int size, final boolean cachedOnly) {
+ if (avatarable instanceof Account) {
+ return get((Account) avatarable,size,cachedOnly);
+ } else if (avatarable instanceof Conversation) {
+ return get((Conversation) avatarable, size, cachedOnly);
+ } else if (avatarable instanceof Message) {
+ return get((Message) avatarable, size, cachedOnly);
+ } else if (avatarable instanceof ListItem) {
+ return get((ListItem) avatarable, size, cachedOnly);
+ }
+ throw new AssertionError("AvatarService does not know how to generate avatar from "+avatarable.getClass().getName());
+ }
+
private Bitmap get(final Contact contact, final int size, boolean cachedOnly) {
if (contact.isSelf()) {
return get(contact.getAccount(), size, cachedOnly);
@@ -650,4 +664,9 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded {
private static String emptyOnNull(@Nullable Jid value) {
return value == null ? "" : value.toString();
}
+
+ public interface Avatarable {
+ @ColorInt
+ int getAvatarBackgroundColor();
+ }
} \ No newline at end of file