Example usage for android.os SystemClock uptimeMillis

List of usage examples for android.os SystemClock uptimeMillis

Introduction

In this page you can find the example usage for android.os SystemClock uptimeMillis.

Prototype

@CriticalNative
native public static long uptimeMillis();

Source Link

Document

Returns milliseconds since boot, not counting time spent in deep sleep.

Usage

From source file:cn.ismartv.recyclerview.widget.RecyclerView.java

/**
 * Enable or disable layout and scroll.  After <code>setLayoutFrozen(true)</code> is called,
 * Layout requests will be postponed until <code>setLayoutFrozen(false)</code> is called;
 * child views are not updated when RecyclerView is frozen, {@link #smoothScrollBy(int, int)},
 * {@link #scrollBy(int, int)}, {@link #scrollToPosition(int)} and
 * {@link #smoothScrollToPosition(int)} are dropped; TouchEvents and GenericMotionEvents are
 * dropped; {@link LayoutManager#onFocusSearchFailed(View, int, Recycler, State)} will not be
 * called.//  ww  w.ja va 2 s.  co m
 *
 * <p>
 * <code>setLayoutFrozen(true)</code> does not prevent app from directly calling {@link
 * LayoutManager#scrollToPosition(int)}, {@link LayoutManager#smoothScrollToPosition(
 * RecyclerView, State, int)}.
 * <p>
 * {@link #setAdapter(Adapter)} and {@link #swapAdapter(Adapter, boolean)} will automatically
 * stop frozen.
 * <p>
 * Note: Running ItemAnimator is not stopped automatically,  it's caller's
 * responsibility to call ItemAnimator.end().
 *
 * @param frozen   true to freeze layout and scroll, false to re-enable.
 */
public void setLayoutFrozen(boolean frozen) {
    if (frozen != mLayoutFrozen) {
        assertNotInLayoutOrScroll("Do not setLayoutFrozen in layout or scroll");
        if (!frozen) {
            mLayoutFrozen = frozen;
            if (mLayoutRequestEaten && mLayout != null && mAdapter != null) {
                requestLayout();
            }
            mLayoutRequestEaten = false;
        } else {
            final long now = SystemClock.uptimeMillis();
            MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0);
            onTouchEvent(cancelEvent);
            mLayoutFrozen = frozen;
            mIgnoreMotionEventTillDown = true;
            stopScroll();
        }
    }
}

From source file:com.anysoftkeyboard.AnySoftKeyboard.java

private void handleCharacter(final int primaryCode, final Key key, final int multiTapIndex,
        int[] nearByKeyCodes) {
    if (BuildConfig.DEBUG)
        Logger.d(TAG, "handleCharacter: %d, isPredictionOn: %s, mPredicting: %s", primaryCode, isPredictionOn(),
                TextEntryState.isPredicting());

    mExpectingSelectionUpdateBy = SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE;
    if (TextEntryState.isReadyToPredict() && isAlphabet(primaryCode) && !isCursorTouchingWord()) {
        TextEntryState.newSession(mPredictionOn);
        mUndoCommitCursorPosition = UNDO_COMMIT_NONE;
        mWord.reset();/*from  ww  w  .ja  v  a 2s  . c o  m*/
        mAutoCorrectOn = mAutoComplete;
        TextEntryState.typedCharacter((char) primaryCode, false);
        if (mShiftKeyState.isActive()) {
            mWord.setFirstCharCapitalized(true);
        }
    } else if (TextEntryState.isPredicting()) {
        TextEntryState.typedCharacter((char) primaryCode, false);
    }

    mLastCharacterWasShifted = (getInputView() != null) && getInputView().isShifted();

    if (TextEntryState.isPredicting()) {
        final InputConnection ic = getCurrentInputConnection();
        mWord.add(primaryCode, nearByKeyCodes);
        ChewbaccaOnTheDrums.onKeyTyped(mWord, getApplicationContext());

        if (ic != null) {
            final int cursorPosition;
            if (mWord.cursorPosition() != mWord.length()) {
                //Cursor is not at the end of the word. I'll need to reposition
                cursorPosition = mGlobalCursorPosition + 1/*adding the new character*/;
                ic.beginBatchEdit();
            } else {
                cursorPosition = -1;
            }

            ic.setComposingText(mWord.getTypedWord(), 1);
            if (cursorPosition > 0) {
                ic.setSelection(cursorPosition, cursorPosition);
                ic.endBatchEdit();
            }
        }
        // this should be done ONLY if the key is a letter, and not a inner
        // character (like ').
        if (isSuggestionAffectingCharacter(primaryCode)) {
            postUpdateSuggestions();
        } else {
            // just replace the typed word in the candidates view
            if (mCandidateView != null)
                mCandidateView.replaceTypedWord(mWord.getTypedWord());
        }
    } else {
        sendKeyChar((char) primaryCode);
    }
    mJustAutoAddedWord = false;
}

From source file:org.distantshoresmedia.keyboard.LatinIME.java

public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
    long when = SystemClock.uptimeMillis();
    if (primaryCode != Keyboard.KEYCODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
        mDeleteCount = 0;//from w  w w  .j a va2 s.  c o  m
    }
    mLastKeyTime = when;
    final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
    switch (primaryCode) {
    case Keyboard.KEYCODE_DELETE:
        if (processMultiKey(primaryCode)) {
            break;
        }
        handleBackspace();
        mDeleteCount++;
        TKIMELogger.logOnDelete();
        break;
    case Keyboard.KEYCODE_SHIFT:
        // Shift key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            handleShift();
        break;
    case Keyboard.KEYCODE_MODE_CHANGE:
        // Symbol key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            changeKeyboardMode();
        break;
    case TKKeyboardView.KEYCODE_CTRL_LEFT:
        // Ctrl key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            setModCtrl(!mModCtrl);
        break;
    case TKKeyboardView.KEYCODE_ALT_LEFT:
        // Alt key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            setModAlt(!mModAlt);
        break;
    case TKKeyboardView.KEYCODE_META_LEFT:
        // Meta key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            setModMeta(!mModMeta);
        break;
    case TKKeyboardView.KEYCODE_FN:
        if (!distinctMultiTouch)
            setModFn(!mModFn);
        break;
    case Keyboard.KEYCODE_CANCEL:
        if (!isShowingOptionDialog()) {
            handleClose();
        }
        break;
    case TKKeyboardView.KEYCODE_OPTIONS:
        onOptionKeyPressed();
        break;
    case TKKeyboardView.KEYCODE_OPTIONS_LONGPRESS:
        onOptionKeyLongPressed();
        break;
    case TKKeyboardView.KEYCODE_COMPOSE:
        mComposeMode = !mComposeMode;
        mComposeBuffer.clear();
        break;
    case TKKeyboardView.KEYCODE_NEXT_LANGUAGE:
        toggleLanguage(false, true);
        break;
    case TKKeyboardView.KEYCODE_PREV_LANGUAGE:
        toggleLanguage(false, false);
        break;
    case TKKeyboardView.KEYCODE_VOICE:
        //            if (mVoiceRecognitionTrigger.isInstalled()) {
        //                mVoiceRecognitionTrigger.startVoiceRecognition();
        //            }
        //startListening(false /* was a button press, was not a swipe */);
        break;
    case 9 /* Tab */:
        if (processMultiKey(primaryCode)) {
            break;
        }
        sendTab();
        break;
    case TKKeyboardView.KEYCODE_ESCAPE:
        if (processMultiKey(primaryCode)) {
            break;
        }
        sendEscape();
        break;
    case TKKeyboardView.KEYCODE_DPAD_UP:
    case TKKeyboardView.KEYCODE_DPAD_DOWN:
    case TKKeyboardView.KEYCODE_DPAD_LEFT:
    case TKKeyboardView.KEYCODE_DPAD_RIGHT:
    case TKKeyboardView.KEYCODE_DPAD_CENTER:
    case TKKeyboardView.KEYCODE_HOME:
    case TKKeyboardView.KEYCODE_END:
    case TKKeyboardView.KEYCODE_PAGE_UP:
    case TKKeyboardView.KEYCODE_PAGE_DOWN:
    case TKKeyboardView.KEYCODE_FKEY_F1:
    case TKKeyboardView.KEYCODE_FKEY_F2:
    case TKKeyboardView.KEYCODE_FKEY_F3:
    case TKKeyboardView.KEYCODE_FKEY_F4:
    case TKKeyboardView.KEYCODE_FKEY_F5:
    case TKKeyboardView.KEYCODE_FKEY_F6:
    case TKKeyboardView.KEYCODE_FKEY_F7:
    case TKKeyboardView.KEYCODE_FKEY_F8:
    case TKKeyboardView.KEYCODE_FKEY_F9:
    case TKKeyboardView.KEYCODE_FKEY_F10:
    case TKKeyboardView.KEYCODE_FKEY_F11:
    case TKKeyboardView.KEYCODE_FKEY_F12:
    case TKKeyboardView.KEYCODE_FORWARD_DEL:
    case TKKeyboardView.KEYCODE_INSERT:
    case TKKeyboardView.KEYCODE_SYSRQ:
    case TKKeyboardView.KEYCODE_BREAK:
    case TKKeyboardView.KEYCODE_NUM_LOCK:
    case TKKeyboardView.KEYCODE_SCROLL_LOCK:
        if (processMultiKey(primaryCode)) {
            break;
        }
        // send as plain keys, or as escape sequence if needed
        sendSpecialKey(-primaryCode);
        break;
    default:
        if (!mComposeMode && mDeadKeysActive && Character.getType(primaryCode) == Character.NON_SPACING_MARK) {
            //Log.i(TAG, "possible dead character: " + primaryCode);
            if (!mDeadAccentBuffer.execute(primaryCode)) {
                //Log.i(TAG, "double dead key");
                break; // pressing a dead key twice produces spacing equivalent
            }
            updateShiftKeyState(getCurrentInputEditorInfo());
            break;
        }
        if (processMultiKey(primaryCode)) {
            break;
        }
        if (primaryCode != ASCII_ENTER) {
            mJustAddedAutoSpace = false;
        }
        TKIMEUtil.RingCharBuffer.getInstance().push((char) primaryCode, x, y);
        TKIMELogger.logOnInputChar();
        if (isWordSeparator(primaryCode)) {
            handleSeparator(primaryCode);
        } else {
            handleCharacter(primaryCode, keyCodes);
        }
        // Cancel the just reverted state
        mJustRevertedSeparator = null;
    }
    mKeyboardSwitcher.onKey(primaryCode);
    // Reset after any single keystroke
    mEnteredText = null;
    //mDeadAccentBuffer.clear();  // FIXME
}

From source file:org.mozilla.gecko.GeckoApp.java

@Override
protected void onNewIntent(Intent intent) {
    Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onNewIntent");

    if (checkLaunchState(LaunchState.GeckoExiting)) {
        // We're exiting and shouldn't try to do anything else just incase
        // we're hung for some reason we'll force the process to exit
        System.exit(0);//from w w w  .ja v a2 s. c o m
        return;
    }

    if (checkLaunchState(LaunchState.Launched)) {
        Uri data = intent.getData();
        Bundle bundle = intent.getExtras();
        // if the intent has data (i.e. a URI to be opened) and the scheme
        // is either http, we'll prefetch it, which means warming
        // up the radio and DNS cache by connecting and parsing the redirect
        // if the return code is between 300 and 400
        if (data != null && "http".equals(data.getScheme())
                && (bundle == null || bundle.getInt("prefetched", 0) != 1)
                && isHostOnPrefetchWhitelist(data.getHost())) {
            GeckoAppShell.getHandler().post(new RedirectorRunnable(intent));
            return;
        }
    }
    final String action = intent.getAction();
    if (ACTION_DEBUG.equals(action)
            && checkAndSetLaunchState(LaunchState.Launching, LaunchState.WaitForDebugger)) {
        mMainHandler.postDelayed(new Runnable() {
            public void run() {
                Log.i(LOGTAG, "Launching from debug intent after 5s wait");
                setLaunchState(LaunchState.Launching);
                sGeckoThread.start();
            }
        }, 1000 * 5 /* 5 seconds */);
        Log.i(LOGTAG, "Intent : ACTION_DEBUG - waiting 5s before launching");
        return;
    }
    if (checkLaunchState(LaunchState.WaitForDebugger) || intent == getIntent())
        return;

    if (Intent.ACTION_MAIN.equals(action)) {
        Log.i(LOGTAG, "Intent : ACTION_MAIN");
        GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(""));
    } else if (ACTION_LOAD.equals(action)) {
        String uri = intent.getDataString();
        loadUrl(uri, AwesomeBar.Type.EDIT);
        Log.i(LOGTAG, "onNewIntent: " + uri);
    } else if (Intent.ACTION_VIEW.equals(action)) {
        String uri = intent.getDataString();
        GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri));
        Log.i(LOGTAG, "onNewIntent: " + uri);
    } else if (ACTION_WEBAPP.equals(action)) {
        String uri = getURIFromIntent(intent);
        GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri));
        Log.i(LOGTAG, "Intent : WEBAPP - " + uri);
    } else if (ACTION_BOOKMARK.equals(action)) {
        String uri = getURIFromIntent(intent);
        GeckoAppShell.sendEventToGecko(GeckoEvent.createLoadEvent(uri));
        Log.i(LOGTAG, "Intent : BOOKMARK - " + uri);
    }
}

From source file:org.pocketworkstation.pckeyboard.LatinIME.java

public void onKey(int primaryCode, int[] keyCodes, int x, int y) {
    long when = SystemClock.uptimeMillis();
    if (primaryCode != Keyboard.KEYCODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
        mDeleteCount = 0;/*from ww w. ja v a  2 s .  co  m*/
    }
    mLastKeyTime = when;
    final boolean distinctMultiTouch = mKeyboardSwitcher.hasDistinctMultitouch();
    switch (primaryCode) {
    case Keyboard.KEYCODE_DELETE:
        if (processMultiKey(primaryCode)) {
            break;
        }
        handleBackspace();
        mDeleteCount++;
        break;
    case Keyboard.KEYCODE_SHIFT:
        // Shift key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            handleShift();
        break;
    case Keyboard.KEYCODE_MODE_CHANGE:
        // Symbol key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            changeKeyboardMode();
        break;
    case LatinKeyboardView.KEYCODE_CTRL_LEFT:
        // Ctrl key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            setModCtrl(!mModCtrl);
        break;
    case LatinKeyboardView.KEYCODE_ALT_LEFT:
        // Alt key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            setModAlt(!mModAlt);
        break;
    case LatinKeyboardView.KEYCODE_META_LEFT:
        // Meta key is handled in onPress() when device has distinct
        // multi-touch panel.
        if (!distinctMultiTouch)
            setModMeta(!mModMeta);
        break;
    case LatinKeyboardView.KEYCODE_FN:
        if (!distinctMultiTouch)
            setModFn(!mModFn);
        break;
    case Keyboard.KEYCODE_CANCEL:
        if (!isShowingOptionDialog()) {
            handleClose();
        }
        break;
    case LatinKeyboardView.KEYCODE_OPTIONS:
        onOptionKeyPressed();
        break;
    case LatinKeyboardView.KEYCODE_OPTIONS_LONGPRESS:
        onOptionKeyLongPressed();
        break;
    case LatinKeyboardView.KEYCODE_COMPOSE:
        mComposeMode = !mComposeMode;
        mComposeBuffer.clear();
        break;
    case LatinKeyboardView.KEYCODE_NEXT_LANGUAGE:
        toggleLanguage(false, true);
        break;
    case LatinKeyboardView.KEYCODE_PREV_LANGUAGE:
        toggleLanguage(false, false);
        break;
    case LatinKeyboardView.KEYCODE_VOICE:
        if (mVoiceRecognitionTrigger.isInstalled()) {
            mVoiceRecognitionTrigger.startVoiceRecognition();
        }
        //startListening(false /* was a button press, was not a swipe */);
        break;
    case 9 /* Tab */:
        if (processMultiKey(primaryCode)) {
            break;
        }
        sendTab();
        break;
    case LatinKeyboardView.KEYCODE_ESCAPE:
        if (processMultiKey(primaryCode)) {
            break;
        }
        sendEscape();
        break;
    case LatinKeyboardView.KEYCODE_DPAD_UP:
    case LatinKeyboardView.KEYCODE_DPAD_DOWN:
    case LatinKeyboardView.KEYCODE_DPAD_LEFT:
    case LatinKeyboardView.KEYCODE_DPAD_RIGHT:
    case LatinKeyboardView.KEYCODE_DPAD_CENTER:
    case LatinKeyboardView.KEYCODE_HOME:
    case LatinKeyboardView.KEYCODE_END:
    case LatinKeyboardView.KEYCODE_PAGE_UP:
    case LatinKeyboardView.KEYCODE_PAGE_DOWN:
    case LatinKeyboardView.KEYCODE_FKEY_F1:
    case LatinKeyboardView.KEYCODE_FKEY_F2:
    case LatinKeyboardView.KEYCODE_FKEY_F3:
    case LatinKeyboardView.KEYCODE_FKEY_F4:
    case LatinKeyboardView.KEYCODE_FKEY_F5:
    case LatinKeyboardView.KEYCODE_FKEY_F6:
    case LatinKeyboardView.KEYCODE_FKEY_F7:
    case LatinKeyboardView.KEYCODE_FKEY_F8:
    case LatinKeyboardView.KEYCODE_FKEY_F9:
    case LatinKeyboardView.KEYCODE_FKEY_F10:
    case LatinKeyboardView.KEYCODE_FKEY_F11:
    case LatinKeyboardView.KEYCODE_FKEY_F12:
    case LatinKeyboardView.KEYCODE_FORWARD_DEL:
    case LatinKeyboardView.KEYCODE_INSERT:
    case LatinKeyboardView.KEYCODE_SYSRQ:
    case LatinKeyboardView.KEYCODE_BREAK:
    case LatinKeyboardView.KEYCODE_NUM_LOCK:
    case LatinKeyboardView.KEYCODE_SCROLL_LOCK:
        if (processMultiKey(primaryCode)) {
            break;
        }
        // send as plain keys, or as escape sequence if needed
        sendSpecialKey(-primaryCode);
        break;
    default:
        if (!mComposeMode && mDeadKeysActive && Character.getType(primaryCode) == Character.NON_SPACING_MARK) {
            //Log.i(TAG, "possible dead character: " + primaryCode);
            if (!mDeadAccentBuffer.execute(primaryCode)) {
                //Log.i(TAG, "double dead key");
                break; // pressing a dead key twice produces spacing equivalent
            }
            updateShiftKeyState(getCurrentInputEditorInfo());
            break;
        }
        if (processMultiKey(primaryCode)) {
            break;
        }
        if (primaryCode != ASCII_ENTER) {
            mJustAddedAutoSpace = false;
        }
        RingCharBuffer.getInstance().push((char) primaryCode, x, y);
        if (isWordSeparator(primaryCode)) {
            handleSeparator(primaryCode);
        } else {
            handleCharacter(primaryCode, keyCodes);
        }
        // Cancel the just reverted state
        mJustRevertedSeparator = null;
    }
    mKeyboardSwitcher.onKey(primaryCode);
    // Reset after any single keystroke
    mEnteredText = null;
    //mDeadAccentBuffer.clear();  // FIXME
}

From source file:com.anysoftkeyboard.AnySoftKeyboard.java

private void handleSeparator(int primaryCode) {
    // Issue 146: Right to left languages require reversed parenthesis
    if (!getCurrentAlphabetKeyboard().isLeftToRightLanguage()) {
        if (primaryCode == (int) ')')
            primaryCode = (int) '(';
        else if (primaryCode == (int) '(')
            primaryCode = (int) ')';
    }/*from   w ww .j  a va 2 s. c  o  m*/
    mExpectingSelectionUpdateBy = SystemClock.uptimeMillis() + MAX_TIME_TO_EXPECT_SELECTION_UPDATE;
    //will not show next-word suggestion in case of a new line or if the separator is a sentence separator.
    boolean isEndOfSentence = (primaryCode == KeyCodes.ENTER || mSentenceSeparators.get(primaryCode));

    // Should dismiss the "Touch again to save" message when handling
    // separator
    if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
        postUpdateSuggestions();
    }

    // Handle separator
    InputConnection ic = getCurrentInputConnection();
    if (ic != null) {
        ic.beginBatchEdit();
    }
    // this is a special case, when the user presses a separator WHILE
    // inside the predicted word.
    // in this case, I will want to just dump the separator.
    final boolean separatorInsideWord = (mWord.cursorPosition() < mWord.length());
    if (TextEntryState.isPredicting() && !separatorInsideWord) {
        //ACTION does not invoke default picking. See https://github.com/AnySoftKeyboard/AnySoftKeyboard/issues/198
        pickDefaultSuggestion(mAutoCorrectOn && primaryCode != KeyCodes.ENTER);
        // Picked the suggestion by a space/punctuation character: we will treat it
        // as "added an auto space".
        mJustAddedAutoSpace = true;
    } else if (separatorInsideWord) {
        // when putting a separator in the middle of a word, there is no
        // need to do correction, or keep knowledge
        abortCorrectionAndResetPredictionState(false);
    }

    if (mJustAddedAutoSpace && primaryCode == KeyCodes.ENTER) {
        removeTrailingSpace();
        mJustAddedAutoSpace = false;
    }

    boolean handledOutputToInputConnection = false;

    if (ic != null) {
        if (primaryCode == KeyCodes.SPACE) {
            if (mAskPrefs.isDoubleSpaceChangesToPeriod()) {
                if ((SystemClock.uptimeMillis()
                        - mLastSpaceTimeStamp) < ((long) mAskPrefs.getMultiTapTimeout())) {
                    //current text in the input-box should be something like "word "
                    //the user pressed on space again. So we want to change the text in the input-box
                    //into "word "->"word. "
                    ic.deleteSurroundingText(1, 0);
                    ic.commitText(". ", 1);
                    mJustAddedAutoSpace = true;
                    isEndOfSentence = true;
                    handledOutputToInputConnection = true;
                }
            }
        } else if (mJustAddedAutoSpace && mLastSpaceTimeStamp != NEVER_TIME_STAMP/*meaning last key was SPACE*/
                && mAskPrefs.shouldSwapPunctuationAndSpace() && primaryCode != KeyCodes.ENTER
                && isSentenceSeparator(primaryCode)) {
            //current text in the input-box should be something like "word "
            //the user pressed a punctuation (say ","). So we want to change the text in the input-box
            //into "word "->"word, "
            ic.deleteSurroundingText(1, 0);
            ic.commitText(((char) primaryCode) + " ", 1);
            mJustAddedAutoSpace = true;
            handledOutputToInputConnection = true;
        }
    }

    if (!handledOutputToInputConnection) {
        sendKeyChar((char) primaryCode);
    }
    TextEntryState.typedCharacter((char) primaryCode, true);

    if (ic != null) {
        ic.endBatchEdit();
    }

    if (isEndOfSentence) {
        mSuggest.resetNextWordSentence();
        clearSuggestions();
    } else if (!TextUtils.isEmpty(mCommittedWord)) {
        setSuggestions(mSuggest.getNextSuggestions(mCommittedWord, mWord.isAllUpperCase()), false, false,
                false);
        mWord.setFirstCharCapitalized(false);
    }
}

From source file:org.bangbang.support.v4.widget.VerticalViewPager.java

/**
 * Start a fake drag of the pager./* w w  w .  ja  va2s . co  m*/
 *
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view, while still letting the ViewPager
 * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
 * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
 * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
 *
 * <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
 * is already in progress, this method will return false.
 *
 * @return true if the fake drag began successfully, false if it could not be started.
 *
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    // bangbang.S
    //        mInitialMotionX = mLastMotionX = 0;
    mInitialMotionY = mLastMotionY = 0;
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    } else {
        mVelocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0);
    mVelocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}

From source file:com.gome.ecmall.custom.VerticalViewPager.java

/**
 * Fake drag by an offset in pixels. You must have called {@link #beginFakeDrag()} first.
 * //from   w ww.  j  av  a2  s  .co m
 * @param xOffset
 *            Offset in pixels to drag by.
 * @see #beginFakeDrag()
 * @see #endFakeDrag()
 */
public void fakeDragBy(float yOffset) {
    if (!mFakeDragging) {
        throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first.");
    }

    mLastMotionY += yOffset;

    float oldScrollY = getScrollY();
    float scrollY = oldScrollY - yOffset;
    final int height = getHeight();

    float topBound = height * mFirstOffset;
    float bottomBound = height * mLastOffset;

    final ItemInfo firstItem = mItems.get(0);
    final ItemInfo lastItem = mItems.get(mItems.size() - 1);
    if (firstItem.position != 0) {
        topBound = firstItem.offset * height;
    }
    if (lastItem.position != mAdapter.getCount() - 1) {
        bottomBound = lastItem.offset * topBound;
    }

    if (scrollY < topBound) {
        scrollY = topBound;
    } else if (scrollY > bottomBound) {
        scrollY = bottomBound;
    }
    // Don't lose the rounded component
    mLastMotionY += scrollY - (int) scrollY;
    scrollTo(getScrollX(), (int) scrollY);
    pageScrolled((int) scrollY);

    // Synthesize an event for the VelocityTracker.
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE, 0,
            mLastMotionY, 0);
    mVelocityTracker.addMovement(ev);
    ev.recycle();
}

From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java

private void updateRecordingTime() {
    if (!isRecording && !onPause) {
        mRecordingTimeView.setText("00:00");
        mRecorded = 0;/*from   w  w w .ja  v a  2s. c  om*/
        return;
    }

    if (onPause) {
        mRecorded = timeStringToMillisecond(mRecordingTimeView.getText().toString());

        blinkPause();

        return;
    }

    long now = SystemClock.uptimeMillis();
    long delta = now - mRecordingStartTime + mRecorded;

    // Starting a minute before reaching the max duration
    // limit, we'll countdown the remaining time instead.
    boolean countdownRemainingTime = (mMaxVideoDurationInMs != 0 && delta >= mMaxVideoDurationInMs - 60000);

    long deltaAdjusted = (long) (delta * captureRate / 24);
    // *captureRate/24 needed for time lapse
    if (countdownRemainingTime) {
        deltaAdjusted = Math.max(0, mMaxVideoDurationInMs - deltaAdjusted) + 999;
    }
    String text;

    long targetNextUpdateDelay;
    text = millisecondToTimeString(deltaAdjusted, false);
    targetNextUpdateDelay = 900;

    mRecordingTimeView.setText(text);

    if (mRecordingTimeCountsDown != countdownRemainingTime) {
        // Avoid setting the color on every update, do it only
        // when it needs changing.
        mRecordingTimeCountsDown = countdownRemainingTime;

        int color = ApplicationScreen.getAppResources().getColor(R.color.recording_time_remaining_text);

        mRecordingTimeView.setTextColor(color);
    }

    long actualNextUpdateDelay = targetNextUpdateDelay - (delta % targetNextUpdateDelay);

    new CountDownTimer(actualNextUpdateDelay, actualNextUpdateDelay) {
        public void onTick(long millisUntilFinished) {
        }

        public void onFinish() {
            updateRecordingTime();
        }
    }.start();

    // show recording shutter
    if (showRecording) {
        stopVideoButton.setImageDrawable(
                ApplicationScreen.getAppResources().getDrawable(R.drawable.plugin_capture_video_stop_square));
        showRecording = false;
    } else {
        stopVideoButton.setImageDrawable(ApplicationScreen.getAppResources()
                .getDrawable(R.drawable.plugin_capture_video_stop_square_red));
        showRecording = true;
    }
}

From source file:android.support.v71.widget.RecyclerView.java

/**
 * Enable or disable layout and scroll.  After <code>setLayoutFrozen(true)</code> is called,
 * Layout requests will be postponed until <code>setLayoutFrozen(false)</code> is called;
 * child views are not updated when RecyclerView is frozen, {@link #smoothScrollBy(int, int)},
 * {@link #scrollBy(int, int)}, {@link #scrollToPosition(int)} and
 * {@link #smoothScrollToPosition(int)} are dropped; TouchEvents and GenericMotionEvents are
 * dropped; {@link LayoutManager#onFocusSearchFailed(View, int, Recycler, State)} will not be
 * called.//from   w  ww.  java2s . c om
 * <p/>
 * <p/>
 * <code>setLayoutFrozen(true)</code> does not prevent app from directly calling {@link
 * LayoutManager#scrollToPosition(int)}, {@link LayoutManager#smoothScrollToPosition(
 *RecyclerView, State, int)}.
 * <p/>
 * {@link #setAdapter(Adapter)} and {@link #swapAdapter(Adapter, boolean)} will automatically
 * stop frozen.
 * <p/>
 * Note: Running ItemAnimator is not stopped automatically,  it's caller's
 * responsibility to call ItemAnimator.end().
 * <p/>
 * 
 *
 * @param frozen true to freeze layout and scroll, false to re-enable.
 */
public void setLayoutFrozen(boolean frozen) {
    if (frozen != mLayoutFrozen) {
        // view 
        assertNotInLayoutOrScroll("Do not setLayoutFrozen in layout or scroll");
        if (!frozen) {
            // 
            mLayoutFrozen = frozen;

            //TODO mLayoutRequestEaten ???
            if (mLayoutRequestEaten && mLayout != null && mAdapter != null) {
                //  layoutManager adpater ??  ?
                requestLayout();
            }
            mLayoutRequestEaten = false;
        } else {
            // 
            final long now = SystemClock.uptimeMillis();
            //? cancle 
            MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0);
            onTouchEvent(cancelEvent);
            mLayoutFrozen = frozen;
            // 
            mIgnoreMotionEventTillDown = true;
            // ?
            stopScroll();
        }
    }
}