Last active
September 3, 2015 12:10
-
-
Save MateuszMlodawski/53c30ba8e8f9f93f9458 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.widget.ImageView; | |
import com.bumptech.glide.Glide; | |
import com.bumptech.glide.Priority; | |
import com.bumptech.glide.load.data.DataFetcher; | |
import com.bumptech.glide.load.engine.DiskCacheStrategy; | |
import com.bumptech.glide.load.model.stream.StreamModelLoader; | |
import java.io.InputStream; | |
public class GlideUtils { | |
public static void loadOnlyFromCache(Context context, String url, ImageView imageView) { | |
Glide.with(context) | |
.using(new StreamModelLoader<String>() { | |
@Override | |
public DataFetcher<InputStream> getResourceFetcher(final String model, int width, int height) { | |
return new DataFetcher<InputStream>() { | |
@Override | |
public InputStream loadData(Priority priority) throws Exception { | |
return null; | |
} | |
@Override | |
public void cleanup() { | |
} | |
@Override | |
public String getId() { | |
return model; | |
} | |
@Override | |
public void cancel() { | |
} | |
}; | |
} | |
}) | |
.load(url) | |
.diskCacheStrategy(DiskCacheStrategy.ALL) | |
.into(imageView); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment