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

The following examples show how to use android.widget.ProgressBar#setProgress() . 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: WordsFragment.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
                         final Bundle savedInstanceState) {
    final View view = inflater.inflate(R.layout.fragment_onboarding_words, container, false);

    // Get arguments: words and offset
    final Bundle b = this.getArguments();
    if (b == null)
        return view;
    final List<String> words = b.getStringArrayList("words");
    final int offset = b.getInt("offset");
    final int index = offset / 6;

    final ProgressBar progressBar = UI.find(view, R.id.progressBar);
    progressBar.setProgress(25+index*25);

    // Setup words recyclerview
    final WordsViewAdapter wordsViewAdapter = new WordsViewAdapter(getContext(), words, offset);
    final RecyclerView wordsRecyclerView = UI.find(view, R.id.wordsRecyclerView);
    wordsRecyclerView.setHasFixedSize(true);
    wordsRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    wordsRecyclerView.setAdapter(wordsViewAdapter);
    return view;
}
 
Example 2
Source File: ManageDownloadsActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 6 votes vote down vote up
public void updateBar(ProgressBar bar) {
	String youtubeId = (String) bar.getTag();
	Integer progress = currentDownloadStatus.get(youtubeId);
	if (progress == null) {
		bar.setVisibility(View.GONE);
	} else {
		switch (progress) {
		case 100:
			bar.setVisibility(View.GONE);
			break;
		case 0:
			bar.setIndeterminate(true);
			bar.setVisibility(View.VISIBLE);
			break;
		default:
			bar.setIndeterminate(false);
			bar.setProgress(progress);
			bar.setVisibility(View.VISIBLE);
		}
	}
}
 
Example 3
Source File: MainActivity.java    From PaintView with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mProgressBar = (ProgressBar) findViewById(R.id.webview_content_progress);

    mWebView = (CustomWebView)findViewById(R.id.webview);
    WebChromeClient WebChromeClient = new WebChromeClient() {

        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            super.onProgressChanged(view, newProgress);

            if (newProgress == 100) {
                mProgressBar.setVisibility(View.INVISIBLE);
            } else {
                mProgressBar.setVisibility(View.VISIBLE);
                mProgressBar.setProgress(newProgress);
            }
        }
    };
    mWebView.setWebChromeClient(WebChromeClient);
    mWebView.loadUrl("http://www.google.com");
}
 
Example 4
Source File: Card.java    From android-play-places with Apache License 2.0 5 votes vote down vote up
/**
 * Set the progress. Only useful for the type {@link #PROGRESS_TYPE_NORMAL}.
 * @param progress
 * @see android.widget.ProgressBar#setProgress(int)
 */
public void setProgress(int progress) {
    currProgress = progress;
    final ProgressBar bar = getProgressBar();
    if (bar != null) {
        bar.setProgress(currProgress);
        bar.invalidate();
    }
}
 
Example 5
Source File: ChannelSetupStepSupportFragment.java    From xipl with Apache License 2.0 5 votes vote down vote up
@Override
public void onScanStepCompleted(int completedStep, int totalSteps) {
    ProgressBar progressBar = mChannelSetupStylist.getProgressBar();
    if (totalSteps > 0 && progressBar != null) {
        progressBar.setIndeterminate(false);
        progressBar.setMax(totalSteps);
        progressBar.setProgress(completedStep);
    }
}
 
Example 6
Source File: UploadResultReceiver.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
protected void onReceiveResult(int resultCode, Bundle resultData) {
    if (resultCode == RESULT_CODE) {
        ProgressBar progressBar = getProgressBar();
        if (progressBar != null) {
            int percentage = resultData.getInt(PROGRESS_KEY);
            if (percentage != 0)
                progressBar.setProgress(percentage);
        }

        TextView progressView = getProgressView();
        if (progressView != null) {
            String msg = resultData.getString(PROGRESS_MESSAGE_KEY);
            if (msg != null)
                progressView.setText(msg);
        }

        ProgressBarUploadDialogFragment.IProgressChangeListener progressChangeListener = getProgressChangeListener();
        if (progressChangeListener != null) {
            String errorMsg = resultData.getString(PROGRESS_ERRORED_KEY);
            if (errorMsg != null) {
                progressChangeListener.onProgressError(errorMsg);
            } else {
                String doneString = resultData.getString(PROGRESS_ENDED_KEY);
                if (doneString != null) {
                    progressChangeListener.onProgressDone(doneString);
                }
            }
        }
    }
}
 
Example 7
Source File: MainActivity.java    From SettingsDeployer with MIT License 5 votes vote down vote up
/**
 * Called on the UI thread when everything finishes
 * @param bSuccess True if deployment succeeded
 */
public void DeploymentFinished(boolean bSuccess)
{
    // set result label based on if we succeeded
    TextView resultTextView = (TextView)findViewById(R.id.result_text);
    if (bSuccess)
    {
        resultTextView.setText(R.string.deploy_success);
        resultTextView.setTextColor(Color.parseColor("#ff77ff79"));
    }
    else
    {
        resultTextView.setText(R.string.deploy_fail);
        resultTextView.setTextColor(Color.RED);
    }

    // clear status of progress bar
    ProgressBar progress = (ProgressBar)findViewById(R.id.work_prog);
    progress.setProgress(0);
    progress.setVisibility(View.INVISIBLE);
    m_progressType = 0;
    TextView workTypeTV = (TextView)findViewById(R.id.work_type);
    workTypeTV.setText("");

    // cleanup log, etc.
    m_kodiEnv.Cleanup(bSuccess);
}
 
Example 8
Source File: CourseReviewsFragment.java    From flow-android with MIT License 5 votes vote down vote up
private void reloadRatingOverview() {
    TextView overallRating = (TextView)mRatingOverviewLayout.findViewById(R.id.overall_rating);
    TextView overallCount = (TextView)mRatingOverviewLayout.findViewById(R.id.overall_count);
    ProgressBar usefulRating = (ProgressBar)mRatingOverviewLayout.findViewById(R.id.useful_bar);
    TextView usefulCount = (TextView)mRatingOverviewLayout.findViewById(R.id.useful_count);
    ProgressBar easyRating = (ProgressBar)mRatingOverviewLayout.findViewById(R.id.easy_bar);
    TextView easyCount = (TextView)mRatingOverviewLayout.findViewById(R.id.easy_count);

    overallRating.setText(String.format("%d%%", (int)(mCourseDetail.getOverall().getRating() * 100)));
    overallCount.setText(String.format("%d ratings", (int) mCourseDetail.getOverall().getCount()));
    usefulRating.setProgress((int) (Double.valueOf(mCourseDetail.getRatings().get(Rating.USEFULNESS).getRating()) * 100));
    usefulCount.setText(String.format("%d ratings", mCourseDetail.getRatings().get(Rating.USEFULNESS).getCount()));
    easyRating.setProgress((int) (Double.valueOf(mCourseDetail.getRatings().get(Rating.EASINESS).getRating()) * 100));
    easyCount.setText(String.format("%d ratings", mCourseDetail.getRatings().get(Rating.EASINESS).getCount()));
}
 
Example 9
Source File: StreamUtils.java    From Mupdf with Apache License 2.0 5 votes vote down vote up
public static byte[] readBytesFully(InputStream i, int max, ProgressBar progressBar) throws IOException {
    byte buf[] = new byte[4096];
    int totalReadBytes = 0;
    while (true) {
        int readBytes = 0;
        readBytes = i.read(buf, totalReadBytes, buf.length - totalReadBytes);
        if (readBytes < 0) {
            // end of stream
            break;
        }
        totalReadBytes += readBytes;
        if (progressBar != null) progressBar.setProgress(totalReadBytes);
        if (max > 0 && totalReadBytes > max) {
            throw new IOException("Remote file is too big");
        }
        if (totalReadBytes == buf.length) {
            // grow buf
            Log.d("cx.hell.android.pdfviewpro", "readBytesFully: growing buffer from " + buf.length + " to " + (buf.length * 2));
            byte newbuf[] = new byte[buf.length * 2];
            System.arraycopy(buf, 0, newbuf, 0, totalReadBytes);
            buf = newbuf;
        }
    }
    byte result[] = new byte[totalReadBytes];
    System.arraycopy(buf, 0, result, 0, totalReadBytes);
    return result;
}
 
Example 10
Source File: Card.java    From android-BatchStepSensor with Apache License 2.0 5 votes vote down vote up
/**
 * Set the progress. Only useful for the type {@link #PROGRESS_TYPE_NORMAL}.
 * @param progress
 * @see android.widget.ProgressBar#setProgress(int)
 */
public void setProgress(int progress) {
    currProgress = progress;
    final ProgressBar bar = getProgressBar();
    if (bar != null) {
        bar.setProgress(currProgress);
        bar.invalidate();
    }
}
 
Example 11
Source File: RecyclerViewHolder.java    From StickyItemDecoration with Apache License 2.0 4 votes vote down vote up
public RecyclerViewHolder setProgress(int viewId, int progress, int max) {
    ProgressBar view = findViewById(viewId);
    view.setMax(max);
    view.setProgress(progress);
    return this;
}
 
Example 12
Source File: ViewHolder.java    From Bailan with Apache License 2.0 4 votes vote down vote up
public ViewHolder setProgress(int viewId, int progress, int max) {
    ProgressBar view = getView(viewId);
    view.setMax(max);
    view.setProgress(progress);
    return this;
}
 
Example 13
Source File: BaseViewHolder.java    From Android-RecyclerViewHelper with Apache License 2.0 4 votes vote down vote up
public BaseViewHolder setProgress(int viewId, int progress, int max) {
    ProgressBar view = getView(viewId);
    view.setMax(max);
    view.setProgress(progress);
    return this;
}
 
Example 14
Source File: ViewHolderHelper.java    From youqu_master with Apache License 2.0 4 votes vote down vote up
public ViewHolderHelper setProgress(int viewId, int progress, int max) {
    ProgressBar view = getView(viewId);
    view.setMax(max);
    view.setProgress(progress);
    return this;
}
 
Example 15
Source File: ViewHolder.java    From Bailan with Apache License 2.0 4 votes vote down vote up
public ViewHolder setProgress(int viewId, int progress) {
    ProgressBar view = getView(viewId);
    view.setProgress(progress);
    return this;
}
 
Example 16
Source File: ViewHolder.java    From SmartChart with Apache License 2.0 4 votes vote down vote up
public ViewHolder setProgress(int viewId, int progress, int max) {
    ProgressBar view = getView(viewId);
    view.setMax(max);
    view.setProgress(progress);
    return this;
}
 
Example 17
Source File: MainActivity.java    From sdscanner with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void updateProgressNum(int progressNum) {
    ProgressBar progressBar = (ProgressBar)findViewById(R.id.progress_bar);
    progressBar.setProgress(progressNum);
}
 
Example 18
Source File: ViewHolder.java    From MVVM-JueJin with MIT License 4 votes vote down vote up
public ViewHolder setProgress(int viewId, int progress, int max) {
    ProgressBar view = getView(viewId);
    view.setMax(max);
    view.setProgress(progress);
    return this;
}
 
Example 19
Source File: BaseViewHolder.java    From GoogleVR with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the progress of a ProgressBar.
 *
 * @param viewId   The view id.
 * @param progress The progress.
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setProgress(int viewId, int progress) {
    ProgressBar view = getView(viewId);
    view.setProgress(progress);
    return this;
}
 
Example 20
Source File: BaseViewHolder.java    From demo4Fish with MIT License 2 votes vote down vote up
/**
 * Sets the progress of a ProgressBar.
 *
 * @param viewId   The view id.
 * @param progress The progress.
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setProgress(int viewId, int progress) {
    ProgressBar view = getView(viewId);
    view.setProgress(progress);
    return this;
}