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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapScalerTask.java

Issue 2845773003: Photo Picker Dialog: Add caching for the decoded images. (Closed)
Patch Set: Address feedback from Michael 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.chrome.browser.photo_picker;
6
7 import android.graphics.Bitmap;
8 import android.os.AsyncTask;
9 import android.util.LruCache;
10
11 import org.chromium.base.ThreadUtils;
12
13 /**
14 * A worker task to enumerate image files on disk.
15 */
16 class BitmapScalerTask extends AsyncTask<Bitmap, Void, Bitmap> {
17 private final LruCache<String, Bitmap> mCache;
18 private final String mFilePath;
19 private final int mSize;
20
21 /**
22 * A BitmapScalerTask constructor.
23 */
24 public BitmapScalerTask(LruCache<String, Bitmap> cache, String filePath, int size) {
25 mCache = cache;
26 mFilePath = filePath;
27 mSize = size;
28 }
29
30 /**
31 * Enumerates (in the background) the image files on disk. Called on a non-U I thread
Michael van Ouwerkerk 2017/05/08 14:44:22 nit: please update the description
Finnur 2017/05/08 14:59:17 Done.
32 * @param params Ignored, do not use.
33 * @return A sorted list of images (by last-modified first).
34 */
35 @Override
36 protected Bitmap doInBackground(Bitmap... bitmaps) {
37 assert !ThreadUtils.runningOnUiThread();
38
39 if (isCancelled()) return null;
40
41 return BitmapUtils.scale(bitmaps[0], mSize, false);
42 }
43
44 /**
45 * Communicates the results back to the client. Called on the UI thread.
46 * @param result The resulting scaled bitmap
47 */
48 @Override
49 protected void onPostExecute(Bitmap result) {
50 if (isCancelled()) {
51 return;
52 }
53
54 mCache.put(mFilePath, result);
55 }
56 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/photo_picker/BitmapUtils.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698