public c(Context paramContext, boolean paramBoolean) { i = paramContext; B = paramBoolean; j = ((NotificationManager) i.getSystemService("notification")); k = false; m = (g.addAndGet(1) + (int) SystemClock.elapsedRealtime()); y.setTextSize(16.0F); if (Build.VERSION.SDK_INT >= 14) { paramContext = i; x = h.b( null, "android.app.Notification$Builder", new Class[] {Context.class}, new Context[] {paramContext}); } for (; ; ) { if (d != null) {} synchronized (c) { if (B) { c.add(Integer.valueOf(m)); if (!f) { if (!bd.j()) { break label305; } paramContext = new Notification( 2130837892, FexApplication.a().getText(2131428105), System.currentTimeMillis()); PendingIntent localPendingIntent = PendingIntent.getActivity(FexApplication.a(), 0, new Intent(), 0); paramContext.setLatestEventInfo( FexApplication.a(), FexApplication.a().getText(2131427488), FexApplication.a().getText(2131428105), localPendingIntent); flags |= 0x20; d.startForeground(g.addAndGet(1) + (int) SystemClock.elapsedRealtime(), paramContext); f = true; } } return; w = new af(i); continue; label305: paramContext = new Notification(0, null, System.currentTimeMillis()); } } }
private void refreshMapInternal(DrawSettings drawSettings) { handler.removeMessages(MAP_REFRESH_MESSAGE); SurfaceHolder holder = getHolder(); long ms = SystemClock.elapsedRealtime(); synchronized (holder) { Canvas canvas = holder.lockCanvas(); if (canvas != null) { try { final float ratioy = mapPosition == OsmandSettings.BOTTOM_CONSTANT ? 0.8f : 0.5f; final int cy = (int) (ratioy * getHeight()); if (currentViewport.getPixWidth() != getWidth() || currentViewport.getPixHeight() != getHeight() || currentViewport.getCenterPixelY() != cy) { currentViewport.setPixelDimensions(getWidth(), getHeight(), 0.5f, ratioy); refreshBufferImage(drawSettings); } // make copy to avoid concurrency RotatedTileBox viewportToDraw = currentViewport.copy(); fillCanvas(canvas, drawSettings); drawOverMap(canvas, viewportToDraw, drawSettings); } finally { holder.unlockCanvasAndPost(canvas); } } if (MEASURE_FPS) { main.calculateFPS(ms, SystemClock.elapsedRealtime()); } } }
@Override protected void onHandleIntent(Intent intent) { Bundle extras = intent.getExtras(); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { for (int i = 0; i < 3; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(5000); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); sendNotification( "Message Received from Google GCM Server: " + extras.get(Config.MESSAGE_KEY)); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReceiver.completeWakefulIntent(intent); }
protected Long doInBackground(Object... objects) { Long startTime = SystemClock.elapsedRealtime(); calculatePi(); Long endTime = SystemClock.elapsedRealtime(); accumulatedRunTime += (endTime - startTime); return (long) 0; }
// When the GPS status changes public void onGpsStatusChanged(int event) { switch (event) { case GpsStatus.GPS_EVENT_SATELLITE_STATUS: // If there's a previous location // and the time is outside of the timeout period if (!blockMessageShown && evade.locMan.lastLoc != null && SystemClock.elapsedRealtime() - evade.locMan.lastLocTime > TIMEOUT_DELAY) { // If the time is outside of the timeout period Toast.makeText(evade, "The aliens are blocking your transmissions.", Toast.LENGTH_SHORT) .show(); evade.timer.cancel(); blockMessageShown = true; } // If there's no previous location else if (evade.locMan.lastLoc == null) { // If we're within the acceptable wait range if (SystemClock.elapsedRealtime() - beginCheckTime < TIMEOUT_DELAY) { System.out.println("Waiting for a GPS fix"); } // Otherwise, we need to timeout else { GPSTimeout(); timeout = true; } } break; case GpsStatus.GPS_EVENT_FIRST_FIX: pro.hide(); break; } }
@SmallTest @Feature({"IntentHandling"}) public void testNavigationWithForwardBack() { TabRedirectHandler handler = new TabRedirectHandler(mContext); handler.updateIntent(sYtIntent); assertFalse(handler.isOnNavigation()); assertFalse(handler.shouldStayInChrome(false)); assertFalse(handler.shouldStayInChrome(true)); handler.updateNewUrlLoading( PageTransition.FORM_SUBMIT | PageTransition.FORWARD_BACK, false, true, SystemClock.elapsedRealtime(), 0); assertTrue(handler.shouldStayInChrome(false)); assertTrue(handler.shouldStayInChrome(true)); handler.updateNewUrlLoading( PageTransition.LINK, false, false, SystemClock.elapsedRealtime(), 1); assertTrue(handler.shouldStayInChrome(false)); assertTrue(handler.shouldStayInChrome(true)); assertTrue(handler.isOnNavigation()); assertEquals(0, handler.getLastCommittedEntryIndexBeforeStartingNavigation()); SystemClock.sleep(1); handler.updateNewUrlLoading(PageTransition.LINK, false, true, SystemClock.elapsedRealtime(), 2); assertFalse(handler.shouldStayInChrome(false)); assertFalse(handler.shouldStayInChrome(true)); assertTrue(handler.isOnNavigation()); assertEquals(2, handler.getLastCommittedEntryIndexBeforeStartingNavigation()); }
@Override protected Bitmap doInBackground(Void... params) { final long start = SystemClock.elapsedRealtime(); Bitmap origin = mBitmapOriginal; Bitmap bitmap = BitmapUtils.doBlur(origin, 3, false); if (!running) { return null; } Canvas canvas = new Canvas(bitmap); canvas.drawColor(mForegroundColor); if (Build.DEBUG) { long delta = SystemClock.elapsedRealtime() - start; Log.d( TAG, "Dynamic background created in " + delta + " millis:" + " width=" + bitmap.getWidth() + " height=" + bitmap.getHeight()); } return bitmap; }
/** Execute a request without applying and rewrite rules. */ public HttpResponse executeWithoutRewriting(HttpUriRequest request, HttpContext context) throws IOException { String code = "Error"; long start = SystemClock.elapsedRealtime(); try { HttpResponse response = mClient.execute(request, context); code = Integer.toString(response.getStatusLine().getStatusCode()); return response; } catch (IOException e) { code = "IOException"; throw e; } finally { // Record some statistics to the checkin service about the outcome. // Note that this is only describing execute(), not body download. try { long elapsed = SystemClock.elapsedRealtime() - start; ContentValues values = new ContentValues(); values.put( Checkin.Stats.TAG, Checkin.Stats.Tag.HTTP_STATUS + ":" + mUserAgent + ":" + code); values.put(Checkin.Stats.COUNT, 1); values.put(Checkin.Stats.SUM, elapsed / 1000.0); mResolver.insert(Checkin.Stats.CONTENT_URI, values); } catch (Exception e) { Log.e(TAG, "Error recording stats", e); } } }
public void halt() { // modified long time = SystemClock.elapsedRealtime(); int i = 0; for (RegisterAgent ra : ras) { unregister(i); while (ra != null && ra.CurrentState != RegisterAgent.UNREGISTERED && SystemClock.elapsedRealtime() - time < 2000) try { Thread.sleep(100); } catch (InterruptedException e1) { } if (wl[i].isHeld()) { wl[i].release(); if (pwl[i] != null && pwl[i].isHeld()) pwl[i].release(); } if (kas[i] != null) { Receiver.alarm(0, LoopAlarm.class); kas[i].halt(); } Receiver.onText(Receiver.REGISTER_NOTIFICATION + i, null, 0, 0); if (ra != null) ra.halt(); if (uas[i] != null) uas[i].hangup(); if (sip_providers[i] != null) sip_providers[i].halt(); i++; } }
@Override protected void onHandleIntent(Intent intent) { // TODO Auto-generated method stub Bundle extras = intent.getExtras(); String msg = intent.getStringExtra("message"); GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(this); String messageType = gcm.getMessageType(intent); if (!extras.isEmpty()) { if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) { sendNotification("Send error: " + extras.toString()); } else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) { sendNotification("Deleted messages on server: " + extras.toString()); // If it's a regular GCM message, do some work. } else if (GoogleCloudMessaging.MESSAGE_TYPE_MESSAGE.equals(messageType)) { // This loop represents the service doing some work. for (int i = 0; i < 5; i++) { Log.i(TAG, "Working... " + (i + 1) + "/5 @ " + SystemClock.elapsedRealtime()); try { Thread.sleep(500); } catch (InterruptedException e) { } } Log.i(TAG, "Completed work @ " + SystemClock.elapsedRealtime()); // Post notification of received message. // sendNotification("Received: " + extras.toString()); sendNotification(msg); Log.i(TAG, "Received: " + extras.toString()); } } GcmBroadcastReciever.completeWakefulIntent(intent); }
private void m2619a(long j, JSONObject jSONObject) throws JSONException { int i = 1; boolean p = this.Cv.m1149p(j); int i2 = (!this.Cz.ev() || this.Cz.m1149p(j)) ? 0 : 1; if ((!this.CA.ev() || this.CA.m1149p(j)) && (!this.CB.ev() || this.CB.m1149p(j))) { i = 0; } i2 = i2 != 0 ? 2 : 0; if (i != 0) { i2 |= 1; } if (p || this.Cu == null) { this.Cu = new MediaStatus(jSONObject); this.Ct = SystemClock.elapsedRealtime(); i2 = 7; } else { i2 = this.Cu.m108a(jSONObject, i2); } if ((i2 & 1) != 0) { this.Ct = SystemClock.elapsedRealtime(); onStatusUpdated(); } if ((i2 & 2) != 0) { this.Ct = SystemClock.elapsedRealtime(); onStatusUpdated(); } if ((i2 & 4) != 0) { onMetadataUpdated(); } for (gr c : this.CF) { c.m1147c(j, 0); } }
@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (TelephonyIntents.ACTION_NETWORK_SET_TIME.equals(action)) { mNitzTimeSetTime = SystemClock.elapsedRealtime(); } else if (TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE.equals(action)) { mNitzZoneSetTime = SystemClock.elapsedRealtime(); } }
/** @return Vehicle flight time in seconds. */ public long getFlightTime() { State droneState = getAttribute(AttributeType.STATE); if (droneState != null && droneState.isFlying()) { // calc delta time since last checked elapsedFlightTime += SystemClock.elapsedRealtime() - startTime; startTime = SystemClock.elapsedRealtime(); } return elapsedFlightTime / 1000; }
private void launchPlayer(long atTime) { Log.d("jdj-ExoPlayer", "Player LOADING at " + atTime); playerState = STATE_LOAD; if (mode != null && mode.equals("audio")) { audioShutter.setVisibility(View.VISIBLE); // seek to position to keep sync if (baganAtTime > 0 && atTime < SystemClock.elapsedRealtime()) { atTime = SystemClock.elapsedRealtime() + 1500; // already late so we postpone the start playerPosition = atTime - baganAtTime; // start at position shifted from baganAtTime } } if (player == null) { player = new ExPlayer(getRendererBuilder()); player.addListener(this); player.seekTo(playerPosition); playerNeedsPrepare = true; if (exoLog) { eventLogger = new EventLogger(); eventLogger.startSession(); player.addListener(eventLogger); player.setInfoListener(eventLogger); player.setInternalErrorListener(eventLogger); } } if (playerNeedsPrepare) { player.prepare(); playerNeedsPrepare = false; } player.setSurface(surfaceView.getHolder().getSurface()); player.setPlayWhenReady(false); atTimeUse = atTime; // Sync with atTime new Handler() .postDelayed( new Runnable() { @Override public void run() { if (playerState == STATE_STOP) return; else if (playerState >= STATE_READY) { Log.d("jdj-ExoPlayer", "Player PLAY - SYNC"); loadShutter.setVisibility(View.GONE); } else Log.d("jdj-ExoPlayer", "Player PLAY - OUT OF SYNC.. (not ready yet)"); player.setPlayWhenReady(true); playerState = STATE_PLAY; Log.d( "jdj-ExoPlayer", " Timer shot shift: " + (SystemClock.elapsedRealtime() - atTimeUse)); } }, Math.max(0, atTime - SystemClock.elapsedRealtime())); }
private void drawStatistic(Canvas canvas) { renderCount++; long diffTime = SystemClock.elapsedRealtime() - lastTime; if (diffTime > 1000) { speed = Math.round(renderCount * 1000f / diffTime); lastTime = SystemClock.elapsedRealtime(); renderCount = 0; } canvas.drawText("FPS: " + speed, 30, 100, paintStatistics); }
@Override void updateLatLng(@NonNull Location location) { if (latLng == null) { // first location fix latLng = new LatLng(location); locationUpdateTimestamp = SystemClock.elapsedRealtime(); } // updateLatLng timestamp long previousUpdateTimeStamp = locationUpdateTimestamp; locationUpdateTimestamp = SystemClock.elapsedRealtime(); // calculate animation duration long locationUpdateDuration; if (previousUpdateTimeStamp == 0) { locationUpdateDuration = 0; } else { // TODO remove 10 * hack to multiply duration to workaround easing interpolation // (easeCamera) locationUpdateDuration = 10 * (locationUpdateTimestamp - previousUpdateTimeStamp); } // calculate interpolated location previousLocation = latLng; latLng = new LatLng(location); interpolatedLocation = new LatLng( (latLng.getLatitude() + previousLocation.getLatitude()) / 2, (latLng.getLongitude() + previousLocation.getLongitude()) / 2); // build new camera CameraPosition.Builder builder = new CameraPosition.Builder().target(interpolatedLocation); // add direction if (myBearingTrackingMode == MyBearingTracking.GPS) { if (location.hasBearing()) { builder.bearing(location.getBearing()); gpsDirection = 0; } } else if (myBearingTrackingMode == MyBearingTracking.COMPASS) { if (!compassListener.isPaused()) { builder.bearing(compassListener.getCurrentDegree()); compassDirection = 0; } } updateAccuracy(location); // animate to new camera mapboxMap.easeCamera( CameraUpdateFactory.newCameraPosition(builder.build()), (int) locationUpdateDuration, null); }
private void hibernate() { // stop GPS until our next fix interval arrives stopNavigating(); mFixCount = 0; mAlarmManager.cancel(mTimeoutIntent); mAlarmManager.cancel(mWakeupIntent); long now = SystemClock.elapsedRealtime(); mAlarmManager.set( AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + mFixInterval * 1000, mWakeupIntent); }
/** * Wait for a new frame, or until the specified timeout elapses. Returns true if a new frame was * received before the timeout. */ public synchronized boolean waitForNewFrame(final long timeoutMs) throws InterruptedException { final long startTimeMs = SystemClock.elapsedRealtime(); long timeRemainingMs = timeoutMs; while (!hasNewFrame && timeRemainingMs > 0) { wait(timeRemainingMs); final long elapsedTimeMs = SystemClock.elapsedRealtime() - startTimeMs; timeRemainingMs = timeoutMs - elapsedTimeMs; } final boolean didReceiveFrame = hasNewFrame; hasNewFrame = false; return didReceiveFrame; }
@Override public void onClick(View v) { boolean isPlaying = mMediaPlayer.isPlaying(); if (v == mButtonPlayPause) { if (isPlaying) { mMediaPlayer.pause(); mChronometer.stop(); mButtonPlayPause.setImageResource(R.drawable.media_play); mButtonPlayPause.setContentDescription(getResources().getText(R.string.play)); } else { mMediaPlayer.start(); mChronometer.setBase(SystemClock.elapsedRealtime() - mMediaPlayer.getCurrentPosition()); mChronometer.start(); mButtonPlayPause.setImageResource(R.drawable.media_pause); mButtonPlayPause.setContentDescription(getResources().getText(R.string.pause)); } } else if (v == mButtonSkip) { mIndex = (mIndex + 1) % mItems.size(); onClick(mButtonStop); if (isPlaying) { onClick(mButtonPlayPause); } } else if (v == mButtonRewind) { // mMediaPlayer.seekTo(0); mChronometer.setBase(SystemClock.elapsedRealtime()); if (mIndex == 0) { mIndex = mItems.size(); } if (mIndex > 0) { mIndex = (mIndex - 1) % mItems.size(); } onClick(mButtonStop); if (isPlaying) { onClick(mButtonPlayPause); } } else if (v == mButtonStop) { mMediaPlayer.stop(); mMediaPlayer.reset(); mChronometer.stop(); mChronometer.setBase(SystemClock.elapsedRealtime()); prepare(); } else if (v == mButtonConfig) { Intent i = new Intent(this, ConfigActivity.class); startActivity(i); Toast.makeText(this, "Config", Toast.LENGTH_LONG).show(); } }
@Override public void run() { try { MainActivity.this.showStatusTextFromThread("Connecting...\n"); serverAddr = InetAddress.getByName("10.10.100.100"); if (serverAddr == null) { MainActivity.this.showStatusTextFromThread("Can't create server address!\n"); return; } socket = new Socket(serverAddr, 8899); if (!socket.isConnected()) { MainActivity.this.showStatusTextFromThread("Can't connect to Robot!\n"); return; } MainActivity.this.showStatusTextFromThread("Connected to Robot.\n"); PrintWriter out = new PrintWriter( new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true); BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); long lastWrite = SystemClock.elapsedRealtime(); int count = 0; char ch = 'A'; while (true) { long now = SystemClock.elapsedRealtime(); if (now - lastWrite >= 3000) { if (count >= 5) break; MainActivity.this.showStatusTextFromThread( "(" + Long.toString(now) + ") SND: " + Character.toString(ch) + "\n"); out.println(ch++); count++; lastWrite = now; } if (in.ready()) { char ch2 = (char) in.read(); MainActivity.this.showStatusTextFromThread( "(" + Long.toString(now) + ") RCV: " + Character.toString(ch2) + "\n"); } else { Thread.sleep(100); } } } catch (Exception e) { e.printStackTrace(); MainActivity.this.showStatusTextFromThread(e.getLocalizedMessage()); } finally { try { if (socket != null) socket.close(); } catch (Exception e) { e.printStackTrace(); MainActivity.this.showStatusTextFromThread(e.getLocalizedMessage()); } } }
@SmallTest @Feature({"Android-AppBase"}) public void testAddTimestampToIntent() { Intent intent = new Intent(); assertEquals(-1, IntentHandler.getTimestampFromIntent(intent)); // Check both before and after to make sure that the returned value is // really from {@link SystemClock#elapsedRealtime()}. long before = SystemClock.elapsedRealtime(); IntentHandler.addTimestampToIntent(intent); long after = SystemClock.elapsedRealtime(); assertTrue("Time should be increasing", before <= IntentHandler.getTimestampFromIntent(intent)); assertTrue("Time should be increasing", IntentHandler.getTimestampFromIntent(intent) <= after); }
@Override public boolean dispatchTouchEvent(MotionEvent ev) { // as long as the user is entering a pattern (i.e sending a touch // event that was handled by this screen), keep poking the // wake lock so that the screen will stay on. final boolean result = super.dispatchTouchEvent(ev); if (result && ((SystemClock.elapsedRealtime() - mLastPokeTime) > (UNLOCK_PATTERN_WAKE_INTERVAL_MS - 100))) { mLastPokeTime = SystemClock.elapsedRealtime(); } return result; }
private static void storeIssue(FailureLevel level, String tag, String message) { if (Application.get() == null || !Application.isDebug() || !sEnabled) { return; } final LogEntry log = new LogEntry(System.currentTimeMillis(), level, tag, message); sHelper.insertLog(log); if (sLastCheck < (SystemClock.elapsedRealtime() - 5 * 1000)) { sLastCheck = SystemClock.elapsedRealtime(); new SendTask(false).start(); } }
@Override protected Bitmap doInBackground(Integer... params) { try { publishProgress(getString(R.string.loading_image)); long start = SystemClock.elapsedRealtime(); InputStream in = getResources().openRawResource(params[0]); byte[] encoded = IOUtils.toByteArray(in); long time = SystemClock.elapsedRealtime() - start; publishProgress(getString(R.string.status, time, WebPBackport.isLibraryUsed())); return WebPBackport.decode(encoded); } catch (IOException e) { throw new RuntimeException(e); } }
/** Starts the ringtone and/or vibrator */ void ring() { if (DBG) log("ring()..."); synchronized (this) { try { mHardwareService.setAttentionLight(true); } catch (RemoteException ex) { // the other end of this binder call is in the system process. } if (shouldVibrate() && mVibratorThread == null) { mContinueVibrating = true; mVibratorThread = new VibratorThread(); if (DBG) log("- starting vibrator..."); mVibratorThread.start(); } AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); if (audioManager.getStreamVolume(AudioManager.STREAM_RING) == 0) { if (DBG) log("skipping ring because volume is zero"); return; } makeLooper(); if (mFirstRingEventTime < 0) { mFirstRingEventTime = SystemClock.elapsedRealtime(); mRingHandler.sendEmptyMessage(PLAY_RING_ONCE); } else { // For repeat rings, figure out by how much to delay // the ring so that it happens the correct amount of // time after the previous ring if (mFirstRingStartTime > 0) { // Delay subsequent rings by the delta between event // and play time of the first ring if (DBG) { log("delaying ring by " + (mFirstRingStartTime - mFirstRingEventTime)); } mRingHandler.sendEmptyMessageDelayed( PLAY_RING_ONCE, mFirstRingStartTime - mFirstRingEventTime); // Math.min(mRingtone.getDuration(), 2000)); } else { // We've gotten two ring events so far, but the ring // still hasn't started. Reset the event time to the // time of this event to maintain correct spacing. mFirstRingEventTime = SystemClock.elapsedRealtime(); } } } }
@Override public void onCreate() { super.onCreate(); long startDate = SystemClock.elapsedRealtime(); mContext = this; ProfilingUtils.start("App Startup"); // Enable log recording AppLog.enableRecording(true); AppLog.i(T.UTILS, "WordPress.onCreate"); if (!PackageUtils.isDebugBuild()) { Fabric.with(this, new Crashlytics()); } versionName = PackageUtils.getVersionName(this); initWpDb(); enableHttpResponseCache(mContext); // EventBus setup EventBus.TAG = "WordPress-EVENT"; EventBus.builder() .logNoSubscriberMessages(false) .sendNoSubscriberEvent(false) .throwSubscriberException(true) .installDefaultEventBus(); EventBus.getDefault().register(this); RestClientUtils.setUserAgent(getUserAgent()); // Volley networking setup setupVolleyQueue(); AppLockManager.getInstance().enableDefaultAppLockIfAvailable(this); if (AppLockManager.getInstance().isAppLockFeatureEnabled()) { AppLockManager.getInstance() .getCurrentAppLock() .setDisabledActivities( new String[] {"org.wordpress.android.ui.ShareIntentReceiverActivity"}); } HelpshiftHelper.init(this); ApplicationLifecycleMonitor applicationLifecycleMonitor = new ApplicationLifecycleMonitor(); registerComponentCallbacks(applicationLifecycleMonitor); registerActivityLifecycleCallbacks(applicationLifecycleMonitor); initAnalytics(SystemClock.elapsedRealtime() - startDate); }
@Override void updateLatLng(@NonNull final Location location) { if (latLng == null) { // first location update latLng = new LatLng(location); locationUpdateTimestamp = SystemClock.elapsedRealtime(); } // update LatLng location previousLocation = latLng; latLng = new LatLng(location); // update LatLng direction if (location.hasBearing()) { gpsDirection = clamp(location.getBearing() - (float) mapboxMap.getCameraPosition().bearing); } // update LatLng accuracy updateAccuracy(location); // calculate updateLatLng time + add some extra offset to improve animation long previousUpdateTimeStamp = locationUpdateTimestamp; locationUpdateTimestamp = SystemClock.elapsedRealtime(); long locationUpdateDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * 1.2); // calculate interpolated entity interpolatedLocation = new LatLng( (latLng.getLatitude() + previousLocation.getLatitude()) / 2, (latLng.getLongitude() + previousLocation.getLongitude()) / 2); // animate changes if (locationChangeAnimator != null) { locationChangeAnimator.end(); locationChangeAnimator = null; } locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); locationChangeAnimator.setDuration((long) (locationUpdateDuration * 1.2)); locationChangeAnimator.addUpdateListener( new MarkerCoordinateAnimatorListener(this, previousLocation, interpolatedLocation)); locationChangeAnimator.setInterpolator(new FastOutLinearInInterpolator()); locationChangeAnimator.start(); // use interpolated location as current location latLng = interpolatedLocation; }
@VisibleForTesting ConnectivityTask(Profile profile, int timeoutMs, ConnectivityResult callback) { mTimeoutMs = timeoutMs; mCallback = callback; mStartCheckTimeMs = SystemClock.elapsedRealtime(); init(profile, timeoutMs); }
void finish(final String tag) { if (mRequestQueue != null) { mRequestQueue.finish(this); } if (MarkerLog.ENABLED) { final long threadId = Thread.currentThread().getId(); if (Looper.myLooper() != Looper.getMainLooper()) { Handler mainThread = new Handler(Looper.getMainLooper()); mainThread.post( new Runnable() { @Override public void run() { mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } }); return; } mEventLog.add(tag, threadId); mEventLog.finish(this.toString()); } else { long requestTime = SystemClock.elapsedRealtime() - mRequestBirthTime; if (requestTime >= SLOW_REQUEST_THRESHOLD_MS) { VolleyLog.d("%d ms: %s", requestTime, this.toString()); } } }
public void addMarker(String tag) { if (MarkerLog.ENABLED) { mEventLog.add(tag, Thread.currentThread().getId()); } else if (mRequestBirthTime == 0) { mRequestBirthTime = SystemClock.elapsedRealtime(); } }