Generate TextDrawable based on issuer and use account name as fallback

This commit is contained in:
Alexander Bakker 2018-06-06 16:27:56 +02:00
parent 4a4ab1a82c
commit 3aba0f3f47
3 changed files with 28 additions and 22 deletions

View file

@ -8,13 +8,16 @@ public class TextDrawableHelper {
}
public static TextDrawable generate(String s) {
if (s == null || s.length() <= 1) {
return null;
public static TextDrawable generate(String text, String fallback) {
if (text == null || text.isEmpty()) {
if (fallback == null || fallback.isEmpty()) {
return null;
}
text = fallback;
}
ColorGenerator generator = ColorGenerator.MATERIAL;
int color = generator.getColor(s);
return TextDrawable.builder().buildRound(s.substring(0, 1).toUpperCase(), color);
int color = generator.getColor(text);
return TextDrawable.builder().buildRound(text.substring(0, 1).toUpperCase(), color);
}
}