/**
* 注意: 次构造器不支持下载进度提示功能
* @param context
* @param withCache 是否支持缓存
* false--不带缓存
* true--支持缓存功能,默认缓存路径在外置存储缓冲目录中的picasso-big-cache文件夹中
*/
public ImageLoader(Context context, boolean withCache) {
this(context, null, withCache);
}
/**
* 支持下载进度提示,以及设置缓存路径
* @param context
* @param listener 下载进度监听器
* @param cachePath 缓存路径字符串
*/
public ImageLoader(Context context, ProgressListener listener, String cachePath) {
// TODO extend to support multiple libraries as Glide
// TODO must be initialized and kept as an member instance to avoid losing cache
Picasso.Builder builder = setupLoaderClientWithCachePath(context, listener, cachePath);
setupListener(builder);
picasso = builder.build();
picasso.setIndicatorsEnabled(BuildConfig.DEBUG);
picasso.setLoggingEnabled(BuildConfig.DEBUG);
}
/**
* 支持下载进度提示,以及设置缓存路径为默认路径picasso-big-cache
* @param context
* @param listener 下载进度监听器
* @param withCache 是否支持缓存
*/
public ImageLoader(Context context, ProgressListener listener, boolean withCache) {
// TODO extend to support multiple libraries as Glide
// TODO must be initialized and kept as an member instance to avoid losing cache
Picasso.Builder builder = setupLoaderClient(context, listener, withCache);
setupListener(builder);
picasso = builder.build();
picasso.setIndicatorsEnabled(BuildConfig.DEBUG);
picasso.setLoggingEnabled(BuildConfig.DEBUG);
}
public void shutdown() {
if (picasso == null) return;
Logger.d(Logger.TAG, "Image loader has been shutdown");
picasso.shutdown();
callback = null;
}
public ImageLoader cancelRequest(ImageView imageView) {
picasso.cancelRequest(imageView);
return this;
}
public ImageLoader load(final int resourceId) {
cleanResources();
this.imageResourceId = resourceId;
return this;
}
public ImageLoader load(final String imageUri) {
cleanResources();
this.imageUri = imageUri;
return this;
}
public ImageLoader withPlaceholder(final int placeholder) {
this.placeholder = placeholder;
return this;
}
public ImageLoader withErrorImage(final int errorImage) {
this.errorImage = errorImage;
return this;
}
public ImageLoader withTag(final String tag) {
this.tag = tag;
return this;
}
public void pause(final String tag) {
if (picasso == null) return;
picasso.pauseTag(tag);
}
public void resume(final String tag) {
if (picasso == null) return;
picasso.resumeTag(tag);
}
public ImageLoader withCallback(final Callback callback) {
this.callback = callback;
return this;
}
public ImageLoader fit() {
this.fit = true;
return this;
}
public ImageLoader centerCrop() {
this.centerCrop = true;
return this;
}
public ImageLoader centerInside() {
this.centerInside = true;
return this;
}
public ImageLoader resize(final int widthResId, final int heightResId) {
this.widthResId = widthResId;
this.heigthResId = heightResId;
return this;
}
public void into(final ImageView imageView) {
run(imageView);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有