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 Project: AudioVideoCodec Author: MannaYang File: AudioCapture.java License: 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 #2
Source Project: react-native-GPay Author: hellochirag File: ReactOkHttpNetworkFetcher.java License: 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 #3
Source Project: guideshow Author: javajavadog File: ViewPager.java License: 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 #4
Source Project: material Author: rey5137 File: Slider.java License: 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 #5
Source Project: commcare-android Author: dimagi File: RecordingFragment.java License: 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 #6
Source Project: FireFiles Author: gigabytedevelopers File: AsyncTaskLoader.java License: 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 #7
Source Project: appium-uiautomator2-server Author: appium File: LongPressKeyCode.java License: 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 #8
Source Project: mobikul-standalone-pos Author: webkul File: CameraSource.java License: 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 #9
Source Project: CSipSimple Author: treasure-lau File: PjSipCalls.java License: 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 #10
Source Project: material Author: rey5137 File: Slider.java License: 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 #11
Source Project: AndroidAPS Author: MilosKozak File: RFSpyReader.java License: 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 #12
Source Project: 365browser Author: mogoweb File: CustomTabObserver.java License: 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 #13
Source Project: AndroidRipper Author: reverse-unina File: ScreenshotTaker.java License: 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 #14
Source Project: AcDisplay Author: AChep File: AlarmSwitch.java License: 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 #15
Source Project: android-gif-drawable-eclipse-sample Author: koral-- File: RenderTask.java License: 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 #16
Source Project: UltimateAndroid Author: cymcsg File: ViewPager.java License: 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 #17
Source Project: cronet Author: lizhangqu File: PathUtils.java License: 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 #18
Source Project: android-movies-demo Author: dlew File: ViewPager.java License: 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 #19
Source Project: HJMirror Author: wejoy File: HJInput.java License: 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 #20
Source Project: ankihelper Author: mmjang File: VerticalViewPager.java License: 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 #21
Source Project: android_9.0.0_r45 Author: lulululbj File: AutomaticBrightnessController.java License: 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 #22
Source Project: AndroidRipper Author: reverse-unina File: Waiter.java License: 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 #23
Source Project: AndroidChromium Author: JackyAndroid File: DeferredStartupHandler.java License: 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 #24
Source Project: YViewPagerDemo Author: youngkaaa File: YViewPager.java License: 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 #25
Source Project: 365browser Author: mogoweb File: LocationBarLayout.java License: 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 #26
Source Project: DoraemonKit Author: didi File: Progress.java License: 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 #27
Source Project: Tok-Android Author: InsightIM File: JCameraView.java License: GNU General Public License v3.0 | 5 votes |
public void onResume() { SystemClock.sleep(500); if (mCamera == null) { getCamera(SELECTED_CAMERA); if (needSetVisible && mVideoView != null) { mVideoView.setVisibility(View.VISIBLE); } else { needSetVisible = true; } if (mHolder != null && !isPre) { setStartPreview(mCamera, mHolder); } } wakeLock.acquire(); }
Example #28
Source Project: Indic-Keyboard Author: smc File: ContactsContentObserver.java License: Apache License 2.0 | 5 votes |
boolean haveContentsChanged() { if (!PermissionsUtil.checkAllPermissionsGranted( mContext, Manifest.permission.READ_CONTACTS)) { Log.i(TAG, "No permission to read contacts. Marking contacts as not changed."); return false; } final long startTime = SystemClock.uptimeMillis(); final int contactCount = mManager.getContactCount(); if (contactCount > ContactsDictionaryConstants.MAX_CONTACTS_PROVIDER_QUERY_LIMIT) { // If there are too many contacts then return false. In this rare case it is impossible // to include all of them anyways and the cost of rebuilding the dictionary is too high. // TODO: Sort and check only the most recent contacts? return false; } if (contactCount != mManager.getContactCountAtLastRebuild()) { if (DebugFlags.DEBUG_ENABLED) { Log.d(TAG, "haveContentsChanged() : Count changed from " + mManager.getContactCountAtLastRebuild() + " to " + contactCount); } return true; } final ArrayList<String> names = mManager.getValidNames(Contacts.CONTENT_URI); if (names.hashCode() != mManager.getHashCodeAtLastRebuild()) { return true; } if (DebugFlags.DEBUG_ENABLED) { Log.d(TAG, "haveContentsChanged() : No change detected in " + (SystemClock.uptimeMillis() - startTime) + " ms)"); } return false; }
Example #29
Source Project: PUMA Author: USC-NSL File: LaunchApp.java License: Apache License 2.0 | 5 votes |
private void waitForNetworkUpdate(long idleTimeoutMillis, long globalTimeoutMillis) { final long startTimeMillis = SystemClock.uptimeMillis(); long prevTraffic = TrafficStats.getUidTxBytes(uid) + TrafficStats.getUidRxBytes(uid); boolean idleDetected = false; long totTraffic = 0; while (!idleDetected) { final long elapsedTimeMillis = SystemClock.uptimeMillis() - startTimeMillis; final long remainingTimeMillis = globalTimeoutMillis - elapsedTimeMillis; if (remainingTimeMillis <= 0) { Util.err("NO_IDLE_TIMEOUT: " + globalTimeoutMillis); break; } try { Thread.sleep(idleTimeoutMillis); long currTraffic = TrafficStats.getUidTxBytes(uid) + TrafficStats.getUidRxBytes(uid); long delta = currTraffic - prevTraffic; if (delta > 0) { totTraffic += delta; prevTraffic = currTraffic; } else { // idle detected idleDetected = true; } } catch (InterruptedException ie) { /* ignore */ } } if (idleDetected) { Util.log("Traffic: " + totTraffic); } }
Example #30
Source Project: MyHearts Author: wuyinlei File: LoginActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void doComplete(JSONObject values) { Log.d(TAG, "ruolanmingyue:" + values); Log.d("SDKQQAgentPref", "AuthorSwitch_SDK:" + SystemClock.elapsedRealtime()); initOpenidAndToken(values); //下面的这个必须放到这个地方,要不然就会出错 哎,,,,,调整了近一个小时,,,,我是服我自己了 updateUserInfo(); }