[#138] Fix exception when saving empty label

This commit is contained in:
Björn Richter 2018-02-20 12:01:54 +01:00
parent 8b9b1fc8aa
commit bffbe51f76

View file

@ -89,14 +89,18 @@ class LetterBitmap {
*/
public Bitmap getLetterTile(String displayName, String key, int width, int height) {
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
char firstChar = displayName.charAt(0);
char firstChar = '?';
if (!displayName.isEmpty()) {
firstChar = displayName.charAt(0);
}
final Canvas c = mCanvas;
c.setBitmap(bitmap);
c.drawColor(pickColor(key));
if (!isEnglishLetterOrDigit(firstChar)) {
firstChar = 'A';
firstChar = '?';
}
mFirstChar[0] = Character.toUpperCase(firstChar);
mPaint.setTextSize(mTileLetterFontSize);