// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/ContentCache.java
// @Beta
// public enum CacheSource {
//     MEMORY,
//     DISK,
//     NETWORK;
// }
// 
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/bitmap/AnimationMode.java
// @Beta
// public enum AnimationMode {
//     /**
//      * Use no animation (same as using a normal {@link BitmapAsyncSetter})
//      */
//     NEVER,
//     /**
//      * Animate only if the bitmap is not already in the memory caches
//      */
//     NOT_IN_MEMORY,
//     /**
//      * Animate only if the bitmap was loaded from network
//      */
//     FROM_NETWORK,
//     /**
//      * Always animate (use with care: the performance impact can be noticeable when scrolling long
//      * lists of bitmaps)
//      */
//     ALWAYS;
// }
// 
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/bitmap/BitmapCache.java
// @Beta
// public interface OnBitmapSetListener {
// 
//     /**
//      * Called from the UI thread when the retrieved bitmap image has been set into the {@link
//      * ImageView}
//      *
//      * @param key    The {@link CacheUrlKey} of the bitmap
//      * @param bitmap The set {@link Bitmap}
//      * @param source The {@link CacheSource} of the bitmap
//      */
//     public void onBitmapSet(@NonNull CacheUrlKey key, @NonNull Bitmap bitmap,
//                             @NonNull CacheSource source);
// }
// 
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/keys/CacheUrlKey.java
// @Beta
// @SuppressLint("ParcelCreator")
// public interface CacheUrlKey extends CacheKey, Parcelable {
// 
//     /**
//      * Gets the hash string used as a key
//      */
//     @NonNull
//     public String hash();
// 
//     /**
//      * Gets the string URL hold by this {@link CacheUrlKey}
//      */
//     @NonNull
//     public String getUrl();
// 
// }


import javax.annotation.concurrent.ThreadSafe;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.github.marcosalis.kraken.cache.ContentCache.CacheSource;
import com.github.marcosalis.kraken.cache.bitmap.AnimationMode;
import com.github.marcosalis.kraken.cache.bitmap.BitmapCache.OnBitmapSetListener;
import com.github.marcosalis.kraken.cache.keys.CacheUrlKey;
import com.google.common.annotations.Beta;
/*
 * Copyright 2013 Luluvise Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.marcosalis.kraken.cache.bitmap.internal;




/**
 * Extension of {@link BitmapAsyncSetter} that starts a fade-in animation right after setting the
 * image bitmap when this is loaded from the disk or network.
 *
 * @author Marco Salis
 * @since 1.0
 */
@Beta
@ThreadSafe
public class BitmapAnimatedAsyncSetter extends BitmapAsyncSetter {

    private static final String TAG = BitmapAnimatedAsyncSetter.class.getSimpleName();

    protected static final int DEFAULT_ANIM_ID = android.R.anim.fade_in;

    protected final AnimationMode mAnimationMode; // defaults to NOT_IN_MEMORY
    protected final int mCustomAnimationId;

	/* Constructors from superclass */

    public BitmapAnimatedAsyncSetter(@NonNull CacheUrlKey key, @NonNull ImageView imgView) {
        this(key, imgView, AnimationMode.NOT_IN_MEMORY, null, -1);
    }

    public BitmapAnimatedAsyncSetter(@NonNull CacheUrlKey key, @NonNull ImageView imgView,
                                     @Nullable OnBitmapSetListener listener) {
        this(key, imgView, AnimationMode.NOT_IN_MEMORY, listener, -1);
    }

    /**
     * @param key               The {@link CacheUrlKey} for the bitmap
     * @param mode              The {@link AnimationMode} to use
     * @param customAnimationId The ID of a custom animation to load, or -1 to use the default
     *                          Android fade-in animation.
     * @see BitmapAsyncSetter#BitmapAsyncSetter(ImageView, BitmapAsyncSetter#OnBitmapImageSetListener)
     */
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/ContentCache.java
// @Beta
// public enum CacheSource {
//     MEMORY,
//     DISK,
//     NETWORK;
// }
// 
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/bitmap/AnimationMode.java
// @Beta
// public enum AnimationMode {
//     /**
//      * Use no animation (same as using a normal {@link BitmapAsyncSetter})
//      */
//     NEVER,
//     /**
//      * Animate only if the bitmap is not already in the memory caches
//      */
//     NOT_IN_MEMORY,
//     /**
//      * Animate only if the bitmap was loaded from network
//      */
//     FROM_NETWORK,
//     /**
//      * Always animate (use with care: the performance impact can be noticeable when scrolling long
//      * lists of bitmaps)
//      */
//     ALWAYS;
// }
// 
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/bitmap/BitmapCache.java
// @Beta
// public interface OnBitmapSetListener {
// 
//     /**
//      * Called from the UI thread when the retrieved bitmap image has been set into the {@link
//      * ImageView}
//      *
//      * @param key    The {@link CacheUrlKey} of the bitmap
//      * @param bitmap The set {@link Bitmap}
//      * @param source The {@link CacheSource} of the bitmap
//      */
//     public void onBitmapSet(@NonNull CacheUrlKey key, @NonNull Bitmap bitmap,
//                             @NonNull CacheSource source);
// }
// 
// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/keys/CacheUrlKey.java
// @Beta
// @SuppressLint("ParcelCreator")
// public interface CacheUrlKey extends CacheKey, Parcelable {
// 
//     /**
//      * Gets the hash string used as a key
//      */
//     @NonNull
//     public String hash();
// 
//     /**
//      * Gets the string URL hold by this {@link CacheUrlKey}
//      */
//     @NonNull
//     public String getUrl();
// 
// }


// Path: kraken_lib/src/main/java/com/github/marcosalis/kraken/cache/bitmap/internal/BitmapAnimatedAsyncSetter.java
import javax.annotation.concurrent.ThreadSafe;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.github.marcosalis.kraken.cache.ContentCache.CacheSource;
import com.github.marcosalis.kraken.cache.bitmap.AnimationMode;
import com.github.marcosalis.kraken.cache.bitmap.BitmapCache.OnBitmapSetListener;
import com.github.marcosalis.kraken.cache.keys.CacheUrlKey;
import com.google.common.annotations.Beta;

/*
 * Copyright 2013 Luluvise Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.github.marcosalis.kraken.cache.bitmap.internal;




/**
 * Extension of {@link BitmapAsyncSetter} that starts a fade-in animation right after setting the
 * image bitmap when this is loaded from the disk or network.
 *
 * @author Marco Salis
 * @since 1.0
 */
@Beta
@ThreadSafe
public class BitmapAnimatedAsyncSetter extends BitmapAsyncSetter {

    private static final String TAG = BitmapAnimatedAsyncSetter.class.getSimpleName();

    protected static final int DEFAULT_ANIM_ID = android.R.anim.fade_in;

    protected final AnimationMode mAnimationMode; // defaults to NOT_IN_MEMORY
    protected final int mCustomAnimationId;

	/* Constructors from superclass */

    public BitmapAnimatedAsyncSetter(@NonNull CacheUrlKey key, @NonNull ImageView imgView) {
        this(key, imgView, AnimationMode.NOT_IN_MEMORY, null, -1);
    }

    public BitmapAnimatedAsyncSetter(@NonNull CacheUrlKey key, @NonNull ImageView imgView,
                                     @Nullable OnBitmapSetListener listener) {
        this(key, imgView, AnimationMode.NOT_IN_MEMORY, listener, -1);
    }

    /**
     * @param key               The {@link CacheUrlKey} for the bitmap
     * @param mode              The {@link AnimationMode} to use
     * @param customAnimationId The ID of a custom animation to load, or -1 to use the default
     *                          Android fade-in animation.
     * @see BitmapAsyncSetter#BitmapAsyncSetter(ImageView, BitmapAsyncSetter#OnBitmapImageSetListener)
     */
    public BitmapAnimatedAsyncSetter(@NonNull CacheUrlKey key, @NonNull ImageView imgView,