FileDocCategorySizeDatePackage
DoubleDigitManager.javaAPI DocAndroid 1.5 API3457Wed May 06 22:41:56 BST 2009android.widget

DoubleDigitManager

public class DoubleDigitManager extends Object
Provides callbacks indicating the steps in two digit pressing within a timeout. Package private: only relevant in helping {@link TimeSpinnerHelper}.

Fields Summary
private final long
timeoutInMillis
private final CallBack
mCallBack
private Integer
intermediateDigit
Constructors Summary
public DoubleDigitManager(long timeoutInMillis, CallBack callBack)

param
timeoutInMillis How long after the first digit is pressed does the user have to press the second digit?
param
callBack The callback to indicate what's going on with the user.

        this.timeoutInMillis = timeoutInMillis;
        mCallBack = callBack;
    
Methods Summary
public voidreportDigit(int digit)
Report to this manager that a digit was pressed.

param
digit

        if (intermediateDigit == null) {
            intermediateDigit = digit;

            new Handler().postDelayed(new Runnable() {
                public void run() {
                    if (intermediateDigit != null) {
                        mCallBack.singleDigitFinal(intermediateDigit);
                        intermediateDigit = null;
                    }
                }
            }, timeoutInMillis);

            if (!mCallBack.singleDigitIntermediate(digit)) {

                // this wasn't a good candidate for the intermediate digit,
                // make it the final digit (since there is no opportunity to
                // reject the final digit).
                intermediateDigit = null;
                mCallBack.singleDigitFinal(digit);
            }
        } else if (mCallBack.twoDigitsFinal(intermediateDigit, digit)) {
             intermediateDigit = null;
        }