daimajia / NumberProgressBar

A beautiful, slim Android ProgressBar.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

当进度走到80%,为什么会变成-%79, - %78 .......

roybill opened this issue · comments

myBody = new MyBody(requestBody, new MyBody.ProgressListener() { @Override public void onProgress(long currentBytes, long contentLength) { int current = new Long(currentBytes).intValue(); int total = new Long(contentLength).intValue(); if (seted) { numberProgressBar.setMax(total); //只设置一次最大值 seted = false; } numberProgress.setProgress(current); } }); mShow = builder.show();

int值发生了越界。
把NumberProgressBar类中的这一行mCurrentDrawText = String.format("%d", getProgress() * 100 / getMax());改成
float pressent = (float) getProgress() / getMax() * 100;
mCurrentDrawText=String.valueOf((int)pressent);