diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..30aa626
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 3963879..a7ca378 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,25 +1,42 @@
+
+
+
+
+
+
@@ -30,4 +47,7 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml
new file mode 100644
index 0000000..c1ac4dc
--- /dev/null
+++ b/.idea/qaplug_profiles.xml
@@ -0,0 +1,763 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 0946b74..79228eb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,7 +7,7 @@ buildscript {
google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0'
+ classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.novoda:bintray-release:0.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/glide/build.gradle b/glide/build.gradle
index 8f8b7b0..99a0a78 100644
--- a/glide/build.gradle
+++ b/glide/build.gradle
@@ -42,7 +42,7 @@ dependencies {
compile 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation "com.github.bumptech.glide:okhttp3-integration:4.7.1"
-// implementation project(':imageloader-framework')
- provided "com.ladingwu.library:imageloader-framework:$library_version"
+ implementation project(':imageloader-framework')
+// provided "com.ladingwu.library:imageloader-framework:$library_version"
}
diff --git a/glide/src/main/java/com/ladingwu/glidelibrary/GlideImageLocader.java b/glide/src/main/java/com/ladingwu/glidelibrary/GlideImageLocader.java
index 6938700..9ce3661 100644
--- a/glide/src/main/java/com/ladingwu/glidelibrary/GlideImageLocader.java
+++ b/glide/src/main/java/com/ladingwu/glidelibrary/GlideImageLocader.java
@@ -6,23 +6,17 @@
import android.os.Looper;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
-import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.RequestBuilder;
import com.bumptech.glide.RequestManager;
-import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.engine.GlideException;
-import com.bumptech.glide.load.engine.cache.LruResourceCache;
-import com.bumptech.glide.load.engine.cache.MemorySizeCalculator;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
-import com.bumptech.glide.module.AppGlideModule;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
@@ -37,7 +31,7 @@
* Created by wuzhao on 2018/1/28.
*/
-public class GlideImageLocader implements IImageLoaderstrategy {
+public class GlideImageLocader implements IImageLoaderstrategy {
private Handler mainHandler = new Handler();
@SuppressLint("CheckResult")
@@ -64,8 +58,8 @@ public void showImage(@NonNull final ImageLoaderOptions options) {
}
}
- if (options.getOnLoaderProgressCallback() != null && !TextUtils.isEmpty(options.getUrl())) {
- DownLoadManager.addListener(options.getUrl(),options.getOnLoaderProgressCallback());
+ if (options.getOnLoaderProgressCallback() != null && null != options.getSource() && options.getSource() instanceof String) {
+ DownLoadManager.addListener((String) options.getSource(), options.getOnLoaderProgressCallback());
}
if (options.isSkipMemoryCache()) {
requestOptions.skipMemoryCache(true);
@@ -77,21 +71,16 @@ public void showImage(@NonNull final ImageLoaderOptions options) {
List list = new ArrayList();
if (options.isBlurImage()) {
list.add(new BlurTransformation(options.getBlurValue()));
-// requestOptions.transforms(new BlurTransformation(options.getBlurValue()));
}
if (options.needImageRadius()) {
list.add(new RoundedCorners(options.getImageRadius()));
-// requestOptions.transforms(new RoundedCorners(options.getImageRadius()));
}
if (options.isCircle()) {
list.add(new CircleTransformation());
-
-// requestOptions.transforms(new CircleTransformation());
}
if (list.size() > 0) {
Transformation[] transformations = list.toArray(new Transformation[list.size()]);
requestOptions.transforms(transformations);
-
}
@@ -130,12 +119,7 @@ private RequestBuilder getRequestBuilder(ImageLoaderOptions options) {
} else {
builder = getRequestManager(options.getViewContainer()).asBitmap();
}
-
- if (!TextUtils.isEmpty(options.getUrl())) {
- builder.load(options.getUrl());
- } else {
- builder.load(options.getResource());
- }
+ builder.load(options.getSource());
return builder;
}
@@ -167,7 +151,7 @@ public void resume(Context context) {
}
@Override
- public void init(Context context ,ImageLoaderConfig config) {
+ public void init(Context context, ImageLoaderConfig config) {
// 暂时不做配置
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 6e8dc74..06d28de 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Jan 28 14:12:51 CST 2018
+#Thu Mar 28 12:57:14 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
diff --git a/imageloader-framework/src/main/java/com/lasingwu/baselibrary/ImageLoaderOptions.java b/imageloader-framework/src/main/java/com/lasingwu/baselibrary/ImageLoaderOptions.java
index dcbd744..600fc54 100644
--- a/imageloader-framework/src/main/java/com/lasingwu/baselibrary/ImageLoaderOptions.java
+++ b/imageloader-framework/src/main/java/com/lasingwu/baselibrary/ImageLoaderOptions.java
@@ -13,38 +13,37 @@
*/
public class ImageLoaderOptions {
private View viewContainer; // 图片容器
- private String url; // 图片地址
- private int resource; // 图片地址
+ private Object source; // 图片地址
private int holderDrawable; // 设置展位图
private ImageSize imageSize; //设置图片的大小
private int errorDrawable; //是否展示加载错误的图片
- private boolean asGif=false; //是否作为gif展示
- private boolean isCrossFade=true; //是否渐变平滑的显示图片,默认为true
- private boolean isSkipMemoryCache = false; //是否跳过内存缓存
- private DiskCacheStrategy mDiskCacheStrategy = DiskCacheStrategy.DEFAULT; //磁盘缓存策略
- private boolean blurImage = false; //是否使用高斯模糊
+ private boolean asGif = false; //是否作为gif展示
+ private boolean isCrossFade = true; //是否渐变平滑的显示图片,默认为true
+ private boolean isSkipMemoryCache = false; //是否跳过内存缓存
+ private DiskCacheStrategy mDiskCacheStrategy = DiskCacheStrategy.DEFAULT; //磁盘缓存策略
+ private boolean blurImage = false; //是否使用高斯模糊
private LoaderResultCallBack loaderResultCallBack; // 返回图片加载结果
private int blurValue; // 高斯模糊参数,越大越模糊
- private int imageRadius= 0;
- private boolean isCircle=false;
+ private int imageRadius = 0;
+ private boolean isCircle = false;
private OnLoaderProgressCallback onLoaderProgressCallback;
- private ImageLoaderOptions (Builder builder ){
- this.asGif=builder.asGif;
- this.errorDrawable=builder.errorDrawable;
- this.holderDrawable=builder.holderDrawable;
- this.imageSize=builder.mImageSize;
- this.isCrossFade=builder.isCrossFade;
- this.isSkipMemoryCache=builder.isSkipMemoryCache;
- this.mDiskCacheStrategy=builder.mDiskCacheStrategy;
- this.url=builder.url;
- this.resource=builder.resource;
- this.viewContainer=builder.mViewContainer;
- this.blurImage=builder.blurImage;
- this.loaderResultCallBack=builder.loaderResultCallBack;
- this.isCircle=builder.isCircle;
- this.blurValue=builder.blurValue;
- this.imageRadius=builder.imageRadius;
- this.onLoaderProgressCallback=builder.onLoaderProgressCallback;
+
+ private ImageLoaderOptions(Builder builder) {
+ this.asGif = builder.asGif;
+ this.errorDrawable = builder.errorDrawable;
+ this.holderDrawable = builder.holderDrawable;
+ this.imageSize = builder.mImageSize;
+ this.isCrossFade = builder.isCrossFade;
+ this.isSkipMemoryCache = builder.isSkipMemoryCache;
+ this.mDiskCacheStrategy = builder.mDiskCacheStrategy;
+ this.source = builder.source;
+ this.viewContainer = builder.mViewContainer;
+ this.blurImage = builder.blurImage;
+ this.loaderResultCallBack = builder.loaderResultCallBack;
+ this.isCircle = builder.isCircle;
+ this.blurValue = builder.blurValue;
+ this.imageRadius = builder.imageRadius;
+ this.onLoaderProgressCallback = builder.onLoaderProgressCallback;
}
public LoaderResultCallBack getLoaderResultCallBack() {
@@ -52,18 +51,20 @@ public LoaderResultCallBack getLoaderResultCallBack() {
}
-
public int getBlurValue() {
return blurValue;
}
+
public boolean needImageRadius() {
- return imageRadius>0;
+ return imageRadius > 0;
}
+
public int getImageRadius() {
return imageRadius;
}
- public int getResource() {
- return resource;
+
+ public Object getSource() {
+ return source;
}
public boolean isBlurImage() {
@@ -74,10 +75,6 @@ public View getViewContainer() {
return viewContainer;
}
- public String getUrl() {
- return url;
- }
-
public boolean isCircle() {
return isCircle;
}
@@ -101,7 +98,6 @@ public int getErrorDrawable() {
}
-
public boolean isAsGif() {
return asGif;
}
@@ -112,119 +108,123 @@ public boolean isCrossFade() {
}
-
public boolean isSkipMemoryCache() {
return isSkipMemoryCache;
}
-
public DiskCacheStrategy getDiskCacheStrategy() {
return mDiskCacheStrategy;
}
- public static ImageLoaderOptions.Builder createImageOptions(@NonNull View v, @NonNull String url){
+
+ public static ImageLoaderOptions.Builder createImageOptions(@NonNull View v, @NonNull String url) {
return new ImageLoaderOptions.Builder(v, url);
}
- public static ImageLoaderOptions.Builder createImageOptions(@NonNull View v, @NonNull int resource){
+
+ public static ImageLoaderOptions.Builder createImageOptions(@NonNull View v, @NonNull int resource) {
return new ImageLoaderOptions.Builder(v, resource);
}
- public void show(){
+
+ public void show() {
ImageLoaderManager.getInstance().showImage(this);
}
- public final static class Builder{
+ public final static class Builder {
- private int holderDrawable=-1; // 设置展位图
+ private int holderDrawable = -1; // 设置展位图
private View mViewContainer; // 图片容器
- private String url; // 图片地址
- private int resource = -1; // 图片地址
+ private Object source; // 图片地址
private ImageSize mImageSize; //设置图片的大小
- private int errorDrawable=-1; //是否展示加载错误的图片
- private boolean asGif=false; //是否作为gif展示
- private boolean isCrossFade=false; //是否渐变平滑的显示图片
- private boolean isSkipMemoryCache = false; //是否跳过内存缓存
- private boolean blurImage = false; //是否使用高斯模糊
- private DiskCacheStrategy mDiskCacheStrategy = DiskCacheStrategy.DEFAULT; //磁盘缓存策略
+ private int errorDrawable = -1; //是否展示加载错误的图片
+ private boolean asGif = false; //是否作为gif展示
+ private boolean isCrossFade = false; //是否渐变平滑的显示图片
+ private boolean isSkipMemoryCache = false; //是否跳过内存缓存
+ private boolean blurImage = false; //是否使用高斯模糊
+ private DiskCacheStrategy mDiskCacheStrategy = DiskCacheStrategy.DEFAULT; //磁盘缓存策略
private LoaderResultCallBack loaderResultCallBack; // 返回图片加载结果
- private int blurValue=15; // 高斯模糊参数,越大越模糊
- private int imageRadius= 0;
- private boolean isCircle=false;
+ private int blurValue = 15; // 高斯模糊参数,越大越模糊
+ private int imageRadius = 0;
+ private boolean isCircle = false;
private OnLoaderProgressCallback onLoaderProgressCallback;
- public Builder(@NonNull View v, @NonNull String url){
- this.url=url;
- this.mViewContainer=v;
- }
- public Builder(@NonNull View v, @NonNull int resource){
- this.resource=resource;
- this.mViewContainer=v;
+ public Builder(@NonNull View v, @NonNull Object source) {
+ this.source = source;
+ this.mViewContainer = v;
}
- public Builder placeholder(@DrawableRes int holderDrawable){
- this.holderDrawable=holderDrawable;
+ public Builder placeholder(@DrawableRes int holderDrawable) {
+ this.holderDrawable = holderDrawable;
return this;
}
- public Builder isCrossFade(boolean isCrossFade){
- this.isCrossFade=isCrossFade;
+
+ public Builder isCrossFade(boolean isCrossFade) {
+ this.isCrossFade = isCrossFade;
return this;
}
- public Builder blurImage(boolean blurImage){
- this.blurImage=blurImage;
+
+ public Builder blurImage(boolean blurImage) {
+ this.blurImage = blurImage;
return this;
}
- public Builder isCircle(){
- this.isCircle=true;
+ public Builder isCircle() {
+ this.isCircle = true;
return this;
}
- public Builder imageRadiusPx(@Dimension(unit = Dimension.PX) int rdius){
- this.imageRadius= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, rdius, mViewContainer.getContext().getApplicationContext().getResources().getDisplayMetrics());
+ public Builder imageRadiusPx(@Dimension(unit = Dimension.PX) int rdius) {
+ this.imageRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, rdius, mViewContainer.getContext().getApplicationContext().getResources().getDisplayMetrics());
return this;
}
- public Builder imageRadiusDp(@Dimension(unit = Dimension.DP) int rdius){
- this.imageRadius= (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rdius, mViewContainer.getContext().getApplicationContext().getResources().getDisplayMetrics());
+
+ public Builder imageRadiusDp(@Dimension(unit = Dimension.DP) int rdius) {
+ this.imageRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rdius, mViewContainer.getContext().getApplicationContext().getResources().getDisplayMetrics());
return this;
}
- public Builder blurValue(@IntRange(from = 0) int blurvalue){
- this.blurValue=blurvalue;
+ public Builder blurValue(@IntRange(from = 0) int blurvalue) {
+ this.blurValue = blurvalue;
return this;
}
- public Builder isSkipMemoryCache(boolean isSkipMemoryCache){
- this.isSkipMemoryCache=isSkipMemoryCache;
+
+ public Builder isSkipMemoryCache(boolean isSkipMemoryCache) {
+ this.isSkipMemoryCache = isSkipMemoryCache;
return this;
}
- public Builder override(int width,int height){
- this.mImageSize=new ImageSize(width,height);
+
+ public Builder override(int width, int height) {
+ this.mImageSize = new ImageSize(width, height);
return this;
}
- public Builder asGif(boolean asGif){
- this.asGif=asGif;
+
+ public Builder asGif(boolean asGif) {
+ this.asGif = asGif;
return this;
}
- public Builder error(@DrawableRes int errorDrawable){
- this.errorDrawable=errorDrawable;
+
+ public Builder error(@DrawableRes int errorDrawable) {
+ this.errorDrawable = errorDrawable;
return this;
}
- public Builder error(LoaderResultCallBack resultCallBack){
- this.loaderResultCallBack=resultCallBack;
+
+ public Builder error(LoaderResultCallBack resultCallBack) {
+ this.loaderResultCallBack = resultCallBack;
return this;
}
- public Builder diskCacheStrategy(DiskCacheStrategy mDiskCacheStrategy){
- this.mDiskCacheStrategy=mDiskCacheStrategy;
+ public Builder diskCacheStrategy(DiskCacheStrategy mDiskCacheStrategy) {
+ this.mDiskCacheStrategy = mDiskCacheStrategy;
return this;
}
- public ImageLoaderOptions build(){
- return new ImageLoaderOptions(this);
+ public ImageLoaderOptions build() {
+ return new ImageLoaderOptions(this);
}
public Builder setOnLoaderProgressCallback(OnLoaderProgressCallback onLoaderProgressCallback) {
@@ -234,12 +234,13 @@ public Builder setOnLoaderProgressCallback(OnLoaderProgressCallback onLoaderProg
}
//对应重写图片size
- public final static class ImageSize{
- private int width=0;
- private int height=0;
- public ImageSize(int width, int heigh){
- this.width=width;
- this.height=heigh;
+ public final static class ImageSize {
+ private int width = 0;
+ private int height = 0;
+
+ public ImageSize(int width, int heigh) {
+ this.width = width;
+ this.height = heigh;
}
public int getHeight() {
@@ -250,8 +251,9 @@ public int getWidth() {
return width;
}
}
+
//对应磁盘缓存策略
- public enum DiskCacheStrategy{
- All,NONE,SOURCE,RESULT,DEFAULT
+ public enum DiskCacheStrategy {
+ All, NONE, SOURCE, RESULT, DEFAULT
}
}