Java Code Examples for android.widget.ProgressBar#getProgress()

The following examples show how to use android.widget.ProgressBar#getProgress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColorChooser.java    From LaunchTime with GNU General Public License v3.0 6 votes vote down vote up
private void animateProgress2(final ProgressBar b, int newval) {
    int cval = b.getProgress();

    int i = 0;
    while (cval != newval && i < 255) { //'i' is a safety in case there's a miss
        cval += Math.signum(newval - cval);

        final int prog = cval;
        b.postDelayed(new Runnable() {
            @Override
            public void run() {
                b.setProgress(prog);
            }
        }, i++);
    }
    b.setProgress(newval);
}
 
Example 2
Source File: ExSimpleVpFragment.java    From ExVidPlayer with Apache License 2.0 6 votes vote down vote up
private int extractDeltaScale(int availableSpace, float deltaX, ProgressBar progressBar) {
  int x = (int) deltaX;
  float scale;
  float progress = progressBar.getProgress();
  final int max = progressBar.getMax();

  if (x < 0) {
    scale = (float) (x) / (float) (max - availableSpace);
    progress = progress - (scale * progress);
  } else {
    scale = (float) (x) / (float) availableSpace;
    progress += scale * max;
  }

  return (int) progress;
}
 
Example 3
Source File: ExVpCompleteFragment.java    From ExVidPlayer with Apache License 2.0 6 votes vote down vote up
private int extractDeltaScale(int availableSpace, float deltaX, ProgressBar progressBar) {
  int x = (int) deltaX;
  float scale;
  float progress = progressBar.getProgress();
  final int max = progressBar.getMax();

  if (x < 0) {
    scale = (float) (x) / (float) (max - availableSpace);
    progress = progress - (scale * progress);
  } else {
    scale = (float) (x) / (float) availableSpace;
    progress += scale * max;
  }

  return (int) progress;
}
 
Example 4
Source File: ExVpFragment.java    From ExVidPlayer with Apache License 2.0 6 votes vote down vote up
private int extractDeltaScale(int availableSpace, float deltaX, ProgressBar progressBar) {
  int x = (int) deltaX;
  float scale;
  float progress = progressBar.getProgress();
  final int max = progressBar.getMax();

  if (x < 0) {
    scale = (float) (x) / (float) (max - availableSpace);
    progress = progress - (scale * progress);
  } else {
    scale = (float) (x) / (float) availableSpace;
    progress += scale * max;
  }

  return (int) progress;
}
 
Example 5
Source File: ViewUtil.java    From BaseProject with Apache License 2.0 5 votes vote down vote up
public static void animProgressBar(ProgressBar pb, int fromValue, int toValue) {
    if (pb != null) {
        if (fromValue == -1) {
            fromValue = pb.getProgress();
        }
        int maxProgress = pb.getMax();
        if (toValue == -1 || toValue > maxProgress) {
            toValue = maxProgress;
        }
        animView(pb, "progress", fromValue, toValue)
                .setDuration(2000)
                .start()
        ;
    }
}
 
Example 6
Source File: ColorableProgressBar.java    From android-material-stepper with Apache License 2.0 4 votes vote down vote up
@Override
public Integer get(ProgressBar object) {
    return object.getProgress();
}
 
Example 7
Source File: WidgetAccess.java    From NextInputs-Android with Apache License 2.0 4 votes vote down vote up
public static int getProgressInt(ProgressBar view) {
    return view.getProgress();
}
 
Example 8
Source File: WidgetAccess.java    From NextInputs-Android with Apache License 2.0 4 votes vote down vote up
public int getProgressInt(int viewId) {
    ProgressBar bar = findView(viewId);
    return bar.getProgress();
}
 
Example 9
Source File: BookOnlineActivity.java    From coolreader with MIT License 4 votes vote down vote up
public void handleMessage(Message msg) {
    if (msg.what == 1) {
        String url = (String) msg.obj;
        int length = msg.arg1;
        ProgressBar bar = ProgressBars.get(url);
        if (bar != null) {
            // 设置进度条按读取的length长度更新
            bar.incrementProgressBy(length);
            if (bar.getProgress() == bar.getMax()) {
                notificationManager.cancel(notificationId);
                btnDownload.setText("下载");
                // 下载完成后清除进度条并将map中的数据清空
                LinearLayout layout = (LinearLayout) bar.getParent();
                layout.removeView(bar);
                ProgressBars.remove(url);
                downloaders.get(url).delete(url);
                downloaders.get(url).reset();
                downloaders.remove(url);
                
                new AlertDialog.Builder(BookOnlineActivity.this).setTitle("提示").setMessage("下载完成,是否将《"+bookNames[currentPosition]+"》加入书架?")
                .setPositiveButton("加入", new DialogInterface.OnClickListener()
                {
                    
                    public void onClick(DialogInterface dialog, int which)
                    {
                        if(BookUtil.isExist( DbDataOperation.getBookInfo(resolver), SD_PATH+bookNames[currentPosition]+".txt")==true)
                        {
                            new AlertDialog.Builder(BookOnlineActivity.this).setTitle("提示").setMessage("此书在书架中已存在,无需继续添加!").setPositiveButton("确定", null).show();
                        }
                        else
                        {
                            DbDataOperation.insertToBookInfo(resolver, bookNames[currentPosition], "未知", SD_PATH+bookNames[currentPosition]+".txt", TimeUtil.getCurrentTime(),
                                    TimeUtil.getCurrentTime(), 0, "未分类",BookUtil.getBookSize(SD_PATH+bookNames[currentPosition]+".txt"), "0.0%");
                            MainTabActivity.thMain.setCurrentTabByTag(MainTabActivity.TAB_BOOKSHELF);
                            }
                    }
                }).setNegativeButton("取消", null).show();
            }
        }
    }
}
 
Example 10
Source File: CustomTransitionSample.java    From Transitions-Everywhere with Apache License 2.0 4 votes vote down vote up
@Override
public Integer get(ProgressBar progressBar) {
    return progressBar.getProgress();
}
 
Example 11
Source File: SingleInputFormActivity.java    From material-singleinputform with MIT License 4 votes vote down vote up
@Override
public Integer get(ProgressBar pb){
	return pb.getProgress();
}