类android.os.SystemClock源码实例Demo

下面列出了怎么用android.os.SystemClock的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: AudioVideoCodec   文件: AudioCapture.java
@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);
    }
}
 
@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);
}
 
源代码3 项目: guideshow   文件: ViewPager.java
/**
 * 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;
}
 
源代码4 项目: material   文件: Slider.java
@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();
}
 
源代码5 项目: commcare-android   文件: RecordingFragment.java
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();
}
 
源代码6 项目: FireFiles   文件: AsyncTaskLoader.java
@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();
    }
}
 
@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));
}
 
源代码8 项目: mobikul-standalone-pos   文件: CameraSource.java
/**
 * 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();
    }
}
 
源代码9 项目: CSipSimple   文件: PjSipCalls.java
/**
 * 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());
}
 
源代码10 项目: material   文件: Slider.java
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;
    }
}
 
源代码11 项目: AndroidAPS   文件: RFSpyReader.java
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;
}
 
源代码12 项目: 365browser   文件: CustomTabObserver.java
@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;
    }
}
 
源代码13 项目: AndroidRipper   文件: ScreenshotTaker.java
/**
 * 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;
}
 
源代码14 项目: AcDisplay   文件: AlarmSwitch.java
@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();
    }
}
 
@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);
    }
}
 
源代码16 项目: UltimateAndroid   文件: ViewPager.java
/**
 * 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;
}
 
源代码17 项目: cronet   文件: PathUtils.java
/**
 * @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();
            }
        }
    }
}
 
源代码18 项目: android-movies-demo   文件: ViewPager.java
/**
 * 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;
}
 
源代码19 项目: HJMirror   文件: HJInput.java
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;
}
 
源代码20 项目: ankihelper   文件: VerticalViewPager.java
/**
 * 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;
}
 
@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();
}
 
源代码22 项目: AndroidRipper   文件: Waiter.java
/**
 * 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();
		}
	}
}
 
源代码23 项目: AndroidChromium   文件: DeferredStartupHandler.java
/**
 * 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;
        }
    });
}
 
源代码24 项目: YViewPagerDemo   文件: YViewPager.java
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;
}
 
源代码25 项目: 365browser   文件: LocationBarLayout.java
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);
}
 
源代码26 项目: DoraemonKit   文件: Progress.java
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;
}
 
源代码27 项目: Tok-Android   文件: JCameraView.java
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();
}
 
源代码28 项目: Indic-Keyboard   文件: ContactsContentObserver.java
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;
}
 
源代码29 项目: PUMA   文件: LaunchApp.java
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);
	}
}
 
源代码30 项目: MyHearts   文件: LoginActivity.java
@Override
protected void doComplete(JSONObject values) {
    Log.d(TAG, "ruolanmingyue:" + values);
    Log.d("SDKQQAgentPref", "AuthorSwitch_SDK:" + SystemClock.elapsedRealtime());
    initOpenidAndToken(values);

    //下面的这个必须放到这个地方,要不然就会出错   哎,,,,,调整了近一个小时,,,,我是服我自己了
    updateUserInfo();
}
 
 类所在包
 同包方法