Android Open Source - Dreamer Blur Manager






From Project

Back to project page Dreamer.

License

The source code is released under:

Apache License

If you think the Android project Dreamer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.android.fancyblurdemo.app.imageblur;
/*from w w  w. j  a  va 2  s .  c  o  m*/
import android.content.Context;
import android.graphics.Bitmap;

import com.android.fancyblurdemo.volley.toolbox.ImageLoader;

/**
 * Created by kevin.marlow on 2/21/14.
 */
public class BlurManager {

    private static int DISK_IMAGECACHE_SIZE = 1024*1024*10;
    private static Bitmap.CompressFormat DISK_IMAGECACHE_COMPRESS_FORMAT = Bitmap.CompressFormat.PNG;
    private static int DISK_IMAGECACHE_QUALITY = 100;  //PNG is lossless so quality is ignored but must be provided

    /** Internal instance variable. */
    private static BlurManager sInstance;

    /** The blur queue. */
    private BlurQueue mBlurQueue;

    /**
     * Image blurrer.
     */
    private ImageBlurrer mImageBlurer;

    /**
     * Image cache implementation
     */
    private ImageLoader.ImageCache mImageCache;

    private BlurManager() {
        // no instances
    }

    /**
     * This is the initializer.
     * @param context The application context.
     * @param uniqueName The unique name of the image cache.
     */
    public static void init(Context context, String uniqueName) {
        if (sInstance == null) {
            sInstance = new BlurManager();
            sInstance.mImageCache = new DiskLruImageCache(context, uniqueName, DISK_IMAGECACHE_SIZE, DISK_IMAGECACHE_COMPRESS_FORMAT, DISK_IMAGECACHE_QUALITY);
            sInstance.mBlurQueue = new BlurQueue(sInstance.mImageCache);
            sInstance.mBlurQueue.start();
            sInstance.mImageBlurer = new ImageBlurrer(sInstance.mBlurQueue);
        }
    }

    /**
     * Gets the blur queue from the singleton.
     * @return The BlurQueue.
     * @throws IllegalStateException This is thrown if init has not been called.
     */
    public static BlurQueue getBlurQueue() {
        if (sInstance == null) {
            throw new IllegalStateException("The BlurManager must be initialized.");
        }
        return sInstance.mBlurQueue;
    }

    /**
     * Gets the image blurrer from the singleton.
     * @return The ImageBlurrer.
     * @throws IllegalStateException This is thrown if init has not been called.
     */
    public static ImageBlurrer getImageBlurrer() {
        if (sInstance == null) {
            throw new IllegalStateException("The BlurManager must be initialized.");
        }
        return sInstance.mImageBlurer;
    }

    /**
     * Gets a bitmap from the cache.
     * @param cacheKey The key used for cache lookup.
     * @return The bitmap.
     */
    public static Bitmap getBitmap(String cacheKey) {
        if (sInstance == null) {
            throw new IllegalStateException("You must call init() first.");
        }
        return sInstance.mImageCache.getBitmap(cacheKey);
    }

    /**
     * Puts a bitmap in the cache.
     * @param cacheKey The key used for cache lookup.
     * @param bitmap The bitmap to cache.
     */
    public static void putBitmap(String cacheKey, Bitmap bitmap) {
        if (sInstance == null) {
            throw new IllegalStateException("You must call init() first.");
        }
        sInstance.mImageCache.putBitmap(cacheKey, bitmap);
    }
}




Java Source Code List

com.android.fancyblurdemo.app.BitmapLruImageCache.java
com.android.fancyblurdemo.app.BlurImageView.java
com.android.fancyblurdemo.app.ContextWrapperEdgeEffect.java
com.android.fancyblurdemo.app.DreamAdapter.java
com.android.fancyblurdemo.app.EdgeEffectViewPager.java
com.android.fancyblurdemo.app.FlickrDream.java
com.android.fancyblurdemo.app.FlickrPhoto.java
com.android.fancyblurdemo.app.FlickrRequest.java
com.android.fancyblurdemo.app.FlickrScroller.java
com.android.fancyblurdemo.app.MainActivity.java
com.android.fancyblurdemo.app.MainApplication.java
com.android.fancyblurdemo.app.PhotoFragment.java
com.android.fancyblurdemo.app.PhotoSizeRequest.java
com.android.fancyblurdemo.app.PreCompositeTextTask.java
com.android.fancyblurdemo.app.RobotoTextView.java
com.android.fancyblurdemo.app.TopSwipeLayout.java
com.android.fancyblurdemo.app.VolleyManager.java
com.android.fancyblurdemo.app.imageblur.BlurDispatcher.java
com.android.fancyblurdemo.app.imageblur.BlurError.java
com.android.fancyblurdemo.app.imageblur.BlurManager.java
com.android.fancyblurdemo.app.imageblur.BlurQueue.java
com.android.fancyblurdemo.app.imageblur.BlurRequest.java
com.android.fancyblurdemo.app.imageblur.BlurResponseDelivery.java
com.android.fancyblurdemo.app.imageblur.BlurResponse.java
com.android.fancyblurdemo.app.imageblur.DiskLruImageCache.java
com.android.fancyblurdemo.app.imageblur.ImageBlurrer.java
com.android.fancyblurdemo.volley.AuthFailureError.java
com.android.fancyblurdemo.volley.CacheDispatcher.java
com.android.fancyblurdemo.volley.Cache.java
com.android.fancyblurdemo.volley.DefaultRetryPolicy.java
com.android.fancyblurdemo.volley.ExecutorDelivery.java
com.android.fancyblurdemo.volley.NetworkDispatcher.java
com.android.fancyblurdemo.volley.NetworkError.java
com.android.fancyblurdemo.volley.NetworkResponse.java
com.android.fancyblurdemo.volley.Network.java
com.android.fancyblurdemo.volley.NoConnectionError.java
com.android.fancyblurdemo.volley.ParseError.java
com.android.fancyblurdemo.volley.RequestQueue.java
com.android.fancyblurdemo.volley.Request.java
com.android.fancyblurdemo.volley.ResponseDelivery.java
com.android.fancyblurdemo.volley.Response.java
com.android.fancyblurdemo.volley.RetryPolicy.java
com.android.fancyblurdemo.volley.ServerError.java
com.android.fancyblurdemo.volley.TimeoutError.java
com.android.fancyblurdemo.volley.VolleyError.java
com.android.fancyblurdemo.volley.VolleyLog.java
com.android.fancyblurdemo.volley.toolbox.AndroidAuthenticator.java
com.android.fancyblurdemo.volley.toolbox.Authenticator.java
com.android.fancyblurdemo.volley.toolbox.BasicNetwork.java
com.android.fancyblurdemo.volley.toolbox.ByteArrayPool.java
com.android.fancyblurdemo.volley.toolbox.ClearCacheRequest.java
com.android.fancyblurdemo.volley.toolbox.DiskBasedCache.java
com.android.fancyblurdemo.volley.toolbox.HttpClientStack.java
com.android.fancyblurdemo.volley.toolbox.HttpHeaderParser.java
com.android.fancyblurdemo.volley.toolbox.HttpStack.java
com.android.fancyblurdemo.volley.toolbox.HurlStack.java
com.android.fancyblurdemo.volley.toolbox.ImageLoader.java
com.android.fancyblurdemo.volley.toolbox.ImageRequest.java
com.android.fancyblurdemo.volley.toolbox.JsonArrayRequest.java
com.android.fancyblurdemo.volley.toolbox.JsonObjectRequest.java
com.android.fancyblurdemo.volley.toolbox.JsonRequest.java
com.android.fancyblurdemo.volley.toolbox.NetworkImageView.java
com.android.fancyblurdemo.volley.toolbox.NoCache.java
com.android.fancyblurdemo.volley.toolbox.PoolingByteArrayOutputStream.java
com.android.fancyblurdemo.volley.toolbox.RequestFuture.java
com.android.fancyblurdemo.volley.toolbox.StringRequest.java
com.android.fancyblurdemo.volley.toolbox.Volley.java