List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:silent.kuasapmaterial.libs.ProgressWheel.java
/** * Set the progress to a specific value, * the bar will smoothly animate until that value * * @param progress the progress between 0 and 1 *//*from ww w . ja va2 s. co m*/ public void setProgress(float progress) { if (isSpinning) { mProgress = 0.0f; isSpinning = false; runCallback(); } if (progress > 1.0f) { progress -= 1.0f; } else if (progress < 0) { progress = 0; } if (progress == mTargetProgress) { return; } // If we are currently in the right position // we set again the last time animated so the // animation starts smooth from here if (mProgress == mTargetProgress) { lastTimeAnimated = SystemClock.uptimeMillis(); } mTargetProgress = Math.min(progress * 360.0f, 360.0f); invalidate(); }
From source file:com.googlecode.eyesfree.testing.BaseAccessibilityInstrumentationTestCase.java
protected void onEventReceived(AccessibilityEvent event) { synchronized (mAccessibilityEventLock) { mLastEventTime = SystemClock.uptimeMillis(); }// w w w .j av a2 s.c o m synchronized (mEventCache) { if (mRecordingEvents) { mEventCache.add(AccessibilityEvent.obtain(event)); mEventCache.notifyAll(); } } }
From source file:silent.kuasapmaterial.libs.ProgressWheel.java
/** * Set the progress to a specific value, * the bar will be set instantly to that value * * @param progress the progress between 0 and 1 *//* w ww. ja v a 2s .c o m*/ public void setInstantProgress(float progress) { if (isSpinning) { mProgress = 0.0f; isSpinning = false; } if (progress > 1.0f) { progress -= 1.0f; } else if (progress < 0) { progress = 0; } if (progress == mTargetProgress) { return; } mTargetProgress = Math.min(progress * 360.0f, 360.0f); mProgress = mTargetProgress; lastTimeAnimated = SystemClock.uptimeMillis(); invalidate(); }
From source file:com.iiordanov.bVNC.RemoteCanvas.java
/** * Sends over the unix username and password if this is VNC over SSH connectio and automatic sending of * UNIX credentials is enabled for AutoX (for x11vnc's "-unixpw" option). *//*from w w w .j ava 2s . co m*/ void sendUnixAuth() { // If the type of connection is ssh-tunneled and we are told to send the unix credentials, then do so. if (connection.getConnectionType() == Constants.CONN_TYPE_SSH && connection.getAutoXUnixAuth()) { keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_UNKNOWN, new KeyEvent(SystemClock.uptimeMillis(), connection.getSshUser(), 0, 0)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_UNKNOWN, new KeyEvent(SystemClock.uptimeMillis(), connection.getSshPassword(), 0, 0)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER)); keyboard.processLocalKeyEvent(KeyEvent.KEYCODE_ENTER, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_ENTER)); } }
From source file:com.library.core.view.HorizontalListView.java
/** * ?/*from w w w. j a v a 2 s. c o m*/ * * @param i * @param j */ public void smoothScrollToPosition1(int i, int j) { // TODO Auto-generated method stub MotionEvent e1 = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 89.333336f, 265.33334f, 0); MotionEvent e2 = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 150.0f, 238.00003f, 0); // Animation rInAnim = AnimationUtils.loadAnimation(mContext, // R.anim.anim_list); // HorizontalListView.this.setAnimation(rInAnim); int a = getWidth() / 5; mOnGesture.onScroll(e1, e2, a, 0); }
From source file:com.campusclipper.android.MyLocationActivity.java
@Override public boolean onMarkerClick(final Marker marker) { if (marker.equals(mPerth)) { // This causes the marker at Perth to bounce into position when it is clicked. final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long duration = 1500; final Interpolator interpolator = new BounceInterpolator(); handler.post(new Runnable() { @Override//w w w . j a v a 2 s .co m public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = Math.max(1 - interpolator.getInterpolation((float) elapsed / duration), 0); marker.setAnchor(0.5f, 1.0f + 2 * t); if (t > 0.0) { // Post again 16ms later. handler.postDelayed(this, 16); } } }); } else if (marker.equals(mAdelaide)) { // This causes the marker at Adelaide to change color and alpha. marker.setIcon(BitmapDescriptorFactory.defaultMarker(mRandom.nextFloat() * 360)); marker.setAlpha(mRandom.nextFloat()); } // We return false to indicate that we have not consumed the event and that we wish // for the default behavior to occur (which is for the camera to move such that the // marker is centered and for the marker's info window to open, if it has one). return false; }
From source file:com.concentricsky.android.khanacademy.util.OfflineVideoManager.java
/** * Show a toast explaining that a {@link Video} could not be downloaded. *//*from w w w .ja v a 2 s .co m*/ private void showDownloadError() { long time = SystemClock.uptimeMillis(); if (time - lastErrorToastTime < MIN_ERROR_TOAST_INTERVAL) return; lastErrorToastTime = time; doToast("Error writing to storage. Please try again later."); }
From source file:com.library.core.view.HorizontalListView.java
/** * 1// w w w. j a va 2s .co m * * @param i * @param j */ public void smoothScrollToPosition2(int i, int j) { // TODO Auto-generated method stub MotionEvent e1 = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 89.333336f, 265.33334f, 0); MotionEvent e2 = MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 150.0f, 238.00003f, 0); mOnGesture.onScroll(e1, e2, 1, 0); }
From source file:silent.kuasapmaterial.libs.ProgressWheel.java
@Override public void onRestoreInstanceState(Parcelable state) { if (!(state instanceof WheelSavedState)) { super.onRestoreInstanceState(state); return;//ww w. j a v a 2s. c o m } WheelSavedState ss = (WheelSavedState) state; super.onRestoreInstanceState(ss.getSuperState()); this.mProgress = ss.mProgress; this.mTargetProgress = ss.mTargetProgress; this.isSpinning = ss.isSpinning; this.spinSpeed = ss.spinSpeed; this.barWidth = ss.barWidth; this.barColor = ss.barColor; this.rimWidth = ss.rimWidth; this.rimColor = ss.rimColor; this.circleRadius = ss.circleRadius; this.linearProgress = ss.linearProgress; this.fillRadius = ss.fillRadius; this.lastTimeAnimated = SystemClock.uptimeMillis(); }
From source file:android.support.design.widget.CoordinatorLayout.java
@Override public boolean onTouchEvent(MotionEvent ev) { boolean handled = false; boolean cancelSuper = false; MotionEvent cancelEvent = null;//from w w w. ja va2 s . c om final int action = MotionEventCompat.getActionMasked(ev); if (mBehaviorTouchView != null || (cancelSuper = performIntercept(ev, TYPE_ON_TOUCH))) { // Safe since performIntercept guarantees that // mBehaviorTouchView != null if it returns true final LayoutParams lp = (LayoutParams) mBehaviorTouchView.getLayoutParams(); final Behavior b = lp.getBehavior(); if (b != null) { handled = b.onTouchEvent(this, mBehaviorTouchView, ev); } } // Keep the super implementation correct if (mBehaviorTouchView == null) { handled |= super.onTouchEvent(ev); } else if (cancelSuper) { if (cancelEvent == null) { final long now = SystemClock.uptimeMillis(); cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); } super.onTouchEvent(cancelEvent); } if (!handled && action == MotionEvent.ACTION_DOWN) { } if (cancelEvent != null) { cancelEvent.recycle(); } if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) { resetTouchBehaviors(); } return handled; }