List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:jp.morihirosoft.twwb.TwwbService.java
private void startRecognition() { if (DEBUG)/*w w w .j av a 2 s. com*/ Log.d(TAG, "startRecognition"); if (mARClient == null) { mARClient = new ActivityRecognitionClient(this, this, this); mARClient.connect(); } mStartTime = SystemClock.uptimeMillis(); }
From source file:it.cnr.isti.doremi.sleeplogger.SensorSamplingService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "onStartCommand()"); isStarted = true;/*from w ww . j av a 2 s . co m*/ wakeLock.acquire(); Notification notification = new NotificationCompat.Builder(this).setContentTitle("Logger") .setContentText("Logger").build(); startForeground(101, notification); samples = 0; isRunning = true; t.start(); handler = new Handler(t.getLooper()); tsInit = System.currentTimeMillis(); lastUptime = SystemClock.uptimeMillis() + SAMPLING_INTERVAL; handler.postAtTime(writeTask, lastUptime); return START_STICKY; }
From source file:com.xianxiaotao.copyandstudy.xcopy.recycleranim.adapter.helper.ViewAnimator.java
/** * Animates given View.//from www . jav a2s .co m * * @param view the View that should be animated. */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void animateView(final int position, @NonNull final View view, @NonNull final Animator[] animators) { if (mAnimationStartMillis == -1) { mAnimationStartMillis = SystemClock.uptimeMillis(); } ViewCompat.setAlpha(view, 0); AnimatorSet set = new AnimatorSet(); set.playTogether(animators); set.setStartDelay(calculateAnimationDelay(position)); set.setDuration(mAnimationDurationMillis); set.start(); mAnimators.put(view.hashCode(), set); }
From source file:com.youzu.android.framework.http.HttpHandler.java
@Override protected Void doInBackground(Object... params) { if (this.state == State.CANCELLED || params == null || params.length == 0) return null; if (params.length > 3) { fileSavePath = String.valueOf(params[1]); isDownloadingFile = fileSavePath != null; autoResume = (Boolean) params[2]; autoRename = (Boolean) params[3]; }/*from ww w . j a v a 2 s. c o m*/ try { if (this.state == State.CANCELLED) return null; // init request & requestUrl request = (HttpRequestBase) params[0]; requestUrl = request.getURI().toString(); if (callback != null) { callback.setRequestUrl(requestUrl); } this.publishProgress(UPDATE_START); lastUpdateTime = SystemClock.uptimeMillis(); ResponseInfo<T> cacheInfo = sendRequestForCache(request); if (cacheInfo != null && (cacheInfo.result instanceof String) && callback.doInThread(cacheInfo)) { this.publishProgress(UPDATE_SUCCESS, cacheInfo); if (!HttpUtils.sHttpCache.needRefresh()) { return null; } } ResponseInfo<T> netInfo = sendRequest(request); if (netInfo != null && (netInfo.result instanceof String)) { boolean isSuccess = callback.doInThread(netInfo); if (isSuccess) { HttpUtils.sHttpCache.put(requestUrl + request.toString(), (String) netInfo.result, expiry); publishProgress(UPDATE_SUCCESS, netInfo); } else { publishProgress(UPDATE_FAILURE, null, ""); } return null; } this.publishProgress(UPDATE_SUCCESS, netInfo); return null; } catch (HttpException e) { this.publishProgress(UPDATE_FAILURE, e, e.getMessage()); } return null; }
From source file:com.yek.keyboard.keyboards.views.AnyKeyboardView.java
@Override public boolean onTouchEvent(@NonNull MotionEvent me) { if (getKeyboard() == null)//I mean, if there isn't any keyboard I'm handling, what's the point? return false; if (areTouchesDisabled(me)) { return super.onTouchEvent(me); }//from w w w.j ava2s. c om final int action = MotionEventCompat.getActionMasked(me); // Gesture detector must be enabled only when mini-keyboard is not // on the screen. if (!mMiniKeyboardPopup.isShowing() && mGestureDetector != null && mGestureDetector.onTouchEvent(me)) { Logger.d(TAG, "Gesture detected!"); mKeyPressTimingHandler.cancelAllMessages(); dismissAllKeyPreviews(); return true; } if (action == MotionEvent.ACTION_DOWN) { mFirstTouchPoint.x = (int) me.getX(); mFirstTouchPoint.y = (int) me.getY(); mIsFirstDownEventInsideSpaceBar = mSpaceBarKey != null && mSpaceBarKey.isInside(mFirstTouchPoint.x, mFirstTouchPoint.y); } // If the motion event is above the keyboard and it's a MOVE event // coming even before the first MOVE event into the extension area if (!mIsFirstDownEventInsideSpaceBar && me.getY() < mExtensionKeyboardYActivationPoint && !mMiniKeyboardPopup.isShowing() && !mExtensionVisible && action == MotionEvent.ACTION_MOVE) { if (mExtensionKeyboardAreaEntranceTime <= 0) mExtensionKeyboardAreaEntranceTime = SystemClock.uptimeMillis(); if (SystemClock.uptimeMillis() - mExtensionKeyboardAreaEntranceTime > DELAY_BEFORE_POPPING_UP_EXTENSION_KBD) { KeyboardExtension extKbd = ((ExternalAnyKeyboard) getKeyboard()).getExtensionLayout(); if (extKbd == null || extKbd.getKeyboardResId() == AddOn.INVALID_RES_ID) { Logger.i(TAG, "No extension keyboard"); return super.onTouchEvent(me); } else { // telling the main keyboard that the last touch was // canceled MotionEvent cancel = MotionEvent.obtain(me.getDownTime(), me.getEventTime(), MotionEvent.ACTION_CANCEL, me.getX(), me.getY(), 0); super.onTouchEvent(cancel); cancel.recycle(); mExtensionVisible = true; dismissAllKeyPreviews(); if (mExtensionKey == null) { mExtensionKey = new AnyKey(new Keyboard.Row(getKeyboard()), getThemedKeyboardDimens()); mExtensionKey.edgeFlags = 0; mExtensionKey.height = 1; mExtensionKey.width = 1; mExtensionKey.popupResId = extKbd.getKeyboardResId(); mExtensionKey.externalResourcePopupLayout = mExtensionKey.popupResId != 0; mExtensionKey.x = getWidth() / 2; mExtensionKey.y = mExtensionKeyboardPopupOffset; } // so the popup will be right above your finger. mExtensionKey.x = (int) me.getX(); onLongPress(extKbd, mExtensionKey, AnyApplication.getConfig().isStickyExtensionKeyboard(), getPointerTracker(me)); // it is an extension.. getMiniKeyboard().setPreviewEnabled(true); return true; } } else { return super.onTouchEvent(me); } } else if (mExtensionVisible && me.getY() > mExtensionKeyboardYDismissPoint) { // closing the popup dismissPopupKeyboard(); return true; } else { return super.onTouchEvent(me); } }
From source file:com.yyl.inputmethod.accessibility.AccessibilityEntityProvider.java
/** * Simulates a key press by injecting touch events into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to press.// www . ja va 2 s .c o m */ void simulateKeyPress(final Key key) { final int x = key.mHitBox.centerX(); final int y = key.mHitBox.centerY(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0); final MotionEvent upEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0); mKeyboardView.onTouchEvent(downEvent); mKeyboardView.onTouchEvent(upEvent); downEvent.recycle(); upEvent.recycle(); }
From source file:com.galois.qrstream.MainActivity.java
private void showUI() { getActionBar().show();// w w w . ja v a2 s . c o m Handler windowHandler = getWindow().getDecorView().getHandler(); getWindow().getDecorView().getHandler().postAtTime(new Runnable() { @Override public void run() { MainActivity.this.hideUI(); } }, HANDLER_TOKEN_HIDE_UI, SystemClock.uptimeMillis() + HIDE_UI_DELAY_MS); }
From source file:com.android.hareime.accessibility.AccessibilityEntityProvider.java
/** * Simulates a key press by injecting touch events into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to press.// ww w . j a va 2 s . co m */ void simulateKeyPress(Key key) { final int x = key.mHitBox.centerX(); final int y = key.mHitBox.centerY(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0); final MotionEvent upEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0); mKeyboardView.onTouchEvent(downEvent); mKeyboardView.onTouchEvent(upEvent); }
From source file:com.android.inputmethod.accessibility.AccessibilityEntityProvider.java
/** * Simulates a key press by injecting touch events into the keyboard view. * This avoids the complexity of trackers and listeners within the keyboard. * * @param key The key to press./*from w w w. ja va2s . co m*/ */ void simulateKeyPress(Key key) { final int x = key.mHitBox.centerX(); final int y = key.mHitBox.centerY(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent downEvent = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_DOWN, x, y, 0); final MotionEvent upEvent = MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, x, y, 0); mKeyboardView.onTouchEvent(downEvent); mKeyboardView.onTouchEvent(upEvent); downEvent.recycle(); upEvent.recycle(); }
From source file:io.appium.uiautomator2.core.AccessibilityNodeInfoDumper.java
public NodeInfoList findNodes(String xpathSelector, boolean multiple) { try {/*from w w w .j a v a 2s . com*/ XPATH.compile(xpathSelector, Filters.element()); } catch (IllegalArgumentException e) { throw new InvalidSelectorException(e); } try { RESOURCES_GUARD.acquire(); } catch (InterruptedException e) { throw new UiAutomator2Exception(e); } uiElementsMapping = new SparseArray<>(); try (InputStream xmlStream = toStream()) { final Document document = SAX_BUILDER.build(xmlStream); final XPathExpression<org.jdom2.Attribute> expr = XPATH .compile(String.format("(%s)/@%s", xpathSelector, UI_ELEMENT_INDEX), Filters.attribute()); final NodeInfoList matchedNodes = new NodeInfoList(); final long timeStarted = SystemClock.uptimeMillis(); for (org.jdom2.Attribute uiElementId : expr.evaluate(document)) { final UiElement uiElement = uiElementsMapping.get(uiElementId.getIntValue()); if (uiElement == null || uiElement.getNode() == null) { continue; } matchedNodes.add(uiElement.getNode()); if (!multiple) { break; } } Logger.debug(String.format("Took %sms to retrieve %s matches for '%s' XPath query", SystemClock.uptimeMillis() - timeStarted, matchedNodes.size(), xpathSelector)); return matchedNodes; } catch (JDOMParseException e) { throw new UiAutomator2Exception(String.format( "%s. " + "Try changing the '%s' driver setting to 'true' in order to workaround the problem.", e.getMessage(), Settings.NORMALIZE_TAG_NAMES.toString()), e); } catch (Exception e) { throw new UiAutomator2Exception(e); } finally { performCleanup(); RESOURCES_GUARD.release(); } }