List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:Main.java
/** * Starts an AnimationDrawable animation at the specified point in the future. * @param handler The Handler for the Activity in which the animation will run. * @param drawable The AnimationDrawable that will have its animation started. * @param millisFromNow The number of milliseconds to wait before starting this animation. *//*ww w . ja v a 2 s . c om*/ public static void startAnimationInFuture(final Handler handler, final AnimationDrawable drawable, long millisFromNow) { handler.postAtTime(new Runnable() { @Override public void run() { drawable.start(); } }, SystemClock.uptimeMillis() + millisFromNow); }
From source file:org.lol.reddit.common.General.java
public static boolean onBackPressed() { if (lastBackPress < SystemClock.uptimeMillis() - 300) { lastBackPress = SystemClock.uptimeMillis(); return true; }//w w w . j a va 2 s . co m return false; }
From source file:pl.mg6.newmaps.demo.ManyMarkersExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.many_markers_example); GoogleMap map = GoogleMapHelper.getMap(this, R.id.many_markers_map); Random r = new Random(); long start = SystemClock.uptimeMillis(); for (int i = 0; i < MARKERS_COUNT; i++) { LatLng position = new LatLng((r.nextDouble() - 0.5) * 170.0, (r.nextDouble() - 0.5) * 360.0); map.addMarker(new MarkerOptions().position(position)); }// w w w.ja v a2 s. c o m long end = SystemClock.uptimeMillis(); Log.w(TAG, "addMarkers time: " + (end - start)); }
From source file:com.android.example.github.util.RateLimiter.java
private long now() { return SystemClock.uptimeMillis(); }
From source file:com.android.talkback.formatter.ScrollFormatter.java
@Override public boolean format(AccessibilityEvent event, TalkBackService context, Utterance utterance) { final long currentTime = SystemClock.uptimeMillis(); if ((currentTime - mLastScrollEvent) < MIN_SCROLL_INTERVAL) { // TODO: We shouldn't just reject events, since we'll get weird // rhythms when scrolling, e.g. if we're getting an event every // 300ms and we reject at the 250ms mark. return false; }/*from ww w . j a v a 2 s. c o m*/ mLastScrollEvent = currentTime; final float percent = getScrollPercent(event); final float rate = (float) Math.pow(2.0, (percent / 50.0) - 1); utterance.addAuditory(R.raw.scroll_tone); utterance.getMetadata().putFloat(Utterance.KEY_METADATA_EARCON_RATE, rate); utterance.addSpokenFlag(FeedbackItem.FLAG_NO_SPEECH); return true; }
From source file:com.android.screenspeak.formatter.ScrollFormatter.java
@Override public boolean format(AccessibilityEvent event, ScreenSpeakService context, Utterance utterance) { final long currentTime = SystemClock.uptimeMillis(); if ((currentTime - mLastScrollEvent) < MIN_SCROLL_INTERVAL) { // TODO: We shouldn't just reject events, since we'll get weird // rhythms when scrolling, e.g. if we're getting an event every // 300ms and we reject at the 250ms mark. return false; }/* w ww. ja v a2 s . c o m*/ mLastScrollEvent = currentTime; final float percent = getScrollPercent(event); final float rate = (float) Math.pow(2.0, (percent / 50.0) - 1); utterance.addAuditory(R.raw.scroll_tone); utterance.getMetadata().putFloat(Utterance.KEY_METADATA_EARCON_RATE, rate); utterance.addSpokenFlag(FeedbackItem.FLAG_NO_SPEECH); return true; }
From source file:com.android.screenspeak.PasteHistory.java
/** * Stores the start time for a paste action. This should be called immediately before * {@link AccessibilityNodeInfoCompat#performAction}. *///from w ww . j av a 2s .c o m public void before() { mStartTime = SystemClock.uptimeMillis(); }
From source file:com.google.android.marvin.mytalkback.formatter.ScrollFormatter.java
@Override public boolean format(AccessibilityEvent event, TalkBackService context, Utterance utterance) { final long currentTime = SystemClock.uptimeMillis(); if ((currentTime - mLastScrollEvent) < MIN_SCROLL_INTERVAL) { // TODO: We shouldn't just reject events, since we'll get weird // rhythms when scrolling, e.g. if we're getting an event every // 300ms and we reject at the 250ms mark. return false; }/*from w w w .j a va 2 s . c om*/ mLastScrollEvent = currentTime; final float percent = getScrollPercent(event); final float rate = (float) Math.pow(2.0, (percent / 50.0) - 1); utterance.addAuditory(R.id.sounds_scrolled_tone); utterance.getMetadata().putFloat(Utterance.KEY_METADATA_EARCON_RATE, rate); utterance.addSpokenFlag(FeedbackItem.FLAG_NO_SPEECH); return true; }
From source file:pl.mg6.newmaps.demo.AddOnlyVisibleMarkersExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.many_markers_example); final GoogleMap map = GoogleMapHelper.getMap(this, R.id.many_markers_map); final List<LatLng> positions = new ArrayList<LatLng>(); Random r = new Random(); long start = SystemClock.uptimeMillis(); for (int i = 0; i < ManyMarkersExampleActivity.MARKERS_COUNT; i++) { LatLng position = new LatLng((r.nextDouble() - 0.5) * 170.0, (r.nextDouble() - 0.5) * 360.0); positions.add(position);// ww w .ja v a 2 s. c o m } long end = SystemClock.uptimeMillis(); Log.w(TAG, "generate time: " + (end - start)); map.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition cameraPosition) { long start = SystemClock.uptimeMillis(); int count = 0; Projection projection = map.getProjection(); LatLngBounds bounds = projection.getVisibleRegion().latLngBounds; for (int i = positions.size() - 1; i >= 0; i--) { LatLng position = positions.get(i); if (bounds.contains(position)) { map.addMarker(new MarkerOptions().position(position)); positions.remove(i); count++; } } long end = SystemClock.uptimeMillis(); Log.w(TAG, "addMarkers time: " + (end - start) + ", added: " + count); } }); }
From source file:com.google.android.marvin.mytalkback.ActionHistory.java
/** * Stores the start time for an action. This should be called immediately * before {@link AccessibilityNodeInfoCompat#performAction}. * * @param action The action that will be performed. */// w ww .j a v a 2 s. c o m public void before(int action) { mActionStartMap.put(action, SystemClock.uptimeMillis()); }