Skip to content

Commit 38a63a7

Browse files
committed
1:修改README文档;
1 parent 37ea9cc commit 38a63a7

File tree

3 files changed

+136
-2
lines changed

3 files changed

+136
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<td><img src="/screenshots/Screenshot_1.png"></td>
66
<td><img src="/screenshots/Screenshot_2.png"></td>
77
<td><img src="/screenshots/Screenshot_3.png"></td>
8+
<td><img src="/screenshots/Screenshot_4.png"></td>
89
</tr>
910
</table>
1011

@@ -14,8 +15,7 @@ Android项目组件化示例代码
1415

1516
**Android组件化方案**http://blog.csdn.net/guiying712/article/details/55213884
1617

17-
Android组件化方案中的路由使用了ActivityRouter,但是因为ActivityRouter对于初学者不太友好,
18-
总是出现莫名其妙的错误,因此现在的 AndroidModulePattern 已经改为使用 阿里ARouter作为路由。
18+
现在的 AndroidModulePattern 使用 阿里ARouter作为路由,并且已经支持**Fragment组件化**,使用方法请下载Demo查看。
1919

2020
## 集成开发模式和组件开发模式转换
2121

@@ -31,6 +31,7 @@ Android组件化方案中的路由使用了ActivityRouter,但是因为Activity
3131
1. 配置整个项目的Gradle脚本,例如 混淆、签名等;
3232
2. app组件中可以初始化全局的库,例如Lib.init(this);
3333
3. 添加 multiDex 功能
34+
4. 业务组件管理(组装);
3435

3536
### main组件功能(业务组件):
3637
1. 声明应用的launcherActivity----->android.intent.category.LAUNCHER;
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
package com.guiying.module.common.glide;
2+
3+
import android.content.Context;
4+
import android.graphics.Bitmap;
5+
import android.graphics.drawable.Drawable;
6+
import android.view.View;
7+
import android.widget.ImageView;
8+
9+
import com.bumptech.glide.Glide;
10+
import com.bumptech.glide.load.engine.DiskCacheStrategy;
11+
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
12+
import com.bumptech.glide.request.animation.GlideAnimation;
13+
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
14+
import com.bumptech.glide.request.target.SimpleTarget;
15+
import com.guiying.module.common.utils.Utils;
16+
17+
/**
18+
* <p> 图片加载工具类</p>
19+
*
20+
* @name ImageUtils
21+
*/
22+
public class ImageUtils {
23+
24+
/**
25+
* 默认加载
26+
*/
27+
public static void loadImageView(String path, ImageView mImageView) {
28+
Glide.with(mImageView.getContext()).load(path).into(mImageView);
29+
}
30+
31+
public static void loadImageWithError(String path, int errorRes, ImageView mImageView) {
32+
Glide.with(mImageView.getContext())
33+
.load(path)
34+
.crossFade()
35+
.diskCacheStrategy(DiskCacheStrategy.SOURCE)
36+
.error(errorRes)
37+
.into(mImageView);
38+
}
39+
40+
/**
41+
* 设置加载中以及加载失败图片
42+
*/
43+
public static void loadImageWithLoading(String path, ImageView mImageView, int lodingImage, int errorRes) {
44+
Glide.with(mImageView.getContext()).load(path).placeholder(lodingImage).
45+
error(errorRes).into(mImageView);
46+
}
47+
48+
/**
49+
* 设置加载动画
50+
* api也提供了几个常用的动画:比如crossFade()
51+
*/
52+
public static void loadImageViewAnim(String path, int anim, ImageView mImageView) {
53+
Glide.with(mImageView.getContext()).load(path).animate(anim).into(mImageView);
54+
}
55+
56+
57+
/**
58+
* 加载为bitmap
59+
*
60+
* @param path 图片地址
61+
* @param listener 回调
62+
*/
63+
public static void loadBitMap(String path, final onLoadBitmap listener) {
64+
Glide.with(Utils.getContext()).load(path).asBitmap().into(new SimpleTarget<Bitmap>() {
65+
66+
@Override
67+
public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
68+
listener.onReady(bitmap);
69+
}
70+
71+
@Override
72+
public void onLoadFailed(Exception e, Drawable errorDrawable) {
73+
listener.onFailed();
74+
}
75+
});
76+
}
77+
78+
/**
79+
* 显示加载进度
80+
*
81+
* @param path 图片地址
82+
* @param mImageView 图片控件
83+
* @param loadView 加载view
84+
*/
85+
public static void loadImageWithProgress(String path, final ImageView mImageView, final View loadView, int errorRes) {
86+
Glide.with(mImageView.getContext()).load(path).error(errorRes).into(new GlideDrawableImageViewTarget(mImageView) {
87+
@Override
88+
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
89+
super.onResourceReady(resource, animation);
90+
loadView.setVisibility(View.GONE);
91+
}
92+
93+
@Override
94+
public void onLoadFailed(Exception e, Drawable errorDrawable) {
95+
super.onLoadFailed(e, errorDrawable);
96+
loadView.setVisibility(View.GONE);
97+
}
98+
});
99+
}
100+
101+
/**
102+
* 清除view上的图片
103+
*
104+
* @param view 视图
105+
*/
106+
public static void clearImageView(View view) {
107+
Glide.clear(view);
108+
}
109+
110+
/**
111+
* 清理磁盘缓存需要在子线程中执行
112+
*/
113+
public static void GuideClearDiskCache(Context mContext) {
114+
Glide.get(mContext).clearDiskCache();
115+
}
116+
117+
/**
118+
* 清理内存缓存可以在UI主线程中进行
119+
*/
120+
public static void GuideClearMemory(Context mContext) {
121+
Glide.get(mContext).clearMemory();
122+
}
123+
124+
/**
125+
* 加载bitmap回调
126+
*/
127+
public interface onLoadBitmap {
128+
void onReady(Bitmap resource);
129+
130+
void onFailed();
131+
}
132+
133+
}

screenshots/Screenshot_4.png

11.4 KB
Loading

0 commit comments

Comments
 (0)