android.os.SystemClock Java Examples
The following examples show how to use
android.os.SystemClock.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlarmSwitch.java From AcDisplay with GNU General Public License v2.0 | 6 votes |
@Override public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.contains(ALARM_ALERT)) { // Hide the keyguard mActive = false; mAlarmingTimestamp = SystemClock.elapsedRealtime(); requestInactive(); } else if (action.contains(ALARM_DISMISS) || action.contains(ALARM_SNOOZE) || action.contains(ALARM_DONE)) { // Show the keyguard mActive = true; requestActive(); } else if (mActive) { // Get mad Log.w(TAG, "Received an unknown intent=" + intent.getAction() + " re-enabling the switch."); // Show the keyguard mActive = true; requestActive(); } }
Example #2
Source File: LocationBarLayout.java From 365browser with Apache License 2.0 | 6 votes |
private void loadUrlFromOmniboxMatch(String url, int transition, int matchPosition, int type) { // loadUrl modifies AutocompleteController's state clearing the native // AutocompleteResults needed by onSuggestionsSelected. Therefore, // loadUrl should should be invoked last. Tab currentTab = getCurrentTab(); String currentPageUrl = getCurrentTabUrl(); WebContents webContents = currentTab != null ? currentTab.getWebContents() : null; long elapsedTimeSinceModified = mNewOmniboxEditSessionTimestamp > 0 ? (SystemClock.elapsedRealtime() - mNewOmniboxEditSessionTimestamp) : -1; boolean shouldSkipNativeLog = mShowCachedZeroSuggestResults && (mDeferredOnSelection != null) && !mDeferredOnSelection.shouldLog(); if (!shouldSkipNativeLog) { mAutocomplete.onSuggestionSelected(matchPosition, type, currentPageUrl, mUrlFocusedFromFakebox, elapsedTimeSinceModified, mUrlBar.getAutocompleteLength(), webContents); } loadUrl(url, transition); }
Example #3
Source File: Progress.java From DoraemonKit with Apache License 2.0 | 6 votes |
public static Progress changeProgress(final Progress progress, long writeSize, long totalSize, final Action action) { progress.totalSize = totalSize; progress.currentSize += writeSize; progress.tempSize += writeSize; long currentTime = SystemClock.elapsedRealtime(); boolean isNotify = (currentTime - progress.lastRefreshTime) >= DokitOkGo.REFRESH_TIME; if (isNotify || progress.currentSize == totalSize) { long diffTime = currentTime - progress.lastRefreshTime; if (diffTime == 0) diffTime = 1; progress.fraction = progress.currentSize * 1.0f / totalSize; progress.speed = progress.bufferSpeed(progress.tempSize * 1000 / diffTime); progress.lastRefreshTime = currentTime; progress.tempSize = 0; if (action != null) { action.call(progress); } } return progress; }
Example #4
Source File: AutomaticBrightnessController.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public String toString() { StringBuffer buf = new StringBuffer(); buf.append('['); for (int i = 0; i < mCount; i++) { final long next = i + 1 < mCount ? getTime(i + 1) : SystemClock.uptimeMillis(); if (i != 0) { buf.append(", "); } buf.append(getLux(i)); buf.append(" / "); buf.append(next - getTime(i)); buf.append("ms"); } buf.append(']'); return buf.toString(); }
Example #5
Source File: Slider.java From material with Apache License 2.0 | 6 votes |
@Override public void run() { long curTime = SystemClock.uptimeMillis(); float progress = Math.min(1f, (float)(curTime - mStartTime) / mTransformAnimationDuration); float value = mInterpolator.getInterpolation(progress); mThumbFillPercent = mAlwaysFillThumb ? 1 : ((mFillPercent - mStartFillPercent) * value + mStartFillPercent); if(progress == 1f) stopAnimation(); if(mRunning) { if(getHandler() != null) getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); else stopAnimation(); } invalidate(); }
Example #6
Source File: AudioCapture.java From AudioVideoCodec with Apache License 2.0 | 6 votes |
@Override public void run() { while (!isStopRecord) { byte[] buffer = new byte[bufferSize]; int readRecord = audioRecord.read(buffer, 0, bufferSize); if (readRecord > 0) { if (captureListener != null) captureListener.onCaptureListener(buffer,readRecord); if (isDebug) { Log.d(TAG, "音频采集数据源 -- ".concat(String.valueOf(readRecord)).concat(" -- bytes")); } } else { if (isDebug) Log.d(TAG, "录音采集异常"); } //延迟写入 SystemClock -- Android专用 SystemClock.sleep(10); } }
Example #7
Source File: DeferredStartupHandler.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * Add the idle handler which will run deferred startup tasks in sequence when idle. This can * be called multiple times by different activities to schedule their own deferred startup * tasks. */ public void queueDeferredTasksOnIdleHandler() { mMaxTaskDuration = 0; mDeferredStartupDuration = 0; Looper.myQueue().addIdleHandler(new MessageQueue.IdleHandler() { @Override public boolean queueIdle() { Runnable currentTask = mDeferredTasks.poll(); if (currentTask == null) { if (mDeferredStartupInitializedForApp) { mDeferredStartupCompletedForApp = true; recordDeferredStartupStats(); } return false; } long startTime = SystemClock.uptimeMillis(); currentTask.run(); long timeTaken = SystemClock.uptimeMillis() - startTime; mMaxTaskDuration = Math.max(mMaxTaskDuration, timeTaken); mDeferredStartupDuration += timeTaken; return true; } }); }
Example #8
Source File: VerticalViewPager.java From ankihelper with GNU General Public License v3.0 | 6 votes |
/** * Start a fake drag of the pager. * <p> * <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> * <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); 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; }
Example #9
Source File: ReactOkHttpNetworkFetcher.java From react-native-GPay with MIT License | 6 votes |
@Override public void fetch(final OkHttpNetworkFetcher.OkHttpNetworkFetchState fetchState, final NetworkFetcher.Callback callback) { fetchState.submitTime = SystemClock.elapsedRealtime(); final Uri uri = fetchState.getUri(); Map<String, String> requestHeaders = null; if (fetchState.getContext().getImageRequest() instanceof ReactNetworkImageRequest) { ReactNetworkImageRequest networkImageRequest = (ReactNetworkImageRequest) fetchState.getContext().getImageRequest(); requestHeaders = getHeaders(networkImageRequest.getHeaders()); } if (requestHeaders == null) { requestHeaders = Collections.emptyMap(); } final Request request = new Request.Builder() .cacheControl(new CacheControl.Builder().noStore().build()) .url(uri.toString()) .headers(Headers.of(requestHeaders)) .get() .build(); fetchWithRequest(fetchState, callback, request); }
Example #10
Source File: YViewPager.java From YViewPagerDemo with Apache License 2.0 | 6 votes |
public boolean beginFakeDrag() { if (mIsBeingDragged) { return false; } mFakeDragging = true; setScrollState(SCROLL_STATE_DRAGGING); mInitialMotionX = mLastMotionX = 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; }
Example #11
Source File: ViewPager.java From guideshow with MIT License | 6 votes |
/** * Start a fake drag of the pager. * * <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); mInitialMotionX = mLastMotionX = 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; }
Example #12
Source File: Waiter.java From AndroidRipper with GNU Affero General Public License v3.0 | 6 votes |
/** * Waits for a web element. * * @param by the By object. Examples are By.id("id") and By.name("name") * @param minimumNumberOfMatches the minimum number of matches that are expected to be shown. {@code 0} means any number of matches * @param timeout the the amount of time in milliseconds to wait * @param scroll {@code true} if scrolling should be performed */ public WebElement waitForWebElement(final By by, int minimumNumberOfMatches, int timeout, boolean scroll){ final long endTime = SystemClock.uptimeMillis() + timeout; while (true) { final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ searcher.logMatchesFound(by.getValue()); return null; } sleeper.sleep(); WebElement webElementToReturn = searcher.searchForWebElement(by, minimumNumberOfMatches); if(webElementToReturn != null) return webElementToReturn; if(scroll) { scroller.scrollDown(); } } }
Example #13
Source File: HJInput.java From HJMirror with MIT License | 6 votes |
public boolean sendMotionEvent(int inputSource, int action, float x, float y) { if (mInputManager == null || mInjectInputEventMethod == null) { return false; } try { long when = SystemClock.uptimeMillis(); MotionEvent event = MotionEvent.obtain(when, when, action, x, y, 1.0f, 1.0f, 0, 1.0f, 1.0f, 0, 0); event.setSource(inputSource); mInjectInputEventMethod.invoke(mInputManager, event, 0); event.recycle(); return true; } catch (Exception e) { HJLog.e(e); } return false; }
Example #14
Source File: ViewPager.java From android-movies-demo with MIT License | 6 votes |
/** * Start a fake drag of the pager. * * <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); mInitialMotionX = mLastMotionX = 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; }
Example #15
Source File: LongPressKeyCode.java From appium-uiautomator2-server with Apache License 2.0 | 6 votes |
@Override protected AppiumResponse safeHandle(IHttpRequest request) { final KeyCodeModel model = toModel(request, KeyCodeModel.class); final int keyCode = model.keycode; int metaState = model.metastate == null ? 0 : model.metastate; int flags = model.flags == null ? 0 : model.flags; final long downTime = SystemClock.uptimeMillis(); final InteractionController interactionController = UiAutomatorBridge.getInstance().getInteractionController(); boolean isSuccessful = interactionController.injectEventSync(new KeyEvent(downTime, downTime, KeyEvent.ACTION_DOWN, keyCode, 0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags)); // https://android.googlesource.com/platform/frameworks/base.git/+/9d83b4783c33f1fafc43f367503e129e5a5047fa%5E%21/#F0 isSuccessful &= interactionController.injectEventSync(new KeyEvent(downTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_DOWN, keyCode, 1, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags | KeyEvent.FLAG_LONG_PRESS)); isSuccessful &= interactionController.injectEventSync(new KeyEvent(downTime, SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, keyCode, 0, metaState, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags)); if (!isSuccessful) { throw new InvalidElementStateException("Cannot inject long press event for key code " + keyCode); } return new AppiumResponse(getSessionId(request)); }
Example #16
Source File: RenderTask.java From android-gif-drawable-eclipse-sample with MIT License | 6 votes |
@Override public void doWork() { final long invalidationDelay = mGifDrawable.mNativeInfoHandle.renderFrame(mGifDrawable.mBuffer); if (invalidationDelay >= 0) { mGifDrawable.mNextFrameRenderTime = SystemClock.uptimeMillis() + invalidationDelay; if (mGifDrawable.isVisible()) { if (mGifDrawable.mIsRunning && !mGifDrawable.mIsRenderingTriggeredOnDraw) { mGifDrawable.mExecutor.remove(this); mGifDrawable.mSchedule = mGifDrawable.mExecutor.schedule(this, invalidationDelay, TimeUnit.MILLISECONDS); } } if (!mGifDrawable.mListeners.isEmpty() && mGifDrawable.getCurrentFrameIndex() == mGifDrawable.mNativeInfoHandle.frameCount - 1) { mGifDrawable.scheduleSelf(mNotifyListenersTask, mGifDrawable.mNextFrameRenderTime); } } else { mGifDrawable.mNextFrameRenderTime = Long.MIN_VALUE; mGifDrawable.mIsRunning = false; } if (mGifDrawable.isVisible() && !mGifDrawable.mInvalidationHandler.hasMessages(0)) { mGifDrawable.mInvalidationHandler.sendEmptyMessageAtTime(0, 0); } }
Example #17
Source File: ScreenshotTaker.java From AndroidRipper with GNU Affero General Public License v3.0 | 6 votes |
/** * Gets the proper view to use for a screenshot. */ private View getScreenshotView() { View decorView = viewFetcher.getRecentDecorView(viewFetcher.getWindowDecorViews()); final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); while (decorView == null) { final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ return null; } sleeper.sleepMini(); decorView = viewFetcher.getRecentDecorView(viewFetcher.getWindowDecorViews()); } wrapAllGLViews(decorView); return decorView; }
Example #18
Source File: ViewPager.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * Start a fake drag of the pager. * * <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); mInitialMotionX = mLastMotionX = 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; }
Example #19
Source File: CustomTabObserver.java From 365browser with Apache License 2.0 | 6 votes |
@Override public void onPageLoadStarted(Tab tab, String url) { if (mCurrentState == STATE_WAITING_LOAD_START) { mPageLoadStartedTimestamp = SystemClock.elapsedRealtime(); mCurrentState = STATE_WAITING_LOAD_FINISH; } else if (mCurrentState == STATE_WAITING_LOAD_FINISH) { if (mCustomTabsConnection != null) { mCustomTabsConnection.notifyNavigationEvent( mSession, CustomTabsCallback.NAVIGATION_ABORTED); mCustomTabsConnection.sendNavigationInfo( mSession, tab.getUrl(), tab.getTitle(), null); } mPageLoadStartedTimestamp = SystemClock.elapsedRealtime(); } if (mCustomTabsConnection != null) { mCustomTabsConnection.setSendNavigationInfoForSession(mSession, false); mCustomTabsConnection.notifyNavigationEvent( mSession, CustomTabsCallback.NAVIGATION_STARTED); mScreenshotTakenForCurrentNavigation = false; } }
Example #20
Source File: RFSpyReader.java From AndroidAPS with GNU Affero General Public License v3.0 | 6 votes |
public byte[] poll(int timeout_ms) { if (isLogEnabled()) LOG.trace(ThreadUtil.sig() + "Entering poll at t==" + SystemClock.uptimeMillis() + ", timeout is " + timeout_ms + " mDataQueue size is " + mDataQueue.size()); if (mDataQueue.isEmpty()) try { // block until timeout or data available. // returns null if timeout. byte[] dataFromQueue = mDataQueue.poll(timeout_ms, TimeUnit.MILLISECONDS); if (dataFromQueue != null) { if (isLogEnabled()) LOG.debug("Got data [" + ByteUtil.shortHexString(dataFromQueue) + "] at t==" + SystemClock.uptimeMillis()); } else { if (isLogEnabled()) LOG.debug("Got data [null] at t==" + SystemClock.uptimeMillis()); } return dataFromQueue; } catch (InterruptedException e) { LOG.error("poll: Interrupted waiting for data"); } return null; }
Example #21
Source File: PathUtils.java From cronet with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @return the public downloads directory. */ @SuppressWarnings("unused") @CalledByNative private static String getDownloadsDirectory() { // Temporarily allowing disk access while fixing. TODO: http://crbug.com/508615 StrictModeContext unused = null; try { unused = StrictModeContext.allowDiskReads(); long time = SystemClock.elapsedRealtime(); String downloadsPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) .getPath(); RecordHistogram.recordTimesHistogram("Android.StrictMode.DownloadsDir", SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS); return downloadsPath; } finally { if (unused != null) { try { unused.close(); } catch (Exception e) { e.printStackTrace(); } } } }
Example #22
Source File: Slider.java From material with Apache License 2.0 | 6 votes |
public boolean startAnimation(int radius) { if(mThumbCurrentRadius == radius) return false; mRadius = radius; if(getHandler() != null){ resetAnimation(); mRunning = true; getHandler().postAtTime(this, SystemClock.uptimeMillis() + ViewUtil.FRAME_DURATION); invalidate(); return true; } else { mThumbCurrentRadius = mRadius; invalidate(); return false; } }
Example #23
Source File: PjSipCalls.java From CSipSimple with GNU General Public License v3.0 | 6 votes |
/** * Copy infos from pjsua call info object to SipCallSession object * * @param session the session to copy info to (output) * @param pjCallInfo the call info from pjsip * @param service PjSipService Sip service to retrieve pjsip accounts infos */ private static void updateSession(SipCallSessionImpl session, pjsua_call_info pjCallInfo, Context context) { // Should be unecessary cause we usually copy infos from a valid session.setCallId(pjCallInfo.getId()); // Nothing to think about here cause we have a // bijection between int / state session.setCallState(pjCallInfo.getState().swigValue()); session.setMediaStatus(pjCallInfo.getMedia_status().swigValue()); session.setRemoteContact(PjSipService.pjStrToString(pjCallInfo.getRemote_info())); session.setConfPort(pjCallInfo.getConf_slot()); // Try to retrieve sip account related to this call int pjAccId = pjCallInfo.getAcc_id(); session.setAccId(PjSipService.getAccountIdForPjsipId(context, pjAccId)); pj_time_val duration = pjCallInfo.getConnect_duration(); session.setConnectStart(SystemClock.elapsedRealtime() - duration.getSec() * 1000 - duration.getMsec()); }
Example #24
Source File: CameraSource.java From mobikul-standalone-pos with MIT License | 6 votes |
/** * Sets the frame data received from the camera. This adds the previous unused frame buffer * (if present) back to the camera, and keeps a pending reference to the frame data for * future use. */ void setNextFrame(byte[] data, Camera camera) { synchronized (mLock) { if (mPendingFrameData != null) { camera.addCallbackBuffer(mPendingFrameData.array()); mPendingFrameData = null; } if (!mBytesToByteBuffer.containsKey(data)) { Log.d(TAG, "Skipping frame. Could not find ByteBuffer associated with the image " + "data from the camera."); return; } // Timestamp and frame ID are maintained here, which will give downstream code some // idea of the timing of frames received and when frames were dropped along the way. mPendingTimeMillis = SystemClock.elapsedRealtime() - mStartTimeMillis; mPendingFrameId++; mPendingFrameData = mBytesToByteBuffer.get(data); // Notify the processor thread if it is waiting on the next frame (see below). mLock.notifyAll(); } }
Example #25
Source File: AsyncTaskLoader.java From FireFiles with Apache License 2.0 | 6 votes |
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) void dispatchOnCancelled(LoadTask task, D data) { onCanceled(data); if (mCancellingTask == task) { if (DEBUG) Log.v(TAG, "Cancelled task is now canceled!"); if(Utils.hasJellyBeanMR2()){ rollbackContentChanged(); } mLastLoadCompleteTime = SystemClock.uptimeMillis(); mCancellingTask = null; if (DEBUG) Log.v(TAG, "Delivering cancellation"); if(Utils.hasJellyBeanMR2()){ deliverCancellation(); } executePendingTask(); } }
Example #26
Source File: RecordingFragment.java From commcare-android with Apache License 2.0 | 6 votes |
private void startRecording() { disableScreenRotation((Activity)getContext()); setCancelable(false); setupRecorder(); recorder.start(); toggleRecording.setOnClickListener(v -> stopRecording()); toggleRecording.setBackgroundResource(R.drawable.record_in_progress); instruction.setText(Localization.get("during.recording")); recordingProgress.setVisibility(View.VISIBLE); recordingDuration.setVisibility(View.VISIBLE); recordingDuration.setBase(SystemClock.elapsedRealtime()); recordingDuration.start(); }
Example #27
Source File: MyInteractionController.java From PUMA with Apache License 2.0 | 5 votes |
private boolean touchDown(int x, int y) { if (DEBUG) { Log.d(LOG_TAG, "touchDown (" + x + ", " + y + ")"); } mDownTime = SystemClock.uptimeMillis(); MotionEvent event = MotionEvent.obtain(mDownTime, mDownTime, MotionEvent.ACTION_DOWN, x, y, 1); event.setSource(InputDevice.SOURCE_TOUCHSCREEN); return injectEventSync(event); }
Example #28
Source File: GifFrameLoader.java From giffun with Apache License 2.0 | 5 votes |
private void loadNextFrame() { if (!isRunning || isLoadPending) { return; } isLoadPending = true; gifDecoder.advance(); long targetTime = SystemClock.uptimeMillis() + gifDecoder.getNextDelay(); DelayTarget next = new DelayTarget(handler, gifDecoder.getCurrentFrameIndex(), targetTime); requestBuilder .signature(new FrameSignature()) .into(next); }
Example #29
Source File: IcsProgressBar.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
@Override protected synchronized void onDraw(Canvas canvas) { super.onDraw(canvas); Drawable d = mCurrentDrawable; if (d != null) { // Translate canvas so a indeterminate circular progress bar with padding // rotates properly in its animation canvas.save(); canvas.translate(getPaddingLeft() + mIndeterminateRealLeft, getPaddingTop() + mIndeterminateRealTop); long time = getDrawingTime(); if (mAnimation != null) { mAnimation.getTransformation(time, mTransformation); float scale = mTransformation.getAlpha(); try { mInDrawing = true; d.setLevel((int) (scale * MAX_LEVEL)); } finally { mInDrawing = false; } if (SystemClock.uptimeMillis() - mLastDrawTime >= mAnimationResolution) { mLastDrawTime = SystemClock.uptimeMillis(); postInvalidateDelayed(mAnimationResolution); } } d.draw(canvas); canvas.restore(); if (mShouldStartAnimationDrawable && d instanceof Animatable) { ((Animatable) d).start(); mShouldStartAnimationDrawable = false; } } }
Example #30
Source File: InstallerDelegate.java From delion with Apache License 2.0 | 5 votes |
/** * Don't call this directly; instead, call {@link #start()}. */ @Override public void run() { boolean isInstalled = isInstalled(); boolean waitedTooLong = (SystemClock.elapsedRealtime() - mTimestampStarted) > mMsMaximumWaitingTime; if (isInstalled || !mIsRunning || waitedTooLong) { mObserver.onInstallFinished(this, isInstalled); mIsRunning = false; } else { mHandler.postDelayed(this, mMsBetweenRuns); } }