Android Open Source - android-process-button Progress Generator






From Project

Back to project page android-process-button.

License

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.

Java Source Code

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);
    }
}




Java Source Code List

com.dd.processbutton.FlatButton.java
com.dd.processbutton.ProcessButton.java
com.dd.processbutton.iml.ActionProcessButton.java
com.dd.processbutton.iml.GenerateProcessButton.java
com.dd.processbutton.iml.SubmitProcessButton.java
com.dd.sample.MainActivity.java
com.dd.sample.MessageActivity.java
com.dd.sample.SignInActivity.java
com.dd.sample.StateSampleActivity.java
com.dd.sample.UploadActivity.java
com.dd.sample.utils.ProgressGenerator.java