Example usage for android.os SystemClock uptimeMillis

List of usage examples for android.os SystemClock uptimeMillis

Introduction

In this page you can find the example usage for android.os SystemClock uptimeMillis.

Prototype

@CriticalNative
native public static long uptimeMillis();

Source Link

Document

Returns milliseconds since boot, not counting time spent in deep sleep.

Usage

From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java

private boolean isInitialBroadcast() {
    return (SystemClock.uptimeMillis() - mCreateTime) < 1000;
}

From source file:io.codetail.animation.AnimationHandler.java

/**
 * Register to get a callback on the next frame after the delay.
 *///  w  ww .  java  2s  .  c  o  m
public void addAnimationFrameCallback(final AnimationFrameCallback callback, long delay) {
    if (mAnimationCallbacks.size() == 0) {
        getProvider().postFrameCallback(mFrameCallback);
    }
    if (!mAnimationCallbacks.contains(callback)) {
        mAnimationCallbacks.add(callback);
    }

    if (delay > 0) {
        mDelayedCallbackStartTime.put(callback, (SystemClock.uptimeMillis() + delay));
    }
}

From source file:com.tapcentive.sdk.touchpoint.nfc.SEManager.java

/**
 * Select tapcentive.// www .  jav a  2s  . c om
 *
 * @return the select response
 */
public SelectResponse selectTapcentive() {
    long time1 = SystemClock.uptimeMillis();
    byte[] responseBuffer = sendAndReceive(selectTapCentive);

    long time2 = SystemClock.uptimeMillis();
    Log.d(TAG, "TIME: selectTapcentive:sendAndReceive: " + (time2 - time1));
    SelectResponse selectResponse = new SelectResponse(responseBuffer);
    long time3 = SystemClock.uptimeMillis();
    Log.d(TAG, "TIME: selectTapcentive:new SelectResponse: " + (time3 - time2));
    return selectResponse;
}

From source file:com.exzogeni.dk.http.HttpTask.java

@Override
public V call() throws Exception {
    final long startTime = SystemClock.uptimeMillis();
    try {// www  .j  a  v  a2 s.com
        final URI uri = getEncodedUriInternal();
        if (mCachePolicy == null || mCachePolicy.shouldCache(uri)) {
            final CacheManager cm = mHttpManager.getCacheManager();
            final Map<String, List<String>> headers = new HashMap<>();
            final InputStream content = cm.get(uri, headers);
            if (content != null) {
                return onSuccessInternal(HttpURLConnection.HTTP_NOT_MODIFIED,
                        Collections.<String, List<String>>emptyMap(), content);
            } else {
                mHeaders.putAll(headers);
            }
        }
        return onPerformNetworkRequest(uri);
    } finally {
        mHttpManager.log(this, (SystemClock.uptimeMillis() - startTime),
                HttpStatus.getStatusLine(mStatusCode.get()));
    }
}

From source file:org.mtransit.android.ui.view.map.impl.MarkerManager.java

public void onAnimateMarkerPosition(DelegatingMarker marker, LatLng target, AnimationSettings settings,
        IMarker.AnimationCallback callback) {
    markerAnimator.cancelAnimation(marker, IMarker.AnimationCallback.CancelReason.ANIMATE_POSITION);
    markerAnimator.animate(marker, marker.getPosition(), target, SystemClock.uptimeMillis(), settings,
            callback);//  ww  w .  j ava 2s . c o  m
}

From source file:com.google.android.apps.forscience.ble.DeviceDiscoverer.java

protected void addOrUpdateDevice(WhistlepunkBleDevice device, int rssi, String longName) {
    DeviceRecord deviceRecord = mDevices.get(device.getAddress());
    boolean previouslyFound = deviceRecord != null;
    if (!previouslyFound) {
        deviceRecord = new DeviceRecord();
        deviceRecord.device = device;/*w w  w  .  j a v  a2s  .c o m*/
        mDevices.put(device.getAddress(), deviceRecord);
        deviceRecord.mLongName = longName;
    }
    // Update the last RSSI and last seen
    deviceRecord.lastRssi = rssi;
    deviceRecord.lastSeenTimestampMs = SystemClock.uptimeMillis();

    if (!previouslyFound && mCallback != null) {
        mCallback.onDeviceFound(deviceRecord);
    }
}

From source file:com.jakewharton.behavior.drawer.BehaviorDelegate.java

private void cancelChildViewTouch() {
    // Cancel child touches
    if (!childrenCanceledTouch) {
        final long now = SystemClock.uptimeMillis();
        final MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0);
        final int childCount = parent.getChildCount();
        for (int i = 0; i < childCount; i++) {
            parent.getChildAt(i).dispatchTouchEvent(cancelEvent);
        }// w ww. j a va  2  s .  co m
        cancelEvent.recycle();
        childrenCanceledTouch = true;
    }
}

From source file:com.commonsware.andprojector.ProjectorService.java

void updateImage(byte[] newPng) {
    latestPng.set(newPng);/*from  w  ww . ja va2  s .c o  m*/

    for (WebSocket socket : getWebSockets()) {
        socket.send("screen/" + Long.toString(SystemClock.uptimeMillis()));
    }
}

From source file:android.support.animation.AnimationHandler.java

/**
 * Register to get a callback on the next frame after the delay.
 *//*from  w w  w  .  java 2 s  .com*/
public void addAnimationFrameCallback(final AnimationFrameCallback callback, long delay) {
    if (mAnimationCallbacks.size() == 0) {
        getProvider().postFrameCallback();
    }
    if (!mAnimationCallbacks.contains(callback)) {
        mAnimationCallbacks.add(callback);
    }

    if (delay > 0) {
        mDelayedCallbackStartTime.put(callback, (SystemClock.uptimeMillis() + delay));
    }
}

From source file:android.support.wear.widget.util.ArcSwipe.java

private Swiper.Status sendArcSwipe(UiController uiController, float[] startCoordinates, float[] endCoordinates,
        float[] precision, int duration, boolean isClockwise) {

    float[][] steps = interpolate(startCoordinates, endCoordinates, SWIPE_EVENT_COUNT, isClockwise);
    final int delayBetweenMovements = duration / steps.length;

    MotionEvent downEvent = MotionEvents.sendDown(uiController, startCoordinates, precision).down;
    try {// ww  w.j  a  v a 2 s.co m
        for (int i = 0; i < steps.length; i++) {
            if (!MotionEvents.sendMovement(uiController, downEvent, steps[i])) {
                Log.e(TAG, "Injection of move event as part of the swipe failed. Sending cancel " + "event.");
                MotionEvents.sendCancel(uiController, downEvent);
                return Swiper.Status.FAILURE;
            }

            long desiredTime = downEvent.getDownTime() + delayBetweenMovements * i;
            long timeUntilDesired = desiredTime - SystemClock.uptimeMillis();
            if (timeUntilDesired > 10) {
                uiController.loopMainThreadForAtLeast(timeUntilDesired);
            }
        }

        if (!MotionEvents.sendUp(uiController, downEvent, endCoordinates)) {
            Log.e(TAG, "Injection of up event as part of the swipe failed. Sending cancel event.");
            MotionEvents.sendCancel(uiController, downEvent);
            return Swiper.Status.FAILURE;
        }
    } finally {
        downEvent.recycle();
    }
    return Swiper.Status.SUCCESS;
}