urbanairship-core/src/main/java/com/urbanairship/iam/MediaDisplayAdapter.java
@PrepareResult
    protected int cacheMedia(Context context, MediaInfo mediaInfo) {
        if (mediaInfo == null || !mediaInfo.getType().equals(MediaInfo.TYPE_IMAGE)) {
            return OK;
        }

        try {
            createCache(context);

            File file = cache.file(IMAGE_FILE_NAME);
            FileUtils.DownloadResult result = FileUtils.downloadFile(new URL(mediaInfo.getUrl()), file);

            if (!result.isSuccess) {
                if (UAHttpStatusUtil.inClientErrorRange(result.statusCode)) {
                    return CANCEL;
                }

                return RETRY;
            }
            cache.getBundle().putString(InAppMessageCache.MEDIA_CACHE_KEY, Uri.fromFile(file).toString());

            // Cache the width and height for view resizing
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(file.getAbsolutePath(), options);
            cache.getBundle().putInt(InAppMessageCache.IMAGE_WIDTH_CACHE_KEY, options.outWidth);
            cache.getBundle().putInt(InAppMessageCache.IMAGE_HEIGHT_CACHE_KEY, options.outHeight);
            return OK;
        } catch (IOException e) {
            Logger.debug("Failed to cache media.", e);
            return RETRY;
        }
    }
/**
     * Caches the media info.
     *
     * @param context The application context.
     * @param mediaInfo The media info.
     * @return {@link #OK} if the media was null, did not contain a cacheable resource, or if the
     * resource was cached. {@link #RETRY} if it failed to cache the resource.
     */
Caches the media info.
@param context The application context.
@param mediaInfo The media info.
@return  #OK if the media was null, did not contain a cacheable resource, or if the
resource was cached.  #RETRY if it failed to cache the resource.
Caches the media info . @param context The application context . @param mediaInfo The media info . @return #OK if the media was null did not contain a cacheable resource or if the resource was cached . #RETRY if it failed to cache the resource .
@PrepareResult
    protected int cacheMedia(Context context, MediaInfo mediaInfo) {
        if (mediaInfo == null || !mediaInfo.getType().equals(MediaInfo.TYPE_IMAGE)) {
            return OK;
        }
        try {
            createCache(context);
            File file = cache.file(IMAGE_FILE_NAME);
            FileUtils.DownloadResult result = FileUtils.downloadFile(new URL(mediaInfo.getUrl()), file);
            if (!result.isSuccess) {
                if (UAHttpStatusUtil.inClientErrorRange(result.statusCode)) {
                    return CANCEL;
                }
                return RETRY;
            }
            cache.getBundle().putString(InAppMessageCache.MEDIA_CACHE_KEY, Uri.fromFile(file).toString());
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeFile(file.getAbsolutePath(), options);
            cache.getBundle().putInt(InAppMessageCache.IMAGE_WIDTH_CACHE_KEY, options.outWidth);
            cache.getBundle().putInt(InAppMessageCache.IMAGE_HEIGHT_CACHE_KEY, options.outHeight);
            return OK;
        } catch (IOException e) {
            Logger.debug("Failed to cache media.", e);
            return RETRY;
        }
    }
@ PrepareResult protected int cacheMedia ( Context context , MediaInfo mediaInfo ) { if ( mediaInfo == null || ! mediaInfo . getType ( ) . equals ( MediaInfo . TYPE_IMAGE ) ) { return OK ; } try { createCache ( context ) ; File file = cache . file ( IMAGE_FILE_NAME ) ; FileUtils . DownloadResult result = FileUtils . downloadFile ( new URL ( mediaInfo . getUrl ( ) ) , file ) ; if ( ! result . isSuccess ) { if ( UAHttpStatusUtil . inClientErrorRange ( result . statusCode ) ) { return CANCEL ; } return RETRY ; } cache . getBundle ( ) . putString ( InAppMessageCache . MEDIA_CACHE_KEY , Uri . fromFile ( file ) . toString ( ) ) ; BitmapFactory . Options options = new BitmapFactory . Options ( ) ; options . inJustDecodeBounds = true ; BitmapFactory . decodeFile ( file . getAbsolutePath ( ) , options ) ; cache . getBundle ( ) . putInt ( InAppMessageCache . IMAGE_WIDTH_CACHE_KEY , options . outWidth ) ; cache . getBundle ( ) . putInt ( InAppMessageCache . IMAGE_HEIGHT_CACHE_KEY , options . outHeight ) ; return OK ; } catch ( IOException e ) { Logger . debug ( "Failed to cache media." , e ) ; return RETRY ; } }
Caches the media info.
Caches the media info .
// Cache the width and height for view resizing