Fix NPE when issuer was not set
This commit is contained in:
parent
5fb5416d2e
commit
cd2310f110
2 changed files with 4 additions and 2 deletions
|
@ -30,6 +30,7 @@ import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.appcompat.content.res.AppCompatResources;
|
import androidx.appcompat.content.res.AppCompatResources;
|
||||||
|
@ -42,13 +43,14 @@ public class EntryThumbnail {
|
||||||
|
|
||||||
if (thumbnail == EntryThumbnails.Default && size > 0) {
|
if (thumbnail == EntryThumbnails.Default && size > 0) {
|
||||||
LetterBitmap letterBitmap = new LetterBitmap(context);
|
LetterBitmap letterBitmap = new LetterBitmap(context);
|
||||||
String letterSrc = issuer.isEmpty() ? label : issuer;
|
String letterSrc = TextUtils.isEmpty(issuer) ? label : issuer;
|
||||||
return letterBitmap.getLetterTile(letterSrc, letterSrc, size, size);
|
return letterBitmap.getLetterTile(letterSrc, letterSrc, size, size);
|
||||||
} else if (thumbnail != EntryThumbnails.Default) {
|
} else if (thumbnail != EntryThumbnails.Default) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (thumbnail.getAssetType() == AssetType.Vector) {
|
if (thumbnail.getAssetType() == AssetType.Vector) {
|
||||||
Drawable drawable = AppCompatResources.getDrawable(context, thumbnail.getResource());
|
Drawable drawable = AppCompatResources.getDrawable(context, thumbnail.getResource());
|
||||||
|
assert drawable != null; // The thumbnail should always have a drawable
|
||||||
Bitmap bitmap = Bitmap.createBitmap(drawable.getMinimumWidth(), drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888);
|
Bitmap bitmap = Bitmap.createBitmap(drawable.getMinimumWidth(), drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888);
|
||||||
Canvas canvas = new Canvas(bitmap);
|
Canvas canvas = new Canvas(bitmap);
|
||||||
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
|
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder
|
||||||
|
|
||||||
int thumbnailSize = settings.getThumbnailSize();
|
int thumbnailSize = settings.getThumbnailSize();
|
||||||
if(settings.getThumbnailVisible()) {
|
if(settings.getThumbnailVisible()) {
|
||||||
thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, entry.getIssuer(), entry.getLabel(), thumbnailSize, entry.getThumbnail()));
|
thumbnailImg.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, issuerText, labelText, thumbnailSize, entry.getThumbnail()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.isTimeBased() && (entry.hasNonDefaultPeriod() || settings.isShowIndividualTimeoutsEnabled())) {
|
if (entry.isTimeBased() && (entry.hasNonDefaultPeriod() || settings.isShowIndividualTimeoutsEnabled())) {
|
||||||
|
|
Loading…
Reference in a new issue