List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:com.android.talkback.EditTextActionHistory.java
/** * Stores the start time for a paste action. This should be called immediately before * {@link AccessibilityNodeInfoCompat#performAction}. *///from w w w. j a v a 2s . c o m public void beforePaste() { mPasteStartTime = SystemClock.uptimeMillis(); }
From source file:com.commonsware.android.sawmonitor.PackageReceiver.java
@Override public void onReceive(Context ctxt, Intent intent) { String pkg = intent.getData().getSchemeSpecificPart(); if (ACTION_PACKAGE_ADDED.equals(intent.getAction())) { ADD_TIMESTAMPS.put(pkg, SystemClock.uptimeMillis()); seeSAW(ctxt, pkg, false);/*from w w w. j a va 2 s .co m*/ } else if (ACTION_PACKAGE_REPLACED.equals(intent.getAction())) { Long added = ADD_TIMESTAMPS.get(pkg); if (added == null || (SystemClock.uptimeMillis() - added) > ADD_THEN_REPLACE_DELTA) { seeSAW(ctxt, pkg, true); if (added != null) { ADD_TIMESTAMPS.remove(pkg); } } } }
From source file:com.commonsware.android.okhttp3.progress.Downloader.java
@Override public void onHandleIntent(Intent i) { mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); try {// ww w .ja v a 2 s . c o m String filename = i.getData().getLastPathSegment(); NotificationCompat.Builder builder = buildForeground(filename); final Notification notif = builder.build(); startForeground(FOREGROUND_ID, notif); File root = getExternalFilesDir(null); root.mkdirs(); File output = new File(root, filename); if (output.exists()) { output.delete(); } final ProgressResponseBody.Listener progressListener = new ProgressResponseBody.Listener() { long lastUpdateTime = 0L; @Override public void onProgressChange(long bytesRead, long contentLength, boolean done) { long now = SystemClock.uptimeMillis(); if (now - lastUpdateTime > 1000) { notif.contentView.setProgressBar(android.R.id.progress, (int) contentLength, (int) bytesRead, false); mgr.notify(FOREGROUND_ID, notif); lastUpdateTime = now; } } }; Interceptor nightTrain = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Response original = chain.proceed(chain.request()); Response.Builder b = original.newBuilder() .body(new ProgressResponseBody(original.body(), progressListener)); return (b.build()); } }; OkHttpClient client = new OkHttpClient.Builder().addNetworkInterceptor(nightTrain).build(); Request request = new Request.Builder().url(i.getData().toString()).build(); Response response = client.newCall(request).execute(); String contentType = response.header("Content-type"); BufferedSink sink = Okio.buffer(Okio.sink(new File(output.getPath()))); sink.writeAll(response.body().source()); sink.close(); stopForeground(true); raiseNotification(contentType, output, null); } catch (IOException e2) { stopForeground(true); raiseNotification(null, null, e2); } }
From source file:org.kontalk.ui.AudioFragment.java
public void startPlaying() { if (mPlayer != null) { mStartTime = SystemClock.uptimeMillis(); mPlayer.start();/*from ww w . ja v a2 s . c o m*/ // started, acquire lock acquireLock(); } }
From source file:com.android.talkback.EditTextActionHistory.java
/** * Stores the finish time for a paste action. This should be called immediately after * {@link AccessibilityNodeInfoCompat#performAction}. *//*w ww . ja v a 2 s. c o m*/ public void afterPaste() { mPasteFinishTime = SystemClock.uptimeMillis(); }
From source file:org.videolan.vlc.RemoteControlClientReceiver.java
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT); if (event != null && action.equalsIgnoreCase(Intent.ACTION_MEDIA_BUTTON)) { if (event.getKeyCode() != KeyEvent.KEYCODE_HEADSETHOOK && event.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE && event.getAction() != KeyEvent.ACTION_DOWN) { super.onReceive(context, intent); return; }/*from w w w .j av a 2 s.c o m*/ Intent i = null; switch (event.getKeyCode()) { /* * one click => play/pause * long click => previous * double click => next */ case KeyEvent.KEYCODE_HEADSETHOOK: case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: long time = SystemClock.uptimeMillis(); switch (event.getAction()) { case KeyEvent.ACTION_DOWN: if (event.getRepeatCount() <= 0) mHeadsetDownTime = time; break; case KeyEvent.ACTION_UP: if (AndroidDevices.hasTsp()) { //no backward/forward on TV if (time - mHeadsetDownTime >= 1000) { // long click i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; } else if (time - mHeadsetUpTime <= 500) { // double click i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; } } // one click i = new Intent(PlaybackService.ACTION_REMOTE_PLAYPAUSE, null, VLCApplication.getAppContext(), PlaybackService.class); mHeadsetUpTime = time; break; } break; case KeyEvent.KEYCODE_MEDIA_PLAY: context.startService(new Intent(PlaybackService.ACTION_REMOTE_PLAY, null, VLCApplication.getAppContext(), PlaybackService.class)); return; case KeyEvent.KEYCODE_MEDIA_PAUSE: i = new Intent(PlaybackService.ACTION_REMOTE_PAUSE, null, VLCApplication.getAppContext(), PlaybackService.class); break; case KeyEvent.KEYCODE_MEDIA_STOP: i = new Intent(PlaybackService.ACTION_REMOTE_STOP, null, VLCApplication.getAppContext(), PlaybackService.class); break; case KeyEvent.KEYCODE_MEDIA_NEXT: i = new Intent(PlaybackService.ACTION_REMOTE_FORWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; case KeyEvent.KEYCODE_MEDIA_PREVIOUS: i = new Intent(PlaybackService.ACTION_REMOTE_BACKWARD, null, VLCApplication.getAppContext(), PlaybackService.class); break; } if (isOrderedBroadcast()) abortBroadcast(); if (i != null) { context.startService(i); return; } } else if (action.equals(PlaybackService.ACTION_REMOTE_PLAYPAUSE)) { intent = new Intent(context, PlaybackService.class); intent.setAction(PlaybackService.ACTION_REMOTE_PLAYPAUSE); context.startService(intent); return; } super.onReceive(context, intent); }
From source file:com.android.talkback.EditTextActionHistory.java
public void beforeSelectAll() { mSelectAllStartTime = SystemClock.uptimeMillis(); }
From source file:pl.mg6.android.maps.extensions.demo.LaunchTimeTestActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.launch_time_test); FragmentManager fm = getSupportFragmentManager(); SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.map); GoogleMap map = f.getExtendedMap();/*from w w w.ja v a 2s. c o m*/ int clusteringType = getIntent().getIntExtra(EXTRA_CLUSTERING_TYPE, CLUSTERING_DISABLED); ClusteringSettings settings = new ClusteringSettings(); switch (clusteringType) { case CLUSTERING_DISABLED_DYNAMIC: settings.enabled(false).addMarkersDynamically(true); break; case CLUSTERING_ENABLED: settings.clusterOptionsProvider(new DemoClusterOptionsProvider(getResources())); break; case CLUSTERING_ENABLED_DYNAMIC: settings.clusterOptionsProvider(new DemoClusterOptionsProvider(getResources())) .addMarkersDynamically(true); break; default: settings.enabled(false); } map.setClustering(settings); Random r = new Random(0); MarkerOptions options = new MarkerOptions(); long start = SystemClock.uptimeMillis(); for (int i = 0; i < MARKERS_COUNT; i++) { LatLng position = new LatLng(r.nextDouble() * 170 - 85, r.nextDouble() * 360 - 180); map.addMarker(options.position(position)); } long end = SystemClock.uptimeMillis(); long time = end - start; float zoom = map.getCameraPosition().zoom; String format = "Time adding %d markers (option: %d, zoom: %.1f): %d"; String text = String.format(Locale.US, format, MARKERS_COUNT, clusteringType, zoom, time); Log.i(TAG, text); }
From source file:com.android.talkback.EditTextActionHistory.java
public void afterSelectAll() { mSelectAllFinishTime = SystemClock.uptimeMillis(); }
From source file:ca.ualberta.cmput301w14t08.geochan.test.ThreadViewFragmentTest.java
/** * http://stackoverflow.com/a/17789933//from w ww .j av a 2s . c o m * Sometimes the emulator is too slow. */ protected Fragment waitForFragment(String tag, int timeout) { long endTime = SystemClock.uptimeMillis() + timeout; while (SystemClock.uptimeMillis() <= endTime) { Fragment fragment = getActivity().getSupportFragmentManager().findFragmentByTag(tag); if (fragment != null) { return fragment; } } return null; }