Bug 1300484 - IconDownloader: Check if best bitmap is not null. r=ahunt

MozReview-Commit-ID: 7A1u6EefKt9

--HG--
extra : rebase_source : 36334c8dd49dcdbdf3f34edc633604d058112fb1
This commit is contained in:
Sebastian Kaspari 2016-09-05 11:43:00 +02:00
parent d2fd8a9859
commit c3c4c19eb4
2 changed files with 9 additions and 3 deletions

View File

@ -5,6 +5,7 @@
package org.mozilla.gecko.icons.decoders;
import android.graphics.Bitmap;
import android.support.annotation.Nullable;
import android.util.Log;
import android.util.SparseArray;
@ -77,6 +78,7 @@ public class LoadFaviconResult {
return null;
}
@Nullable
public Bitmap getBestBitmap(int targetWidthAndHeight) {
final SparseArray<Bitmap> iconMap = new SparseArray<>();
final List<Integer> sizes = new ArrayList<>();

View File

@ -6,6 +6,7 @@
package org.mozilla.gecko.icons.loader;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.annotation.VisibleForTesting;
import android.util.Log;
@ -60,9 +61,12 @@ public class IconDownloader implements IconLoader {
return null;
}
return IconResponse.createFromNetwork(
result.getBestBitmap(request.getTargetSize()),
iconUrl);
final Bitmap bitmap = result.getBestBitmap(request.getTargetSize());
if (bitmap == null) {
return null;
}
return IconResponse.createFromNetwork(bitmap, iconUrl);
} catch (Exception e) {
Log.e(LOGTAG, "Error reading favicon", e);
} catch (OutOfMemoryError e) {