Skip to content

Commit

Permalink
progress format support
Browse files Browse the repository at this point in the history
  • Loading branch information
huangshuisheng committed Jun 9, 2017
1 parent 5115151 commit 789fb1b
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .idea/libraries/appcompat_v7_24_2_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/rules_0_5.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/runner_0_5.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/support_compat_24_2_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/support_core_ui_24_2_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/support_fragment_24_2_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/libraries/support_media_compat_24_2_1.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ NotifyUtil.buildBigText(103,R.drawable.timg,"jtitle","我学习最快的方法
"本篇文章和以前的风格有所不同,以前都是文章中代码比较少,附上demo,但发现这样可能不方便读者," +
"所以采用了实现效果以及主要代码的形式。这种方式现在还在测试阶段,如果觉得以前的模式比较" +
"好或者其他更好的方式的话可以給我留言,以后的文章会做出相应的调整 。").show();
```
```


认定该
2 changes: 2 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>


</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public void run() {
return;
}
progresses = progresses +10;
NotifyUtil.buildProgress(102,R.mipmap.ic_launcher,"正在下载",progresses,100).show();

NotifyUtil.buildProgress(102,R.mipmap.ic_launcher,"正在下载",progresses,100,"下载进度:%dkb/%dkb").show();//"下载进度:%d%%"
showProgress();

}
Expand Down
14 changes: 11 additions & 3 deletions notifyutil2/src/main/java/com/hss01248/notifyutil/NotifyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,23 @@ public static SingleLineBuilder buildSimple(int id,int smallIcon,CharSequence co
return builder;
}

@Deprecated
public static ProgressBuilder buildProgress(int id,int smallIcon,CharSequence contentTitle,int progress,int max){
ProgressBuilder builder = new ProgressBuilder();
builder.setBase(smallIcon,contentTitle,progress+"/"+max)
.setId(id);
builder.setProgress(max,progress,false);
return builder;
}

public static ProgressBuilder buildProgress(int id,int smallIcon,CharSequence contentTitle,int progress,int max,String format){
ProgressBuilder builder = new ProgressBuilder();
builder.setBase(smallIcon,contentTitle,progress+"/"+max)
.setId(id);
builder.setProgressAndFormat(progress,max,false,format);
return builder;
}

public static BigPicBuilder buildBigPic(int id,int smallIcon,CharSequence contentTitle,CharSequence contentText,CharSequence summaryText){
BigPicBuilder builder = new BigPicBuilder();
builder.setBase(smallIcon,contentTitle,contentText).setId(id);
Expand All @@ -71,9 +81,7 @@ public static MediaBuilder buildMedia(int id,int smallIcon,CharSequence contentT
}
/*public static CustomViewBuilder buildCustomView(BigPicBuilder builder){
}
*/
}*/

public static void notify(int id,Notification notification){

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.hss01248.notifyutil.builder;

import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;

/**
* Created by Administrator on 2017/2/13 0013.
Expand All @@ -11,10 +12,32 @@ public class ProgressBuilder extends BaseBuilder{
public int progress;
public boolean interminate = false;

@Deprecated
public ProgressBuilder setProgress(int max,int progress,boolean interminate){
setProgressAndFormat(progress,max,interminate,"%d/%d");
return this;
}

public ProgressBuilder setProgressAndFormat(int progress,int max,boolean interminate,String format){
this.max = max;
this.progress = progress;
this.interminate = interminate;

//contenttext的显示
if(TextUtils.isEmpty(format) ){
format = "进度:%d/%d";
setContentText(String.format(format,progress,max));
}else {
if(format.contains("%%")){//百分比类型
int progressf = progress*100/max;
setContentText(String.format(format,progressf));
}else {

setContentText(String.format(format,progress,max));
}

}

return this;
}

Expand Down

0 comments on commit 789fb1b

Please sign in to comment.