package org.example.gallery.bitmap;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.File;

/**
 * Created by d on 2016-07-17.
 * my device is cannot query thumbnail path
 * but MediaStore.Images.Thumbnails.getThumbnail is work
 */
public final class BitmapLoader {
    public interface ImageLoader {
        Bitmap imageLoader();
    }

    private final Context context;

    private static final BitmapFactory.Options defaultBitmapOptions = new BitmapFactory.Options();

    static {
        defaultBitmapOptions.inDither = false;
        defaultBitmapOptions.inPreferQualityOverSpeed = false;
        defaultBitmapOptions.inSampleSize = 2;
        defaultBitmapOptions.inPreferredConfig = Bitmap.Config.RGB_565;
    }

    public BitmapLoader(Context context) {
        this.context = context;
    }

    public static final BitmapLoader with(Context context) {
        return new BitmapLoader(context);
    }

    public final Loader load(ImageLoader loadTask) {
        return new Loader(context,null).load(loadTask);
    }

    public final Loader load(final File path) {
        return new Loader(context, path);
    }
}
