/* * Copyright (C) 2014 pengjianbo(pengjianbosoft@gmail.com), Inc. * * 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 cn.finalteam.galleryfinal.sample.loader; import android.app.Activity; import android.graphics.drawable.Drawable; import cn.finalteam.galleryfinal.sample.R; import cn.finalteam.galleryfinal.widget.GFImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.load.engine.DiskCacheStrategy; import com.bumptech.glide.load.resource.drawable.GlideDrawable; import com.bumptech.glide.request.Request; import com.bumptech.glide.request.target.ImageViewTarget; /** * Desction: * Author:pengjianbo * Date:15/12/1 下午10:28 */ public class GlideImageLoader implements cn.finalteam.galleryfinal.ImageLoader { @Override public void displayImage(Activity activity, String path, final GFImageView imageView, Drawable defaultDrawable, int width, int height) { Glide.with(activity) .load("file://" + path) .placeholder(defaultDrawable) .error(defaultDrawable) .override(width, height) .diskCacheStrategy(DiskCacheStrategy.NONE) //不缓存到SD卡 .skipMemoryCache(true) //.centerCrop() .into(new ImageViewTarget(imageView) { @Override protected void setResource(GlideDrawable resource) { imageView.setImageDrawable(resource); } @Override public void setRequest(Request request) { imageView.setTag(R.id.adapter_item_tag_key,request); } @Override public Request getRequest() { return (Request) imageView.getTag(R.id.adapter_item_tag_key); } }); } @Override public void clearMemoryCache() { } }