List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:com.hippo.ehviewer.gallery.gl.GestureRecognizer.java
public void cancelScale() { long now = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0); mScaleDetector.onTouchEvent(cancelEvent); cancelEvent.recycle();//from ww w.j a v a 2 s . c om }
From source file:org.droid2droid.install.AskAcceptDownloadApkActivity.java
/** Called when the activity is first created. */ @Override/* w w w .j a va2s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); showDialog(DIALOG_IMPORT); if (V) Log.v(TAG_INSTALL, PREFIX_LOG + "srv create confirm apk dialog"); long timeout = getIntent().getLongExtra(EXTRA_TIMEOUT, -1); mId = getIntent().getIntExtra(Notifications.EXTRA_ID, -1); mHandler.postAtTime(new FinishRunnable(this), SystemClock.uptimeMillis() + timeout); }
From source file:org.droid2droid.pairing.AskAcceptPairActivity.java
/** Called when the activity is first created. */ @Override/*from w ww .ja v a 2 s . co m*/ public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); showDialog(DIALOG_ASK_ACCEPT_PAIRING); if (V) Log.v(TAG_INSTALL, PREFIX_LOG + "srv create accept pairing dialog"); mFinisher = new FinishRunnable(this); mHandler.postAtTime(mFinisher, SystemClock.uptimeMillis() + TIMEOUT_ASK_PAIR); }
From source file:android.support.v7.widget.ForwardingListener.java
@Override public boolean onTouch(View v, MotionEvent event) { final boolean wasForwarding = mForwarding; final boolean forwarding; if (wasForwarding) { forwarding = onTouchForwarded(event) || !onForwardingStopped(); } else {//from www . j a v a2s . co m forwarding = onTouchObserved(event) && onForwardingStarted(); if (forwarding) { // Make sure we cancel any ongoing source event stream. final long now = SystemClock.uptimeMillis(); final MotionEvent e = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); mSrc.onTouchEvent(e); e.recycle(); } } mForwarding = forwarding; return forwarding || wasForwarding; }
From source file:pl.mg6.newmaps.demo.AddMarkersInBackgroundExampleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.many_markers_example); map = GoogleMapHelper.getMap(this, R.id.many_markers_map); 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[i] = new LatLngDistance(position); }//from w ww . j av a 2 s. co m long end = SystemClock.uptimeMillis(); Log.w(TAG, "generate time: " + (end - start)); }
From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PickServerFragment fragment = findOrReplaceFragment(android.R.id.content, TAG, PickServerFragment.class); getActionBar().setDisplayHomeAsUpEnabled(true); mPort = getIntent().getIntExtra(PortSweeper.EXTRA_PORT, 0); if (mPort == 0) { throw new IllegalArgumentException("Port must be specified"); }/*from w ww . jav a2 s . co m*/ mFile = getIntent().getStringExtra(PortSweeper.EXTRA_FILE); if (mFile == null) { throw new IllegalArgumentException("File must be specified"); } mWorkers = getIntent().getIntExtra(PortSweeper.EXTRA_WORKERS, DEFAULT_WORKERS); mPortSweeper = createPortSweeper(fragment); startSweep(); // Registering the receiver triggers a broadcast with the initial state. // To tell the difference between a broadcast triggered by registering a // receiver and a broadcast triggered by a true network event, note the // time and ignore all broadcasts for one second. mCreateTime = SystemClock.uptimeMillis(); mReceiver = new MyBroadcastReceiver(); // For robustness, update the connection status for all types of events. IntentFilter filter = new IntentFilter(); filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); filter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION); filter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION); registerReceiver(mReceiver, filter); }
From source file:com.android.screenspeak.eventprocessor.ProcessorEventQueue.java
@Override public void onAccessibilityEvent(AccessibilityEvent event) { final int eventType = event.getEventType(); if (eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { mLastWindowStateChanged = SystemClock.uptimeMillis(); }/* w ww . ja va 2s . c o m*/ synchronized (mEventQueue) { mEventQueue.enqueue(event); mHandler.postSpeak(); } }
From source file:android.net.http.IdleCache.java
private synchronized void clearIdle() { if (mCount > 0) { long time = SystemClock.uptimeMillis(); for (int i = 0; i < IDLE_CACHE_MAX; i++) { Entry entry = mEntries[i];/* www.j av a 2 s .c o m*/ if (entry.mHost != null && time > entry.mTimeout) { entry.mHost = null; entry.mConnection.closeConnection(); entry.mConnection = null; mCount--; } } } }
From source file:org.zoumbox.mh_dla_notifier.Receiver.java
protected Predicate<Context> justRestarted() { Predicate<Context> result = new Predicate<Context>() { @Override// w w w . j a va2 s .co m public boolean apply(Context context) { // Check if the device just restarted long elapsedSinceLastRestartCheck = getProfileProxy().getElapsedSinceLastRestartCheck(context); Log.d(TAG, "Elapsed since last restart check: " + elapsedSinceLastRestartCheck + "ms ~= " + (elapsedSinceLastRestartCheck / 60000) + "min"); long uptime = SystemClock.uptimeMillis(); Log.d(TAG, "Uptime: " + uptime + "ms ~= " + (uptime / 60000) + "min"); boolean result = elapsedSinceLastRestartCheck > uptime; if (result) { getProfileProxy().restartCheckDone(context); } Log.d(TAG, "Device restarted since last check: " + result); return result; } }; return result; }
From source file:pl.mg6.newmaps.demo.InfoWindowExampleActivity.java
private void setInfoWindowAdapter(GoogleMap map) { map.setInfoWindowAdapter(new InfoWindowAdapter() { @Override/*from www .j a v a 2 s. c o m*/ public View getInfoWindow(Marker marker) { if (warsawMarker.equals(marker)) { return createView(R.layout.warsaw_info_window, 1711324, 3309); } return null; } @Override public View getInfoContents(Marker marker) { if (cracowMarker.equals(marker)) { return createView(R.layout.cracow_info_contents, 759137, 2232); } return null; } private View createView(int layoutId, int population, int density) { View view = getLayoutInflater().inflate(layoutId, null); TextView snippet = (TextView) view.findViewById(R.id.snippet); long currentTime = SystemClock.uptimeMillis() / 1000; int bornCount = (int) (currentTime - startTime); snippet.setText("Populacja: " + (population + bornCount) + "\nGsto: " + density + " os./km^2"); return view; } }); }