Java Code Examples for com.nostra13.universalimageloader.utils.DiskCacheUtils

The following examples show how to use com.nostra13.universalimageloader.utils.DiskCacheUtils. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Rey-MusicPlayer   Source File: AlbumsArtDownloadService.java    License: Apache License 2.0 5 votes vote down vote up
public void setAlbumArt(File file, Bitmap artworkBitmap, Song song) throws IOException, TagException, ReadOnlyFileException, CannotReadException, InvalidAudioFrameException {

        artworkBitmap = Bitmap.createScaledBitmap(artworkBitmap, 500, 500, false);

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        artworkBitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);

        byte[] byteArray = stream.toByteArray();

        File artworkFile = new File(Environment.getExternalStorageDirectory() + "/artwork.jpg");

        if (!artworkFile.exists())
            artworkFile.createNewFile();

        FileOutputStream out = new FileOutputStream(artworkFile);
        artworkBitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);

        Artwork artwork = Artwork.createArtworkFromFile(artworkFile);

        artwork.setBinaryData(byteArray);
        AudioFile audioFile = AudioFileIO.read(file);
        Tag tag = audioFile.getTagOrCreateAndSetDefault();


        if (tag.getFirstArtwork() != null) {
            tag.deleteArtworkField();
            tag.setField(artwork);
        } else {
            tag.addField(artwork);
        }

        Uri uri = MusicUtils.getAlbumArtUri(song._albumId);
        DiskCacheUtils.removeFromCache(uri.toString(), ImageLoader.getInstance().getDiskCache());
        String path = FileUtils.getRealPathFromURI(uri);
        new File(path).delete();
        artworkFile.delete();
    }
 
Example 2
Source Project: apng-view   Source File: ApngImageLoadingListener.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
    if (view == null) return;

    Object tag = view.getTag(R.id.tag_image);
    if (enableDebugLog) FLog.d("tag: %s", tag);

    if (tag != null && tag instanceof String) {
        String actualUri = tag.toString();

        File pngFile = AssistUtil.getCopiedFile(context, actualUri);

        if (pngFile == null) {
            if (enableDebugLog) FLog.w("Can't locate the file!!! %s", actualUri);

        } else if (pngFile.exists()) {
            boolean isApng = AssistUtil.isApng(pngFile);

            if (isApng) {
                if (enableDebugLog) FLog.d("Setup apng drawable");
                ApngDrawable drawable = new ApngDrawable(context, loadedImage, Uri.fromFile(pngFile));
                ((ImageView) view).setImageDrawable(drawable);
            } else {
                ((ImageView) view).setImageBitmap(loadedImage);
            }

        } else {
            if (enableDebugLog) FLog.d("Clear cache and reload");
            MemoryCacheUtils.removeFromCache(actualUri, ApngImageLoader.getInstance().getMemoryCache());
            DiskCacheUtils.removeFromCache(actualUri, ApngImageLoader.getInstance().getDiskCache());

            ApngImageLoader.getInstance().displayImage(actualUri, (ImageView) view, this);
        }
    }

    if (shouldForward()) callback.onLoadFinish(true, imageUri, view);
}
 
Example 3
Source Project: MiBandDecompiled   Source File: BraceletImageLoader.java    License: Apache License 2.0 4 votes vote down vote up
public File getDiscCache(String s)
{
    return DiskCacheUtils.findInCache(s, b.getDiscCache());
}
 
Example 4
Source Project: MiBandDecompiled   Source File: BraceletImageLoader.java    License: Apache License 2.0 4 votes vote down vote up
public void removeImageCache(String s)
{
    MemoryCacheUtils.removeFromCache(s, b.getMemoryCache());
    DiskCacheUtils.removeFromCache(s, b.getDiscCache());
}