Back to project page android-process-button.
The source code is released under:
MIT License
If you think the Android project android-process-button listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dd.sample.utils; //w ww. j a va2 s . co m import com.dd.processbutton.ProcessButton; import android.os.Handler; import java.util.Random; public class ProgressGenerator { public interface OnCompleteListener { public void onComplete(); } private OnCompleteListener mListener; private int mProgress; public ProgressGenerator(OnCompleteListener listener) { mListener = listener; } public void start(final ProcessButton button) { final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { mProgress += 10; button.setProgress(mProgress); if (mProgress < 100) { handler.postDelayed(this, generateDelay()); } else { mListener.onComplete(); } } }, generateDelay()); } private Random random = new Random(); private int generateDelay() { return random.nextInt(1000); } }