package com.yidianling.dynamic.common.tool;

import android.app.Activity;
import android.widget.ImageView;

import com.lzy.imagepicker.loader.ImageLoader;
import com.ydl.ydl_image.config.ISimpleImageOpConfig;
import com.ydl.ydl_image.config.SimpleImageOpConfiger;
import com.ydl.ydl_image.manager.YDLImageCacheManager;
import com.yidianling.dynamic.R;

/**
 * Created by xiongyu on 2017/4/7.
 */

public class GlideImageLoader implements ImageLoader {
    @Override
    public void displayImage(Activity activity, String path, ImageView imageView, int width, int height) {
        showImage(activity,path,imageView,width,height);
    }

    @Override
    public void displayImagePreview(Activity activity, String path, ImageView imageView, int width, int height) {
        showImage(activity,path,imageView,width,height);
    }

    private void showImage(Activity activity, String path, ImageView imageView, int width, int height){
        SimpleImageOpConfiger sp = new SimpleImageOpConfiger();
        sp.loadingPic = R.drawable.dynamic_default_img;
        sp.errorPic = R.drawable.dynamic_default_img;
        sp.scaleType = ISimpleImageOpConfig.CENTER_CROP;
        sp.isCacheOnDisk = false;
        YDLImageCacheManager.showImage(activity,path,imageView,width, height,sp);
    }

    @Override
    public void clearMemoryCache() {

    }
}
