List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:info.staticfree.android.units.Units.java
private void sendTextAsSoftKeyboard(String text) { dispatchKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), text, Units.class.hashCode(), KeyEvent.FLAG_SOFT_KEYBOARD)); }
From source file:info.staticfree.android.units.Units.java
private void sendTextAsSoftKeyboard(String text, boolean moveToDefault) { dispatchKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), text, Units.class.hashCode(), KeyEvent.FLAG_SOFT_KEYBOARD)); if (moveToDefault) { workspace.moveToDefaultScreen(); }/* w w w . jav a2 s . c o m*/ }
From source file:com.iride.ayride.HomePageActivity.java
private void animateMarkerTo(final Marker marker, final double lat, final double lng) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final long DURATION_MS = 1000; final Interpolator interpolator = new AccelerateDecelerateInterpolator(); final LatLng startPosition = marker.getPosition(); handler.post(new Runnable() { @Override/*from w w w .j a va 2s . c o m*/ public void run() { float elapsed = SystemClock.uptimeMillis() - start; float t = elapsed / DURATION_MS; float v = interpolator.getInterpolation(t); double currentLat = (lat - startPosition.latitude) * v + startPosition.latitude; double currentLng = (lng - startPosition.longitude) * v + startPosition.longitude; marker.setPosition(new LatLng(currentLat, currentLng)); // if animation is not finished yet, repeat if (t < 1) { handler.postDelayed(this, 16); } } }); }
From source file:com.mycompany.myfirstindoorsapp.PagedActivity.java
void onAccelChanged(double[] accelData) //store accelData { if (kalman != null) { long time = SystemClock.uptimeMillis(); kalman.predict(new ArrayRealVector(accelData)); double[] estimatedState; estimatedState = kalman.getStateEstimationVector().toArray(); data.addToFilter(time, new Coordinate((int) estimatedState[0], (int) estimatedState[1], FLOORLVL)); Log.d("velocityvelocity", "" + estimatedState[2] + " | " + estimatedState[3]); if (null != overlayKalman) { indoorsSurfaceFragment.removeOverlay(overlayKalman); overlayKalman = null;//from w w w . ja va 2 s. co m } overlayKalman = new RedSurfaceOverlay( new Coordinate((int) estimatedState[0], (int) estimatedState[1], FLOORLVL)); indoorsSurfaceFragment.addOverlay(overlayKalman); indoorsSurfaceFragment.updateSurface(); } }
From source file:me.spadival.podmode.PodModeService.java
public void broadcastMediaButtons(int keyCode, String app) { long eventtime = SystemClock.uptimeMillis(); Intent downIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); KeyEvent downEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_DOWN, keyCode, 0); downIntent.putExtra(Intent.EXTRA_KEY_EVENT, downEvent); if (app != null) downIntent.setPackage(app);//from w w w . ja v a 2s . c om sendOrderedBroadcast(downIntent, null); eventtime = SystemClock.uptimeMillis(); Intent upIntent = new Intent(Intent.ACTION_MEDIA_BUTTON, null); KeyEvent upEvent = new KeyEvent(eventtime, eventtime, KeyEvent.ACTION_UP, keyCode, 0); upIntent.putExtra(Intent.EXTRA_KEY_EVENT, upEvent); if (app != null) upIntent.setPackage(app); sendOrderedBroadcast(upIntent, null); }
From source file:org.mozilla.gecko.AwesomeBarTabs.java
private void addAllPagesTab() { Log.d(LOGTAG, "Creating All Pages tab"); addAwesomeTab(ALL_PAGES_TAB, R.string.awesomebar_all_pages_title, R.id.all_pages_list); // Load the list using a custom adapter so we can create the bitmaps mAllPagesCursorAdapter = new AwesomeBarCursorAdapter(mContext, R.layout.awesomebar_row, null, new String[] { URLColumns.TITLE, URLColumns.URL, URLColumns.FAVICON }, new int[] { R.id.title, R.id.url, R.id.favicon }); mAllPagesCursorAdapter.setViewBinder(new AwesomeCursorViewBinder()); mAllPagesCursorAdapter.setFilterQueryProvider(new FilterQueryProvider() { public Cursor runQuery(CharSequence constraint) { long start = SystemClock.uptimeMillis(); Cursor c = BrowserDB.filter(mContentResolver, constraint, MAX_RESULTS); c.getCount(); // ensure the query runs at least once long end = SystemClock.uptimeMillis(); Log.i(LOGTAG, "Got cursor in " + (end - start) + "ms"); return c; }/*from w ww. j av a 2s.c om*/ }); final ListView allPagesList = (ListView) findViewById(R.id.all_pages_list); allPagesList.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { handleItemClick(allPagesList, position); } }); allPagesList.setAdapter(mAllPagesCursorAdapter); allPagesList.setOnTouchListener(mListTouchListener); }
From source file:com.android.launcher3.Folder.java
public void onDragOver(DragObject d) { final DragView dragView = d.dragView; final int scrollOffset = mScrollView.getScrollY(); final float[] r = getDragViewVisualCenter(d.x, d.y, d.xOffset, d.yOffset, dragView, null); r[0] -= getPaddingLeft();/*from ww w . j a v a2s. c o m*/ r[1] -= getPaddingTop(); final long downTime = SystemClock.uptimeMillis(); final MotionEvent translatedEv = MotionEvent.obtain(downTime, downTime, MotionEvent.ACTION_MOVE, d.x, d.y, 0); if (!mAutoScrollHelper.isEnabled()) { mAutoScrollHelper.setEnabled(true); } final boolean handled = mAutoScrollHelper.onTouch(this, translatedEv); translatedEv.recycle(); if (handled) { mReorderAlarm.cancelAlarm(); } else { mTargetCell = mContent.findNearestArea((int) r[0], (int) r[1] + scrollOffset, 1, 1, mTargetCell); if (isLayoutRtl()) { mTargetCell[0] = mContent.getCountX() - mTargetCell[0] - 1; } if (mTargetCell[0] != mPreviousTargetCell[0] || mTargetCell[1] != mPreviousTargetCell[1]) { mReorderAlarm.cancelAlarm(); mReorderAlarm.setOnAlarmListener(mReorderAlarmListener); mReorderAlarm.setAlarm(REORDER_DELAY); mPreviousTargetCell[0] = mTargetCell[0]; mPreviousTargetCell[1] = mTargetCell[1]; } } }
From source file:com.android.mail.ui.ConversationViewFragment.java
private void renderConversation(MessageCursor messageCursor) { final String convHtml = renderMessageBodies(messageCursor, mEnableContentReadySignal); timerMark("rendered conversation"); if (DEBUG_DUMP_CONVERSATION_HTML) { java.io.FileWriter fw = null; try {/*w w w .j av a 2 s .c o m*/ fw = new java.io.FileWriter(getSdCardFilePath()); fw.write(convHtml); } catch (java.io.IOException e) { e.printStackTrace(); } finally { if (fw != null) { try { fw.close(); } catch (java.io.IOException e) { e.printStackTrace(); } } } } // save off existing scroll position before re-rendering if (mWebViewLoadedData) { mWebViewYPercent = calculateScrollYPercent(); } mWebView.loadDataWithBaseURL(mBaseUri, convHtml, "text/html", "utf-8", null); mWebViewLoadedData = true; mWebViewLoadStartMs = SystemClock.uptimeMillis(); }
From source file:com.android.yijiang.kzx.widget.betterpickers.radialtimepicker.RadialPickerLayout.java
/** * Try to vibrate. To prevent this becoming a single continuous vibration, nothing will happen if we have vibrated * very recently./*ww w . ja v a2s . c om*/ */ public void tryVibrate() { if (mVibrator != null) { long now = SystemClock.uptimeMillis(); // We want to try to vibrate each individual tick discretely. if (now - mLastVibrate >= 125) { mVibrator.vibrate(5); mLastVibrate = now; } } }
From source file:com.a.mirko.android.datetimepicker.time.RadialPickerLayout.java
/** * Try to vibrate. To prevent this becoming a single continuous vibration, nothing will * happen if we have vibrated very recently. *///from w w w . j a va 2 s . c o m public void tryVibrate() { if (mVibrate && mVibrator != null) { long now = SystemClock.uptimeMillis(); // We want to try to vibrate each individual tick discretely. if (now - mLastVibrate >= 125) { mVibrator.vibrate(5); mLastVibrate = now; } } }