Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInlineImageCache.java +1 −10 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.net.Uri; import android.os.AsyncTask; import android.util.Log; import java.io.IOException; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; Loading Loading @@ -82,16 +81,8 @@ public class NotificationInlineImageCache implements NotificationInlineImageReso @Override protected Drawable doInBackground(Uri... uris) { Drawable drawable = null; Uri target = uris[0]; try { drawable = mResolver.resolveImage(target); } catch (IOException | SecurityException ex) { Log.d(TAG, "PreloadImageTask: Resolve failed from " + target, ex); } return drawable; return mResolver.resolveImage(target); } } } packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInlineImageResolver.java +18 −19 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.android.internal.widget.ImageResolver; import com.android.internal.widget.LocalImageResolver; import com.android.internal.widget.MessagingMessage; import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; Loading Loading @@ -111,30 +110,30 @@ public class NotificationInlineImageResolver implements ImageResolver { * To resolve image from specified uri directly. If the resulting image is larger than the * maximum allowed size, scale it down. * @param uri Uri of the image. * @return Drawable of the image. * @throws IOException Throws if failed at resolving the image. * @return Drawable of the image, or null if unable to load. */ Drawable resolveImage(Uri uri) throws IOException { Drawable resolveImage(Uri uri) { try { return LocalImageResolver.resolveImage(uri, mContext, mMaxImageWidth, mMaxImageHeight); } catch (Exception ex) { // Catch general Exception because ContentResolver can re-throw arbitrary Exception // from remote process as a RuntimeException. See: Parcel#readException Log.d(TAG, "resolveImage: Can't load image from " + uri, ex); } return null; } @Override public Drawable loadImage(Uri uri) { Drawable result = null; try { if (hasCache()) { return hasCache() ? loadImageFromCache(uri) : resolveImage(uri); } private Drawable loadImageFromCache(Uri uri) { // if the uri isn't currently cached, try caching it first if (!mImageCache.hasEntry(uri)) { mImageCache.preload((uri)); } result = mImageCache.get(uri); } else { result = resolveImage(uri); } } catch (IOException | SecurityException ex) { Log.d(TAG, "loadImage: Can't load image from " + uri, ex); } return result; return mImageCache.get(uri); } /** Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInlineImageCache.java +1 −10 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.net.Uri; import android.os.AsyncTask; import android.util.Log; import java.io.IOException; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; Loading Loading @@ -82,16 +81,8 @@ public class NotificationInlineImageCache implements NotificationInlineImageReso @Override protected Drawable doInBackground(Uri... uris) { Drawable drawable = null; Uri target = uris[0]; try { drawable = mResolver.resolveImage(target); } catch (IOException | SecurityException ex) { Log.d(TAG, "PreloadImageTask: Resolve failed from " + target, ex); } return drawable; return mResolver.resolveImage(target); } } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/row/NotificationInlineImageResolver.java +18 −19 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ import com.android.internal.widget.ImageResolver; import com.android.internal.widget.LocalImageResolver; import com.android.internal.widget.MessagingMessage; import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; Loading Loading @@ -111,30 +110,30 @@ public class NotificationInlineImageResolver implements ImageResolver { * To resolve image from specified uri directly. If the resulting image is larger than the * maximum allowed size, scale it down. * @param uri Uri of the image. * @return Drawable of the image. * @throws IOException Throws if failed at resolving the image. * @return Drawable of the image, or null if unable to load. */ Drawable resolveImage(Uri uri) throws IOException { Drawable resolveImage(Uri uri) { try { return LocalImageResolver.resolveImage(uri, mContext, mMaxImageWidth, mMaxImageHeight); } catch (Exception ex) { // Catch general Exception because ContentResolver can re-throw arbitrary Exception // from remote process as a RuntimeException. See: Parcel#readException Log.d(TAG, "resolveImage: Can't load image from " + uri, ex); } return null; } @Override public Drawable loadImage(Uri uri) { Drawable result = null; try { if (hasCache()) { return hasCache() ? loadImageFromCache(uri) : resolveImage(uri); } private Drawable loadImageFromCache(Uri uri) { // if the uri isn't currently cached, try caching it first if (!mImageCache.hasEntry(uri)) { mImageCache.preload((uri)); } result = mImageCache.get(uri); } else { result = resolveImage(uri); } } catch (IOException | SecurityException ex) { Log.d(TAG, "loadImage: Can't load image from " + uri, ex); } return result; return mImageCache.get(uri); } /** Loading