Skip to content

Commit

Permalink
V2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sunfusheng committed Jun 30, 2018
1 parent 170bafb commit b985e5c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 115 deletions.
2 changes: 1 addition & 1 deletion GlideImageView/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
}

dependencies {
api 'com.android.support:support-v4:' + rootProject.supportLibraryVersion
api "com.android.support:support-v4:$rootProject.supportLibraryVersion"
api 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
api "com.github.bumptech.glide:okhttp3-integration:4.7.1"
Expand Down
125 changes: 15 additions & 110 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
# GlideImageView [ ![Download](https://api.bintray.com/packages/sfsheng0322/maven/glideimageview/images/download.svg) ](https://bintray.com/sfsheng0322/maven/glideimageview/_latestVersion)
# GlideImageView [ ![Download](https://api.bintray.com/packages/sfsheng0322/maven/GlideImageView/images/download.svg) ](https://bintray.com/sfsheng0322/maven/GlideImageView/_latestVersion)

### 该库是基于[Glide](https://github.com/bumptech/glide) V4.0设计的,实现如下特性:<br/>
1、通过提供的属性可以设置图片的圆角、边框。<br/>
2、可以设置点击触摸图片时的颜色、透明度。<br/>
3、一行代码加载来自网络、res、SDCard中的图片,可加载成圆形。<br/>
4、可以监听加载图片时的进度。<br/>
### 该库是基于[Glide](https://github.com/bumptech/glide) V4.7.1设计的,实现如下特性:<br/>
1、监听加载网络图片的进度<br/>
2、动态加载成有弧度的图片、圆形图片、高斯模糊图片更方便<br/>
3、链式设置触摸图片的透明度和非使能的透明度<br/>
4、增加九宫格控件,具体使用参考[NineImageViewActivity](https://github.com/sfsheng0322/GlideImageView/blob/master/Sample/src/main/java/com/sunfusheng/glideimageview/sample/NineImageViewActivity.java)<br/>

<br/>

### 设置圆角、边框的图片,触摸图片时的效果,显示Gif图的效果

<table>
<tr>
<td><img src="/resources/image4.png"></td>
<td><img src="/resources/gif6.gif"></td>
<td><img src="/resources/gif1.gif"></td>
<td><img src="/resources/gif3.gif"></td>
</tr>
</table>

<br/>

### 监听先加载缩略图再加载高清图片进度的效果图
### 监听加载高清图片进度的效果图

<img src="/resources/gif5.gif">

Expand All @@ -35,102 +22,20 @@

#### Gradle:

compile 'com.sunfusheng:glideimageview:1.2.0'

#### Maven:

<dependency>
<groupId>com.sunfusheng</groupId>
<artifactId>glideimageview</artifactId>
<version>1.2.0</version>
<type>pom</type>
</dependency>

<br/>

#### ShapeImageView 和 GlideImageView 共同的属性

该库提供了一个[ShapeImageView](https://github.com/sfsheng0322/GlideImageView/blob/master/GlideImageView/src/main/java/com/sunfusheng/glideimageview/ShapeImageView.java)类,可以在xml当中,也可以在代码中设置图片的一些属性,
当然这些属性也可以在[GlideImageView](https://github.com/sfsheng0322/GlideImageView/blob/master/GlideImageView/src/main/java/com/sunfusheng/glideimageview/GlideImageView.java)上面设置,具体属性如下

| Attribute 属性 | Description 描述 |
|:--- |:---|
| siv_border_color | 边框颜色 |
| siv_border_width | 边框宽度 |
| siv_pressed_color | 触摸图片时的颜色 |
| siv_pressed_alpha | 触摸图片时的颜色透明度: 0.0f - 1.0f |
| siv_radius | 圆角弧度 |
| siv_shape_type | 三种类型:默认是0:none、1:rectangle、2:circle |

#### 下面是在xml中和代码中设置的效果

| xml中设置 | 代码中设置 |
| :--- | :--- |
| ![](https://raw.githubusercontent.com/sfsheng0322/GlideImageView/master/screenshot/code2.png) | ![](https://raw.githubusercontent.com/sfsheng0322/GlideImageView/master/screenshot/code3.png) |

<br/>

#### 一行代码加载来自网络、res、SDCard中图片

public GlideImageView loadImage(String url, int placeholderResId);
public GlideImageView loadLocalImage(@DrawableRes int resId, int placeholderResId);
public GlideImageView loadLocalImage(String localPath, int placeholderResId);

#### 一行代码加载来自网络、res、SDCard中图片成圆形

public GlideImageView loadCircleImage(String url, int placeholderResId);
public GlideImageView loadLocalCircleImage(int resId, int placeholderResId);
public GlideImageView loadLocalCircleImage(String localPath, int placeholderResId);

#### 如果你觉得上面的方法还不能满足你,那么你可以通过下面的方法追加自己想要的属性来加载图片

RequestOptions requestOptions(int placeholderResId);
RequestOptions circleRequestOptions(int placeholderResId);

GlideImageView load(int resId, RequestOptions options);
GlideImageView load(Uri uri, RequestOptions options);
GlideImageView load(String url, RequestOptions options);
compile 'com.sunfusheng:GlideImageView:<latest-version>'

#### 如果你还是觉得得不到满足,好吧,我提供了[GlideImageLoader](https://github.com/sfsheng0322/GlideImageView/blob/master/GlideImageView/src/main/java/com/sunfusheng/glideimageview/GlideImageLoader.java)类加载图片,比如这样加载图片:先加载缩略图再加载高清图片,并监听加载的进度

private void loadImage(String image_url_thumbnail, String image_url) {
RequestOptions requestOptions = glideImageView.requestOptions(R.color.black)
.centerCrop()
.skipMemoryCache(true) // 跳过内存缓存
.diskCacheStrategy(DiskCacheStrategy.NONE); // 不缓存到SDCard中

glideImageView.getImageLoader().setOnGlideImageViewListener(image_url, new OnGlideImageViewListener() {
@Override
public void onProgress(int percent, boolean isDone, GlideException exception) {
progressView.setProgress(percent);
progressView.setVisibility(isDone ? View.GONE : View.VISIBLE);
}
});

glideImageView.getImageLoader().requestBuilder(image_url, requestOptions)
.thumbnail(Glide.with(ImageActivity.this) // 加载缩略图
.load(image_url_thumbnail)
.apply(requestOptions))
.transition(DrawableTransitionOptions.withCrossFade()) // 动画渐变加载
.into(glideImageView);
}

<br/>

<img src="/resources/gif4.gif">

<br/>
#### GlideImageView 主要方法

load(String url, @DrawableRes int placeholder, int radius, OnProgressListener onProgressListener)

#### 该库提供两种监听加载图片进度的Listener,总有一款是你想要的
load(Object obj, @DrawableRes int placeholder, Transformation<Bitmap> transformation, OnProgressListener onProgressListener)

public interface OnGlideImageViewListener {
void onProgress(int percent, boolean isDone, GlideException exception);
}
loadCircle(String url, @DrawableRes int placeholder, OnProgressListener onProgressListener)

public interface OnProgressListener {
void onProgress(String imageUrl, long bytesRead, long totalBytes, boolean isDone, GlideException exception);
}
loadDrawable(@DrawableRes int resId, @DrawableRes int placeholder)
<br/>

### 个人微信公众号
Expand Down
8 changes: 4 additions & 4 deletions Sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def generateApk(variant) {
}

dependencies {
api 'com.android.support:appcompat-v7:' + rootProject.supportLibraryVersion
api 'com.android.support:percent:' + rootProject.supportLibraryVersion
api 'com.android.support:design:' + rootProject.supportLibraryVersion
api "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
api "com.android.support:percent:$rootProject.supportLibraryVersion"
api "com.android.support:design:$rootProject.supportLibraryVersion"
api 'com.android.support.constraint:constraint-layout:1.1.2'
api 'com.github.chrisbanes:PhotoView:2.1.3'

api 'com.sunfusheng:FirUpdater:1.0.8'
// api 'com.sunfusheng:glideimageview:1.3.0'
// api 'com.sunfusheng:GlideImageView:2.0.0'
api project(':GlideImageView')
}

0 comments on commit b985e5c

Please sign in to comment.