Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(649)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java

Issue 2865963003: [Suggestions UI] Drop Bitmap references from articles under memory pressure. (Closed)
Patch Set: remove annotation Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
index 3b3f9c51059c9714ebe07b99d8fec69172299b7c..4a3be792866f6bff0f4d9214e87a8138ea7f475e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetArticleViewHolder.java
@@ -356,7 +356,7 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
mArticle.setThumbnailBitmap(null);
Bitmap thumbnail = mThumbnailProvider.getThumbnail(mImageCallback);
if (thumbnail == null || thumbnail.isRecycled()) return;
- mArticle.setThumbnailBitmap(thumbnail);
+ mArticle.setThumbnailBitmap(mUiDelegate.getReferencePool().put(thumbnail));
setThumbnailFromBitmap(thumbnail);
return;
@@ -371,8 +371,9 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
// mThumbnailView's visibility is modified in updateLayout().
if (mThumbnailView.getVisibility() != View.VISIBLE) return;
- if (mArticle.getThumbnailBitmap() != null && !mArticle.getThumbnailBitmap().isRecycled()) {
- setThumbnailFromBitmap(mArticle.getThumbnailBitmap());
+ Bitmap thumbnail = mArticle.getThumbnailBitmap();
+ if (thumbnail != null && !thumbnail.isRecycled()) {
+ setThumbnailFromBitmap(thumbnail);
return;
}
@@ -418,7 +419,7 @@ public class SnippetArticleViewHolder extends CardViewHolder implements Impressi
thumbnail, targetSize, targetSize, ThumbnailUtils.OPTIONS_RECYCLE_INPUT);
// Store the bitmap to skip the download task next time we display this snippet.
- snippet.setThumbnailBitmap(scaledThumbnail);
+ snippet.setThumbnailBitmap(mUiDelegate.getReferencePool().put(scaledThumbnail));
// Cross-fade between the placeholder and the thumbnail. We cross-fade because the incoming
// image may have transparency and we don't want the previous image showing up behind.

Powered by Google App Engine
This is Rietveld 408576698