package com.cmb.zh.common.util;
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;
import com.cmb.zhsdk.magi.task.ICancelable;
public interface ImgLoadManager {
interface LoadListener {
void onSuccess(Bitmap bitmap);
void onFailed(Throwable error);
}
interface ImgLoadReq {
/**
* 默认图片
*
* @param placeholderResId 默认资源id
* @return
*/
ImgLoadReq placeholder(int placeholderResId);
/**
* 错误图片
*
* @param errorResId 默认资源id
* @return
*/
ImgLoadReq error(int errorResId);
/**
* 设置tag,用于开启或结束图片加载
*
* @param tag
* @return
*/
ImgLoadReq tag(Object tag);
/**
* 重置图片宽高
*
* @param width
* @param height
* @return
*/
ImgLoadReq resize(int width, int height);
/**
* CenterInside()是一种尺度图像的裁剪技术,这样两个尺寸等于或小于请求的ImageView的界限。图像将显示完全,但可能不会填满整个ImageView
*
* @return
*/
ImgLoadReq centerInside();
/**
* CenterCrop()是一种尺度图像的裁剪技术,填补了ImageView的要求范围,然后修剪其余的范围。ImageView将被完全填满,但整个图像可能不会显示
*
* @return
*/
ImgLoadReq centerCrop();
/**
* 图片旋转
*
* @param degrees 旋转的角度
* @return
*/
ImgLoadReq rotate(float degrees);
/**
* 加载图片至imageView控件
*
* @param imgView
*/
ICancelable into(ImageView imgView);
ICancelable into(LoadListener listener);
/**
* 自适应控件宽高设置图片(wrap_content 无法计算)
*
* @return
*/
ImgLoadReq fit();
}
/**
* 加载
*
* @param path 可以是 url 或 本地路径(本地路径时需完全路径file://...,否则无法正常显示)
* @return
*/
ImgLoadReq load(String path);
/**
* 加载资源文件
*
* @param resourceId 资源id
* @return
*/
ImgLoadReq load(int resourceId);
ImgLoadReq load(Uri path);
/**
* 加载本地图片
*
* @param path 图片本地路径
* @return
*/
ImgLoadReq loadFile(String path);
/**
* 关闭请求
*
* @param tag
*/
void pauseLoadByTag(Object tag);
/**
* 开启请求
*
* @param tag
*/
void resumeLoadByTag(Object tag);
}
import android.graphics.Bitmap;
import android.net.Uri;
import android.widget.ImageView;
import com.cmb.zhsdk.magi.task.ICancelable;
public interface ImgLoadManager {
interface LoadListener {
void onSuccess(Bitmap bitmap);
void onFailed(Throwable error);
}
interface ImgLoadReq {
/**
* 默认图片
*
* @param placeholderResId 默认资源id
* @return
*/
ImgLoadReq placeholder(int placeholderResId);
/**
* 错误图片
*
* @param errorResId 默认资源id
* @return
*/
ImgLoadReq error(int errorResId);
/**
* 设置tag,用于开启或结束图片加载
*
* @param tag
* @return
*/
ImgLoadReq tag(Object tag);
/**
* 重置图片宽高
*
* @param width
* @param height
* @return
*/
ImgLoadReq resize(int width, int height);
/**
* CenterInside()是一种尺度图像的裁剪技术,这样两个尺寸等于或小于请求的ImageView的界限。图像将显示完全,但可能不会填满整个ImageView
*
* @return
*/
ImgLoadReq centerInside();
/**
* CenterCrop()是一种尺度图像的裁剪技术,填补了ImageView的要求范围,然后修剪其余的范围。ImageView将被完全填满,但整个图像可能不会显示
*
* @return
*/
ImgLoadReq centerCrop();
/**
* 图片旋转
*
* @param degrees 旋转的角度
* @return
*/
ImgLoadReq rotate(float degrees);
/**
* 加载图片至imageView控件
*
* @param imgView
*/
ICancelable into(ImageView imgView);
ICancelable into(LoadListener listener);
/**
* 自适应控件宽高设置图片(wrap_content 无法计算)
*
* @return
*/
ImgLoadReq fit();
}
/**
* 加载
*
* @param path 可以是 url 或 本地路径(本地路径时需完全路径file://...,否则无法正常显示)
* @return
*/
ImgLoadReq load(String path);
/**
* 加载资源文件
*
* @param resourceId 资源id
* @return
*/
ImgLoadReq load(int resourceId);
ImgLoadReq load(Uri path);
/**
* 加载本地图片
*
* @param path 图片本地路径
* @return
*/
ImgLoadReq loadFile(String path);
/**
* 关闭请求
*
* @param tag
*/
void pauseLoadByTag(Object tag);
/**
* 开启请求
*
* @param tag
*/
void resumeLoadByTag(Object tag);
}