diff options
| author | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-03 18:28:45 -0800 |
| commit | d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /core/java/android/widget/DoubleDigitManager.java | |
| parent | 076357b8567458d4b6dfdcf839ef751634cd2bfb (diff) | |
auto import from //depot/cupcake/@135843
Diffstat (limited to 'core/java/android/widget/DoubleDigitManager.java')
| -rw-r--r-- | core/java/android/widget/DoubleDigitManager.java | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/core/java/android/widget/DoubleDigitManager.java b/core/java/android/widget/DoubleDigitManager.java deleted file mode 100644 index 1eea1fb06bda..000000000000 --- a/core/java/android/widget/DoubleDigitManager.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (C) 2007 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.widget; - -import android.os.Handler; - -/** - * Provides callbacks indicating the steps in two digit pressing within a - * timeout. - * - * Package private: only relevant in helping {@link TimeSpinnerHelper}. - */ -class DoubleDigitManager { - - private final long timeoutInMillis; - private final CallBack mCallBack; - - private Integer intermediateDigit; - - /** - * @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. - */ - public DoubleDigitManager(long timeoutInMillis, CallBack callBack) { - this.timeoutInMillis = timeoutInMillis; - mCallBack = callBack; - } - - /** - * Report to this manager that a digit was pressed. - * @param digit - */ - public void reportDigit(int 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; - } - } - - /** - * The callback to indicate what is going on with the digits pressed. - */ - static interface CallBack { - - /** - * A digit was pressed, and there are no intermediate digits. - * @param digit The digit pressed. - * @return Whether the digit was accepted; how the user of this manager - * tells us that the intermediate digit is acceptable as an - * intermediate digit. - */ - boolean singleDigitIntermediate(int digit); - - /** - * A single digit was pressed, and it is 'the final answer'. - * - a single digit pressed, and the timeout expires. - * - a single digit pressed, and {@link #singleDigitIntermediate} - * returned false. - * @param digit The digit. - */ - void singleDigitFinal(int digit); - - /** - * The user pressed digit1, then digit2 within the timeout. - * @param digit1 - * @param digit2 - */ - boolean twoDigitsFinal(int digit1, int digit2); - } - -} |
