List of usage examples for android.os SystemClock elapsedRealtime
@CriticalNative native public static long elapsedRealtime();
From source file:com.frostwire.android.gui.fragments.BrowsePeerFragment.java
@Override protected void initComponents(View v) { filesBar = findView(v, R.id.fragment_browse_peer_files_bar); filesBar.setOnActionListener(new OnActionListener() { public void onCheckAll(View v, boolean isChecked) { if (adapter != null) { if (isChecked) { adapter.checkAll();//from w w w .ja v a 2s .c o m } else { adapter.clearChecked(); } } } public void onFilter(View v, String str) { if (adapter != null) { adapter.getFilter().filter(str); } } @Override public void onClear() { clearPreviousFilter(); } }); swipeRefresh = findView(v, R.id.fragment_browse_peer_swipe_refresh); swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { long now = SystemClock.elapsedRealtime(); if ((now - lastAdapterRefresh) > 5000) { refreshSelection(); } else { swipeRefresh.setRefreshing(false); } } }); list = findView(v, R.id.fragment_browse_peer_list); list.setOnTouchListener(viewSwipeDetector); initRadioButton(v, R.id.fragment_browse_peer_radio_audio, Constants.FILE_TYPE_AUDIO); initRadioButton(v, R.id.fragment_browse_peer_radio_ringtones, Constants.FILE_TYPE_RINGTONES); initRadioButton(v, R.id.fragment_browse_peer_radio_videos, Constants.FILE_TYPE_VIDEOS); initRadioButton(v, R.id.fragment_browse_peer_radio_pictures, Constants.FILE_TYPE_PICTURES); initRadioButton(v, R.id.fragment_browse_peer_radio_documents, Constants.FILE_TYPE_DOCUMENTS); initRadioButton(v, R.id.fragment_browse_peer_radio_torrents, Constants.FILE_TYPE_TORRENTS); }
From source file:neal.http.impl.BasicNetwork.java
protected void logError(String what, String url, long start) { long now = SystemClock.elapsedRealtime(); HttpLog.v("HTTP ERROR(%s) %d ms to fetch %s", what, (now - start), url); }
From source file:de.quist.app.errorreporter.ExceptionReportService.java
private void sendReport(Intent intent) throws UnsupportedEncodingException, NameNotFoundException { Log.v(TAG, "Got request to report error: " + intent.toString()); Uri server = getTargetUrl();/*from w w w . j a va 2 s.c o m*/ boolean isManualReport = intent.getBooleanExtra(EXTRA_MANUAL_REPORT, false); boolean isReportOnFroyo = isReportOnFroyo(); boolean isFroyoOrAbove = isFroyoOrAbove(); if (isFroyoOrAbove && !isManualReport && !isReportOnFroyo) { // We don't send automatic reports on froyo or above Log.d(TAG, "Don't send automatic report on froyo"); return; } Set<String> fieldsToSend = getFieldsToSend(); String stacktrace = intent.getStringExtra(EXTRA_STACK_TRACE); String exception = intent.getStringExtra(EXTRA_EXCEPTION_CLASS); String message = intent.getStringExtra(EXTRA_MESSAGE); long availableMemory = intent.getLongExtra(EXTRA_AVAILABLE_MEMORY, -1l); long totalMemory = intent.getLongExtra(EXTRA_TOTAL_MEMORY, -1l); String dateTime = intent.getStringExtra(EXTRA_EXCEPTION_TIME); String threadName = intent.getStringExtra(EXTRA_THREAD_NAME); String extraMessage = intent.getStringExtra(EXTRA_EXTRA_MESSAGE); List<NameValuePair> params = new ArrayList<NameValuePair>(); addNameValuePair(params, fieldsToSend, "exStackTrace", stacktrace); addNameValuePair(params, fieldsToSend, "exClass", exception); addNameValuePair(params, fieldsToSend, "exDateTime", dateTime); addNameValuePair(params, fieldsToSend, "exMessage", message); addNameValuePair(params, fieldsToSend, "exThreadName", threadName); if (extraMessage != null) addNameValuePair(params, fieldsToSend, "extraMessage", extraMessage); if (availableMemory >= 0) addNameValuePair(params, fieldsToSend, "devAvailableMemory", availableMemory + ""); if (totalMemory >= 0) addNameValuePair(params, fieldsToSend, "devTotalMemory", totalMemory + ""); PackageManager pm = getPackageManager(); try { PackageInfo packageInfo = pm.getPackageInfo(getPackageName(), 0); addNameValuePair(params, fieldsToSend, "appVersionCode", packageInfo.versionCode + ""); addNameValuePair(params, fieldsToSend, "appVersionName", packageInfo.versionName); addNameValuePair(params, fieldsToSend, "appPackageName", packageInfo.packageName); } catch (NameNotFoundException e) { } addNameValuePair(params, fieldsToSend, "devModel", android.os.Build.MODEL); addNameValuePair(params, fieldsToSend, "devSdk", android.os.Build.VERSION.SDK); addNameValuePair(params, fieldsToSend, "devReleaseVersion", android.os.Build.VERSION.RELEASE); HttpClient httpClient = new DefaultHttpClient(); HttpPost post = new HttpPost(server.toString()); post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8)); Log.d(TAG, "Created post request"); try { httpClient.execute(post); Log.v(TAG, "Reported error: " + intent.toString()); } catch (ClientProtocolException e) { // Ignore this kind of error Log.e(TAG, "Error while sending an error report", e); } catch (SSLException e) { Log.e(TAG, "Error while sending an error report", e); } catch (IOException e) { if (e instanceof SocketException && e.getMessage().contains("Permission denied")) { Log.e(TAG, "You don't have internet permission", e); } else { int maximumRetryCount = getMaximumRetryCount(); int maximumExponent = getMaximumBackoffExponent(); // Retry at a later point in time AlarmManager alarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); int exponent = intent.getIntExtra(EXTRA_CURRENT_RETRY_COUNT, 0); intent.putExtra(EXTRA_CURRENT_RETRY_COUNT, exponent + 1); PendingIntent operation = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); if (exponent >= maximumRetryCount) { // Discard error Log.w(TAG, "Error report reached the maximum retry count and will be discarded.\nStacktrace:\n" + stacktrace); return; } if (exponent > maximumExponent) { exponent = maximumExponent; } long backoff = (1 << exponent) * 1000; // backoff in ms alarmMgr.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + backoff, operation); } } }
From source file:com.playbasis.android.playbasissdk.http.toolbox.BasicNetwork.java
protected void logError(String what, String url, long start) { long now = SystemClock.elapsedRealtime(); PlayBasisLog.v("HTTP ERROR(%s) %d ms to fetch %s", what, (now - start), url); }
From source file:com.github.jvanhie.discogsscrobbler.util.NowPlayingService.java
public void pause() { if (isPlaying) { //clear pending next track alarm if (mAlarmIntent != null) { mAlarmManager.cancel(mAlarmIntent); mAlarmIntent.cancel();/*from w ww. ja va2s.com*/ } isPlaying = false; //calculate how much of the track we have already played in ms and add it to the done variable in s long diff = SystemClock.elapsedRealtime() - mTrackStart; mTrackDone += diff / 1000; //notify last.fm as well mLastfm.stopNowPlaying(track); //change notifaction mNotificationBuilder.setWhen(System.currentTimeMillis()) .setSmallIcon(android.R.drawable.ic_media_pause); startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); } }
From source file:com.minio.io.alice.MainActivity.java
private void manageAliceDisplay() { currentTime = SystemClock.elapsedRealtime(); long timeElapsed = currentTime - prevFaceDetectionAt; if (isAliceAwake && (timeElapsed > ELAPSED_DURATION)) { isAliceAwake = false;/*from w w w . j av a 2 s. c o m*/ } //Wake up Alice if currently invisible if (isAliceAwake && !mPreview.isShown()) toggleDisplay(mPreview, View.VISIBLE); //Blank display if Alice has not detected any face in ELAPSED_DURATION if (!isAliceAwake && mPreview.isShown()) toggleDisplay(mPreview, View.INVISIBLE); }
From source file:com.royer.bangstopwatch.app.StopwatchFragment.java
protected void onLap() { mLapManager.appandLap(SystemClock.elapsedRealtime()); mLapAdapter.notifyDataSetChanged(); }
From source file:ca.rmen.android.scrumchatter.meeting.detail.MeetingFragment.java
@MainThread private void displayMeeting(Meeting meeting) { FragmentActivity activity = getActivity(); if (activity == null) return;/* w w w .ja v a2 s. com*/ setHasOptionsMenu(true); activity.supportInvalidateOptionsMenu(); // Update the UI views Log.v(TAG, "meetingState = " + meeting.getState()); // Show the "stop meeting" button if the meeting is not finished. mBinding.btnStopMeeting.setVisibility( meeting.getState() == State.NOT_STARTED || meeting.getState() == State.IN_PROGRESS ? View.VISIBLE : View.INVISIBLE); // Only enable the "stop meeting" button if the meeting is in progress. mBinding.btnStopMeeting.setEnabled(meeting.getState() == State.IN_PROGRESS); // Show the horizontal progress bar for in progress meetings mBinding.headerProgressBar .setVisibility(meeting.getState() == State.IN_PROGRESS ? View.VISIBLE : View.INVISIBLE); // Update the chronometer if (meeting.getState() == State.IN_PROGRESS) { // If the meeting is in progress, show the Chronometer. long timeSinceMeetingStartedMillis = System.currentTimeMillis() - meeting.getStartDate(); mBinding.tvMeetingDuration.setBase(SystemClock.elapsedRealtime() - timeSinceMeetingStartedMillis); mBinding.tvMeetingDuration.start(); } else if (meeting.getState() == State.FINISHED) { // For finished meetings, show the duration we retrieved from the db. mBinding.tvMeetingDuration.stop(); mBinding.tvMeetingDuration.setText(DateUtils.formatElapsedTime(meeting.getDuration())); } }
From source file:com.scooter1556.sms.android.activity.VideoPlayerActivity.java
private void togglePlayback() { lastActionTime = SystemClock.elapsedRealtime(); if (player != null) { if (player.isPlaying()) { playButton.setImageResource(R.drawable.ic_play_light); videoOverlay.setVisibility(View.VISIBLE); showController = true;/* ww w . ja v a2 s . co m*/ surface.removeCallbacks(updateController); player.pause(); paused = true; // Allow screen to turn off getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); if (wifiLock.isHeld()) { wifiLock.release(); } } else { playButton.setImageResource(R.drawable.ic_pause_light); videoOverlay.setVisibility(View.INVISIBLE); player.start(); paused = false; showController = false; surface.postDelayed(updateController, 1000); // Keep screen on getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); wifiLock.acquire(); } } }
From source file:com.acrr.acdisplay.services.activemode.ActiveModeService.java
/** * {@inheritDoc} */ public void pingConsumingSensors() { mConsumingPingTimestamp = SystemClock.elapsedRealtime(); pingConsumingSensorsInternal(); }