Skip to content

Commit

Permalink
1.2.0版本发布,更新请看README
Browse files Browse the repository at this point in the history
  • Loading branch information
totond committed Sep 11, 2017
1 parent 60fd84b commit 1075ea7
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CustomProgressBar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ publish {
repoName = 'CustomViewRepository' //Repository的名字
groupId = 'com.yanzhikaijky' //包名
artifactId = 'PictureProgressbar' //项目名
publishVersion = '1.1.2' //版本号
publishVersion = '1.2.0' //版本号
desc = 'a picture progressbar' //description说明,随便写
website = 'https://github.com/totond/PictureProgressBar'//VCS地址,这里最好写GitHub的,我试过不写然后上传不了
}

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CustomProgressBar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
<attr name="isGradient" format="boolean"/>
<attr name="gradientStartColor" format="color"/>
<attr name="gradientEndColor" format="color"/>
<attr name="backgroundDrawable" format="reference"/>
<attr name="barDrawable" format="reference"/>



Expand Down
19 changes: 17 additions & 2 deletions README-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PictureProgressBar allows you to set picture and animation in the position of cu

### Gradle
```
compile 'com.yanzhikaijky:PictureProgressbar:1.1.2'
compile 'com.yanzhikaijky:PictureProgressbar:1.2.0'
```

### Attributes
Expand Down Expand Up @@ -41,7 +41,12 @@ PictureProgressBar allows you to set picture and animation in the position of cu
|scaleRate | The scale of each interval time | float | 0.1|
|gradientStartColor | The gradient start color |color | #ff0000 |
|gradientEndColor | The gradient end color |color | #ffff00|
|**backgroundDrawable** | The background drawable |reference | |
|**barDrawable** | The bar drawable |reference | |

> PS: To set `backgroundDrawable` and `barDrawable` can provide a drawable background like Google's Progress:
> ![](https://i.imgur.com/laHcRXm.png)
> ![](https://i.imgur.com/GFgRZCz.gif)

**Introduction of animMode:**
Expand Down Expand Up @@ -80,6 +85,14 @@ Except the setter and getter of above-mentioned attributes, there are some metho
//进度完成时的回答
public void onOnProgressFinish();
}
//added by v1.2.0:
//设置进度条背景图片
public void setBarDrawableId(int id)
//设置进度条图片
public void setBarBackgroundDrawableId(int id)
```
## LICENSE

Expand All @@ -100,10 +113,12 @@ limitations under the License.
```

## Update
- **version 1.1.1** : 2017/07/07 Fix a bug:
- **version 1.1.1** : 2017/07/07 Fixed a bug:
Added Attribute `progressPercentage` to show the percentage of progress.
Changed the `setProgress()` to prevent the int type overflow:

- **version 1.2.0 **:2017/09/11:
- Added Attribute, `backgroundDrawable` and `barDrawable`.The new effect is similar to a drawable background in Google's Progress.
## About
> id:Yanzhikai
Expand Down
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### Gradle

```
compile 'com.yanzhikaijky:PictureProgressbar:1.1.2'
compile 'com.yanzhikaijky:PictureProgressbar:1.2.0'
```


Expand Down Expand Up @@ -42,8 +42,12 @@
|scaleRate | 缩放倍数/每次刷新 | float | 0.1|
|gradientStartColor | 进度条渐变色开始颜色 |color | #ff0000 |
|gradientEndColor | 进度条渐变色结束颜色 |color | #ffff00|
|**backgroundDrawable** | 进度条背景图片 |reference | |
|**barDrawable** | 进度条图片 |reference | |

> 注意:上面的drawable属性可以是图片,也可以是Shape(demo里面的正方形就是自动画的Shape),其他的类型应该不行了。
> 注意:backgroundDrawable和barDrawable(版本1.2.0新增),的引用只能是图片,不然会报错(对其他类型的支持后续开发中)。用法类似于官方ProgressBar的图片背景,设置一个图片之后会自动进行宽高调整后平铺:![](https://i.imgur.com/laHcRXm.png)
> 最后得到这样的结果:
> ![](https://i.imgur.com/GFgRZCz.gif)
**对应的animMode模式有:**

Expand Down Expand Up @@ -81,11 +85,19 @@
//进度完成时的回答
public void onOnProgressFinish();
}
//以下为v1.2.0新增:
//设置进度条背景图片
public void setBarDrawableId(int id)
//设置进度条图片
public void setBarBackgroundDrawableId(int id)
```
## 开源协议
  PictureProgressBar遵循Apache 2.0开源协议。

## 更新
## 版本更新
- **version 1.1.1 **:2017/07/07修复bug:
  加入了progressPercentage属性来表示进度条进度比例,修改了`setProgress()`内容,在里面加入

Expand All @@ -96,6 +108,10 @@ progressPercentage = progress/max;
- **version 1.1.2 **:2017/09/07修复bug:
  progress/max得到0的结果,醉了过了两个月才发现。。。

- **version 1.2.0 **:2017/09/11更新:
- 1.修复非圆角进度条宽度设置失效问题。
- 2.新增进度条的图片设置,类似官方ProgressBar的图片平铺设置功能。

## 关于作者
> id:炎之铠
Expand Down
25 changes: 15 additions & 10 deletions app/src/main/java/com/scut/pictureprogressbar/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,52 @@

public class MainActivity extends AppCompatActivity {
Button btn_start;
PictureProgressBar pb_1,pb_2,pb_3,pb_4,pb_5;
PictureProgressBar pb_1, pb_2, pb_3, pb_4, pb_5;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn_start = (Button) findViewById(R.id.btn_start);
pb_1 = (PictureProgressBar) findViewById(R.id.pb_1);
pb_1.setDrawableIds(new int[]{R.drawable.i00,R.drawable.i01,R.drawable.i02,R.drawable.i03,R.drawable.i04,R.drawable.i05,R.drawable.i06});
pb_1.setDrawableIds(new int[]{R.drawable.i00, R.drawable.i01, R.drawable.i02, R.drawable.i03, R.drawable.i04, R.drawable.i05, R.drawable.i06});
pb_2 = (PictureProgressBar) findViewById(R.id.pb_2);
pb_3 = (PictureProgressBar) findViewById(R.id.pb_3);
pb_4 = (PictureProgressBar) findViewById(R.id.pb_4);
pb_5 = (PictureProgressBar) findViewById(R.id.pb_5);
// try {
// pb_1.setBarBackgroundDrawableId(R.drawable.background_1);
// pb_1.setBarDrawableId(R.drawable.bar_1);
// } catch (Exception e) {
// e.printStackTrace();
// }

//使用属性动画来实现进度的变化
final ValueAnimator valueAnimator = ValueAnimator.ofInt(0,1000);
final ValueAnimator valueAnimator = ValueAnimator.ofInt(0, 1000);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Log.d("sdsa", "onAnimationUpdate: "+Integer.parseInt(animation.getAnimatedValue().toString()));
Log.d("sdsa", "onAnimationUpdate: " + Integer.parseInt(animation.getAnimatedValue().toString()));
pb_1.setProgress(Integer.parseInt(animation.getAnimatedValue().toString()));
if (pb_1.getProgress() >= pb_1.getMax()){
if (pb_1.getProgress() >= pb_1.getMax()) {
//进度满了之后停止动画
pb_1.setAnimRun(false);
}
pb_2.setProgress(Integer.parseInt(animation.getAnimatedValue().toString()));
if (pb_2.getProgress() >= pb_2.getMax()){
if (pb_2.getProgress() >= pb_2.getMax()) {
//进度满了之后改变图片
pb_2.setPicture(R.drawable.b666);
}
pb_3.setProgress(Integer.parseInt(animation.getAnimatedValue().toString()));
if (pb_3.getProgress() >= pb_3.getMax()){
if (pb_3.getProgress() >= pb_3.getMax()) {
pb_3.setAnimRun(false);
}
pb_4.setProgress(Integer.parseInt(animation.getAnimatedValue().toString()));
if (pb_4.getProgress() >= pb_4.getMax()){
if (pb_4.getProgress() >= pb_4.getMax()) {
pb_4.setAnimRun(false);
}
pb_5.setProgress(Integer.parseInt(animation.getAnimatedValue().toString()));
if (pb_5.getProgress() >= pb_5.getMax()){
if (pb_5.getProgress() >= pb_5.getMax()) {
pb_5.setAnimRun(false);
}
}
Expand All @@ -65,7 +71,6 @@ public void onClick(View v) {
pb_4.setAnimRun(true);
pb_5.setAnimRun(true);
valueAnimator.start();

}
});
}
Expand Down
Binary file added app/src/main/res/drawable/background_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/background_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/bar_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/bar_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 7 additions & 8 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,19 @@
<com.yanzhikai.pictureprogressbar.PictureProgressBar
android:layout_width="match_parent"
android:layout_height="60dp"
app:drawable="@drawable/test_shape"
app:max="1000"
app:isSetBar="true"
app:progressHeight="10dp"
app:progressHeight="45dp"
app:animMode="ANIM_FRAME"
app:rotateRate="30"
app:drawableHeightOffset="0dp"
app:progressHeightOffset="15dp"
app:progressHeightOffset="0dp"
app:scaleMax="1.8"
app:scaleMin="0.5"
app:scaleRate="0.1"
app:refreshTime="100"
app:isGradient="true"
app:gradientStartColor="#ff0000"
app:gradientEndColor="#ffff00"
app:backgroundDrawable="@drawable/background_1"
app:barDrawable="@drawable/bar_1"
android:id="@+id/pb_1"
/>

Expand All @@ -55,8 +53,8 @@
android:layout_height="40dp"
app:drawable="@drawable/b333"
app:max="1000"
app:roundY="20dp"
app:roundX="20dp"
app:roundY="15dp"
app:roundX="15dp"
app:halfDrawableHeight="20dp"
app:halfDrawableWidth="20dp"
app:animMode="ANIM_NULL"
Expand All @@ -83,6 +81,7 @@
app:halfDrawableHeight="15dp"
app:halfDrawableWidth="15dp"
app:animMode="ANIM_ROTATE"
app:isRound="false"
app:rotateRate="15"
app:isGradient="true"
app:gradientStartColor="#ff00ff"
Expand Down

0 comments on commit 1075ea7

Please sign in to comment.