List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:org.openqa.selendroid.server.model.AndroidNativeElement.java
private void clickOnScreen(float x, float y) { final ServerInstrumentation inst = ServerInstrumentation.getInstance(); long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); final MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); final MotionEvent event2 = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0); try {/*from w w w.j a v a 2 s . c o m*/ inst.sendPointerSync(event); inst.sendPointerSync(event2); try { Thread.sleep(300); } catch (InterruptedException ignored) { } } catch (SecurityException e) { SelendroidLogger.log("error while clicking element", e); } }
From source file:com.tapcentive.sdk.touchpoint.nfc.SEManager.java
/** * Fetch all descriptions./*from w w w . ja v a 2s .c o m*/ * * @return the byte[] * @throws IOException Signals that an I/O exception has occurred. * @throws TapcentiveException the tap centive exception */ public byte[] fetchAllDescriptions() throws IOException, TapcentiveException { //DescriptionResponse description; long time1 = SystemClock.uptimeMillis(); byte[] response = sendAndReceive(readAllDescriptions); long time2 = SystemClock.uptimeMillis(); Log.d(TAG, "TIME: fetchAllDescriptions:sendAndReceive=" + (time2 - time1)); return response; }
From source file:com.ternup.caddisfly.fragment.FormFragment.java
public void showKeyboard() { if (mPlaceEditText.getEditText().getText().toString().isEmpty()) { (new Handler()).postDelayed(new Runnable() { public void run() { mPlaceEditText.getEditText().dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_DOWN, 0, 0, 0)); mPlaceEditText.getEditText().dispatchTouchEvent(MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), MotionEvent.ACTION_UP, 0, 0, 0)); }// w w w. jav a2s.c o m }, 300); } /* InputMethodManager imm = (InputMethodManager) getActivity().getSystemService( Context.INPUT_METHOD_SERVICE); imm.showSoftInput(mPlaceEditText.getInputControl(), InputMethodManager.SHOW_FORCED); */ }
From source file:com.example.map.BasicMapActivity.java
public void animateMarker(final Marker marker, final LatLng toPosition, final boolean hideMarker) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); Projection proj = mMap.getProjection(); Point startPoint = proj.toScreenLocation(marker.getPosition()); final LatLng startLatLng = proj.fromScreenLocation(startPoint); final long duration = 500; final Interpolator interpolator = new LinearInterpolator(); handler.post(new Runnable() { @Override//from ww w. ja va 2 s . co m public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * toPosition.longitude + (1 - t) * startLatLng.longitude; double lat = t * toPosition.latitude + (1 - t) * startLatLng.latitude; marker.setPosition(new LatLng(lat, lng)); if (t < 1.0) { // Post again 16ms later. handler.postDelayed(this, 16); } else { if (hideMarker) { marker.setVisible(false); } else { marker.setVisible(true); } } } }); }
From source file:android.example.com.visualizerpreferences.AudioVisuals.VisualizerView.java
/** * Calculates, based on the current time, the angle all of the shapes should be at * * @return The current angle, in radians, that all shapes should be at */// ww w . ja v a 2s. c o m private double calcCurrentAngle() { long elapsedTime = SystemClock.uptimeMillis() - mStartTime; float revolutions = elapsedTime * REVOLUTIONS_PER_SECOND / 1000; return revolutions * 2 * Math.PI; }
From source file:cn.com.dfc.pl.afinal.http.HttpHandler.java
private void handleResponse(HttpResponse response) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() >= 300) { String errorMsg = "response status error code:" + status.getStatusCode(); if (status.getStatusCode() == 416 && isResume) { errorMsg += " \n maybe you have download complete."; }/*from w w w.j av a 2 s .c o m*/ publishProgress(UPDATE_FAILURE, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), status.getStatusCode(), errorMsg); } else { try { HttpEntity entity = response.getEntity(); Object responseBody = null; if (entity != null) { time = SystemClock.uptimeMillis(); if (targetUrl != null) { responseBody = mFileEntityHandler.handleEntity(entity, this, targetUrl, isResume); } else { responseBody = mStrEntityHandler.handleEntity(entity, this, charset); } } publishProgress(UPDATE_SUCCESS, responseBody); } catch (IOException e) { publishProgress(UPDATE_FAILURE, e, 0, e.getMessage()); } } }
From source file:com.dongfang.net.http.HttpHandler.java
@Override protected Void doInBackground(Object... params) { if (params == null || params.length < 1) return null; if (params.length > 3) { fileSavePath = String.valueOf(params[1]); isDownloadingFile = fileSavePath != null; autoResume = (Boolean) params[2]; autoRename = (Boolean) params[3]; }//from ww w . j a v a2s . co m try { // init request & requestUrl request = (HttpRequestBase) params[0]; requestUrl = request.getURI().toString(); if (callback != null) { callback.setRequestUrl(requestUrl); } this.publishProgress(UPDATE_START); lastUpdateTime = SystemClock.uptimeMillis(); ResponseInfo<T> responseInfo = sendRequest(request); if (responseInfo != null) { this.publishProgress(UPDATE_SUCCESS, responseInfo); return null; } } catch (HttpException e) { this.publishProgress(UPDATE_FAILURE, e, e.getMessage()); } return null; }
From source file:com.samebits.beacon.locator.ui.view.RadarScanView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int center = getWidth() / 2; int radius = center - 8; // Draw the rings final Paint gridPaint = mGridPaint; canvas.drawCircle(center, center, radius, gridPaint); canvas.drawCircle(center, center, radius * 3 / 4, gridPaint); canvas.drawCircle(center, center, radius >> 1, gridPaint); canvas.drawCircle(center, center, radius >> 2, gridPaint); int blipRadius = (int) (mDistanceRatio * radius); final long now = SystemClock.uptimeMillis(); if (mSweepTime > 0) { // Draw the sweep. Radius is determined by how long ago it started long sweepDifference = now - mSweepTime; if (sweepDifference < 512L) { int sweepRadius = (int) (((radius + 6) * sweepDifference) >> 9); canvas.drawCircle(center, center, sweepRadius, mSweepPaint0); canvas.drawCircle(center, center, sweepRadius - 2, mSweepPaint1); canvas.drawCircle(center, center, sweepRadius - 4, mSweepPaint2); // Note when the sweep has passed the blip boolean before = sweepRadius < blipRadius; if (!before && mSweepBefore) { mSweepBefore = false;// ww w. jav a 2s . c o m mBlipTime = now; } } else { mSweepTime = now + 1000; mSweepBefore = true; } postInvalidate(); } // Draw horizontal and vertical lines canvas.drawLine(center, center - (radius >> 2) + 6, center, center - radius - 6, gridPaint); canvas.drawLine(center, center + (radius >> 2) - 6, center, center + radius + 6, gridPaint); canvas.drawLine(center - (radius >> 2) + 6, center, center - radius - 6, center, gridPaint); canvas.drawLine(center + (radius >> 2) - 6, center, center + radius + 6, center, gridPaint); // Draw X in the center of the screen canvas.drawLine(center - 4, center - 4, center + 4, center + 4, gridPaint); canvas.drawLine(center - 4, center + 4, center + 4, center - 4, gridPaint); if (mHaveDetected) { // Draw the blip. Alpha is based on how long ago the sweep crossed the blip long blipDifference = now - mBlipTime; gridPaint.setAlpha(255 - (int) ((128 * blipDifference) >> 10)); double bearingToTarget = mLast_bearing; double drawingAngle = Math.toRadians(bearingToTarget) - (Math.PI / 2); float cos = (float) Math.cos(drawingAngle); float sin = (float) Math.sin(drawingAngle); addText(canvas, getRatioDistanceText(0.25f), center, center + (radius >> 2)); addText(canvas, getRatioDistanceText(0.5f), center, center + (radius >> 1)); addText(canvas, getRatioDistanceText(0.75f), center, center + radius * 3 / 4); addText(canvas, getRatioDistanceText(1.0f), center, center + radius); for (Map.Entry<String, DetectedBeacon> entry : mBeacons.entrySet()) { //String key = entry.getKey(); DetectedBeacon dBeacon = entry.getValue(); System.out.println("value: " + dBeacon); // drawing the beacon if (((System.currentTimeMillis() - dBeacon.getTimeLastSeen()) / 1000 < 5)) { canvas.drawBitmap(mBlip, center + (cos * distanceToPix(dBeacon.getDistance())) - 8, center + (sin * distanceToPix(dBeacon.getDistance())) - 8, gridPaint); } } gridPaint.setAlpha(255); } }
From source file:com.miku.framelite.httpx.core.DownloadHandler.java
private void handleResponse(HttpResponse response) { StatusLine status = response.getStatusLine(); if (status.getStatusCode() >= 300) { String errorMsg = "response status error code:" + status.getStatusCode(); if (status.getStatusCode() == 416 && isResume) { errorMsg += " \n maybe you have download complete."; }/*from www . j ava 2 s . co m*/ publishProgress(UPDATE_FAILURE, new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), status.getStatusCode(), errorMsg); } else { try { HttpEntity entity = response.getEntity(); Object responseBody = null; if (entity != null) { time = SystemClock.uptimeMillis(); if (targetUrl != null) { responseBody = handleEntity(entity, targetUrl, isResume); } } publishProgress(UPDATE_SUCCESS, responseBody); } catch (IOException e) { publishProgress(UPDATE_FAILURE, e, 0, e.getMessage()); } } }