aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/services
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-02 23:59:02 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-03 00:06:57 +0100
commit241de062dad6376e5320138a870d9c0642f52126 (patch)
tree548f87c3eb32cf5b0b9225a11c67f105fbc94f37 /src/main/java/eu/siacs/conversations/services
parent9dd445a50750c3518fa94116f31c2b9e6184d55c (diff)
cleaned up avatar / tile creation
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
-rw-r--r--src/main/java/eu/siacs/conversations/services/AvatarService.java26
1 files changed, 6 insertions, 20 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java
index 70c1d4dd..3ac4462d 100644
--- a/src/main/java/eu/siacs/conversations/services/AvatarService.java
+++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java
@@ -121,8 +121,8 @@ public class AvatarService {
if (count == 0) {
String name = mucOptions.getConversation().getName();
- String letter = name.substring(0, 1);
- int color = UIHelper.getColorForName(name);
+ final String letter = name.isEmpty() ? "X" : name.substring(0,1);
+ final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, 0, 0, size, size);
} else if (count == 1) {
drawTile(canvas, users.get(0), 0, 0, size, size);
@@ -212,15 +212,8 @@ public class AvatarService {
}
bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
- String letter;
- int color;
- if (name.length() > 0) {
- letter = name.substring(0, 1);
- color = UIHelper.getColorForName(name);
- } else {
- letter = "X";
- color = PLACEHOLDER_COLOR;
- }
+ final String letter = name.isEmpty() ? "X" : name.substring(0,1);
+ final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, 0, 0, size, size);
mXmppConnectionService.getBitmapCache().put(KEY, bitmap);
return bitmap;
@@ -275,15 +268,8 @@ public class AvatarService {
}
}
String name = contact != null ? contact.getDisplayName() : user.getName();
- String letter;
- int color;
- if (name.length() > 0) {
- letter = name.substring(0, 1);
- color = UIHelper.getColorForName(name);
- } else {
- letter = "X";
- color = PLACEHOLDER_COLOR;
- }
+ final String letter = name.isEmpty() ? "X" : name.substring(0,1);
+ final int color = UIHelper.getColorForName(name);
drawTile(canvas, letter, color, left, top, right, bottom);
}