[#138] Fix exception when saving empty label
This commit is contained in:
parent
8b9b1fc8aa
commit
bffbe51f76
1 changed files with 6 additions and 2 deletions
|
@ -89,14 +89,18 @@ class LetterBitmap {
|
||||||
*/
|
*/
|
||||||
public Bitmap getLetterTile(String displayName, String key, int width, int height) {
|
public Bitmap getLetterTile(String displayName, String key, int width, int height) {
|
||||||
final Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
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;
|
final Canvas c = mCanvas;
|
||||||
c.setBitmap(bitmap);
|
c.setBitmap(bitmap);
|
||||||
c.drawColor(pickColor(key));
|
c.drawColor(pickColor(key));
|
||||||
|
|
||||||
if (!isEnglishLetterOrDigit(firstChar)) {
|
if (!isEnglishLetterOrDigit(firstChar)) {
|
||||||
firstChar = 'A';
|
firstChar = '?';
|
||||||
}
|
}
|
||||||
mFirstChar[0] = Character.toUpperCase(firstChar);
|
mFirstChar[0] = Character.toUpperCase(firstChar);
|
||||||
mPaint.setTextSize(mTileLetterFontSize);
|
mPaint.setTextSize(mTileLetterFontSize);
|
||||||
|
|
Loading…
Reference in a new issue