List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:br.com.halph.agendafeliz.util.SwipeableRecyclerViewTouchListener.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalLayoutParamsHeight = lp.height; final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override/*ww w . j a va 2 s .c o m*/ public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingDismisses); int[] dismissPositions = new int[mPendingDismisses.size()]; for (int i = mPendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = mPendingDismisses.get(i).position; } if (mFinalDelta < 0) { mSwipeListener.onDismissedBySwipeLeft(mRecyclerView, dismissPositions); } else { mSwipeListener.onDismissedBySwipeRight(mRecyclerView, dismissPositions); } // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss // animation with a stale position mDownPosition = ListView.INVALID_POSITION; ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : mPendingDismisses) { // Reset view presentation pendingDismiss.view.setAlpha(mAlpha); pendingDismiss.view.setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalLayoutParamsHeight; pendingDismiss.view.setLayoutParams(lp); } // Send a cancel event long time = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0); mRecyclerView.dispatchTouchEvent(cancelEvent); mPendingDismisses.clear(); mAnimatingPosition = ListView.INVALID_POSITION; } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
From source file:org.secuso.privacyfriendlypasswordgenerator.helpers.SwipeableRecyclerViewTouchListener.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalLayoutParamsHeight = lp.height; final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override/* w w w . j a v a2 s . c o m*/ public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingDismisses); int[] dismissPositions = new int[mPendingDismisses.size()]; for (int i = mPendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = mPendingDismisses.get(i).position; } if (mFinalDelta < 0) { mSwipeListener.onDismissedBySwipeLeft(mRecyclerView, dismissPositions); // } else { // mSwipeListener.onDismissedBySwipeRight(mRecyclerView, dismissPositions); } // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss // animation with a stale position mDownPosition = ListView.INVALID_POSITION; ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : mPendingDismisses) { // Reset view presentation pendingDismiss.view.setAlpha(mAlpha); pendingDismiss.view.setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalLayoutParamsHeight; pendingDismiss.view.setLayoutParams(lp); } // Send a cancel event long time = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0); mRecyclerView.dispatchTouchEvent(cancelEvent); mPendingDismisses.clear(); mAnimatingPosition = ListView.INVALID_POSITION; } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
From source file:com.itude.mobile.mobbl.blueprint.app.view.listeners.SwipeDismissRecyclerViewTouchListener.java
private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight; if (mIsVertical) originalHeight = dismissView.getWidth(); else// ww w. j av a 2 s. c om originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingDismisses); int[] dismissPositions = new int[mPendingDismisses.size()]; for (int i = mPendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = mPendingDismisses.get(i).position; } mCallbacks.onDismiss(dismissView, dismissPosition); // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss // animation with a stale position mDownPosition = ListView.INVALID_POSITION; ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : mPendingDismisses) { // Reset view presentation pendingDismiss.view.setAlpha(1f); if (mIsVertical) pendingDismiss.view.setTranslationY(0); else pendingDismiss.view.setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); if (mIsVertical) lp.width = originalHeight; else lp.height = originalHeight; pendingDismiss.view.setLayoutParams(lp); } // Send a cancel event long time = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0); mRecyclerView.dispatchTouchEvent(cancelEvent); mPendingDismisses.clear(); } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { if (mIsVertical) lp.width = (Integer) valueAnimator.getAnimatedValue(); else lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
From source file:silent.kuasapmaterial.libs.ProgressWheel.java
@Override protected void onVisibilityChanged(@NonNull View changedView, int visibility) { super.onVisibilityChanged(changedView, visibility); if (visibility == VISIBLE) { lastTimeAnimated = SystemClock.uptimeMillis(); }/* w w w .j av a 2s. c om*/ }
From source file:org.chromium.chrome.browser.tabmodel.TabPersistentStore.java
/** * Restore saved state. Must be called before any tabs are added to the list. * * This will read the metadata file for the current TabPersistentStore and the metadata file * from another TabPersistentStore if applicable. When restoreTabs() is called, tabs from both * will be restored into this instance./* w w w .j a va2 s. c om*/ * * @param ignoreIncognitoFiles Whether to skip loading incognito tabs. */ public void loadState(boolean ignoreIncognitoFiles) { long time = SystemClock.uptimeMillis(); // If a cleanup task is in progress, cancel it before loading state. mPersistencePolicy.cancelCleanupInProgress(); waitForMigrationToFinish(); logExecutionTime("LoadStateTime", time); mCancelNormalTabLoads = false; mCancelIncognitoTabLoads = ignoreIncognitoFiles; mNormalTabsRestored = new SparseIntArray(); mIncognitoTabsRestored = new SparseIntArray(); try { long timeLoadingState = SystemClock.uptimeMillis(); assert mTabModelSelector.getModel(true).getCount() == 0; assert mTabModelSelector.getModel(false).getCount() == 0; checkAndUpdateMaxTabId(); DataInputStream stream; if (mPrefetchTabListTask != null) { long timeWaitingForPrefetch = SystemClock.uptimeMillis(); stream = mPrefetchTabListTask.get(); // Restore the tabs for this TabPeristentStore instance if the tab metadata file // exists. if (stream != null) { logExecutionTime("LoadStateInternalPrefetchTime", timeWaitingForPrefetch); mLoadInProgress = true; readSavedStateFile(stream, createOnTabStateReadCallback(mTabModelSelector.isIncognitoSelected(), false), null, false); logExecutionTime("LoadStateInternalTime", timeLoadingState); } } // Restore the tabs for the other TabPeristentStore instance if its tab metadata file // exists. if (mPrefetchTabListToMergeTask != null) { long timeMergingState = SystemClock.uptimeMillis(); stream = mPrefetchTabListToMergeTask.get(); if (stream != null) { logExecutionTime("MergeStateInternalFetchTime", timeMergingState); mPersistencePolicy.setMergeInProgress(true); readSavedStateFile(stream, createOnTabStateReadCallback(mTabModelSelector.isIncognitoSelected(), mTabsToRestore.size() == 0 ? false : true), null, true); logExecutionTime("MergeStateInternalTime", timeMergingState); RecordUserAction.record("Android.MergeState.ColdStart"); } } } catch (Exception e) { // Catch generic exception to prevent a corrupted state from crashing app on startup. Log.d(TAG, "loadState exception: " + e.toString(), e); } if (mObserver != null) mObserver.onInitialized(mTabsToRestore.size()); }
From source file:com.woofy.haifa.MapActivity.java
private boolean initMap() { if (mMap == null) { SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mMap = mapFrag.getMap();//from ww w . j av a2 s.com if (mMap != null) { mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() { @Override public View getInfoWindow(Marker marker) { // Getting view from the layout file LayoutInflater inflater = LayoutInflater.from(MapActivity.this); View v = inflater.inflate(R.layout.info_window, null); TextView locality = (TextView) v.findViewById(R.id.tv_locality); locality.setText(marker.getTitle()); // TextView title = (TextView) v.findViewById(R.id.tv_lat); // title.setText(marker.getTitle()); TextView address = (TextView) v.findViewById(R.id.tv_lng); address.setText(marker.getSnippet()); ImageView img = (ImageView) v.findViewById(R.id.imageView1); if (lastbitmap != null) { img.setImageBitmap(lastbitmap); } if (pic_map.containsKey(marker.getTitle())) { img.setImageBitmap(pic_map.get(marker.getTitle())); } if (marker.getTitle().equals("You")) { img.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.you_marker)); } if (marker.getSnippet().length() < 30) { // img.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.bad_dog)); new HttpLib.MarkerPic(marker.getTitle(), img, marker).execute(); // HttpLib.DownloadImageTask task=new HttpLib.DownloadImageTask(img,marker); // task.execute("http://52.1.192.145/uploads/img_1434327703156_kgqsjhlevp9fj6tcs7su32gj43.jpg"); // Vector<BasicNameValuePair> vec = new Vector<BasicNameValuePair>(); vec.add(new BasicNameValuePair("name", marker.getTitle())); new HttpLib.MarkerInfoWindow(vec, marker).execute(); } return v; // return null; } @Override public View getInfoContents(Marker marker) { View v = getLayoutInflater().inflate(R.layout.info_window, null); TextView tvLocality = (TextView) v.findViewById(R.id.tv_locality); TextView tvLat = (TextView) v.findViewById(R.id.tv_lat); TextView tvLng = (TextView) v.findViewById(R.id.tv_lng); TextView tvSnippet = (TextView) v.findViewById(R.id.tv_snippet); // ImageView img = (ImageView) v.findViewById(R.id.imageView1); LatLng ll = marker.getPosition(); tvLocality.setText(marker.getTitle()); // tvLat.setText("Dogs: " + "Woofy, Goofy"); // tvLng.setText("Click for more info"); // tvSnippet.setText(marker.getSnippet()); ImageView img = (ImageView) v.findViewById(R.id.imageView1); if (lastbitmap != null) { img.setImageBitmap(lastbitmap); Log.d("Set bitmap", "Set bitmap"); } else { new HttpLib.MarkerPic(marker.getTitle(), img, marker).execute(); } if (marker.getSnippet().length() < 30) { // img.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.bad_dog)); // HttpLib.DownloadImageTask task=new HttpLib.DownloadImageTask(img,marker); // task.execute("http://52.1.192.145/uploads/img_1434327703156_kgqsjhlevp9fj6tcs7su32gj43.jpg"); // Vector<BasicNameValuePair> vec = new Vector<BasicNameValuePair>(); vec.add(new BasicNameValuePair("name", marker.getTitle())); new HttpLib.MarkerInfoWindow(vec, marker).execute(); } return v; } }); mMap.setOnMapLongClickListener(new OnMapLongClickListener() { @Override public void onMapLongClick(final LatLng point) { final Dialog dialog = new Dialog(MapActivity.this); dialog.setContentView(R.layout.alert_layout); dialog.setCancelable(true); dialog.show(); // .setMessage(R.string.really_quit) Button b = (Button) dialog.findViewById(R.id.yesmeet); b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String t1 = ((EditText) dialog.findViewById(R.id.meet_name)).getText().toString(); // String t2 = ((EditText)dialog.findViewById(R.id.editText1111)).getText().toString(); if (meet != null) meet.remove(); MarkerOptions options; options = new MarkerOptions().title(t1).position(point) .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher)) .anchor(.5f, .5f) //center the icon .draggable(true); Marker mar = mMap.addMarker(options); // MeetingMarkers.add(mar); meet = mar; dialog.dismiss(); } }); Button b1 = (Button) dialog.findViewById(R.id.nomeet); b1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); } }); mMap.setOnCameraChangeListener(new OnCameraChangeListener() { @Override public void onCameraChange(CameraPosition position) { if (SystemClock.uptimeMillis() - show_people_last_updated > 1000) { show_people_last_updated = SystemClock.uptimeMillis(); showPeople(); } } }); mMap.setOnMarkerClickListener(new OnMarkerClickListener() { @Override public boolean onMarkerClick(final Marker marker) { lastbitmap = null; marker.hideInfoWindow(); marker.showInfoWindow(); return false; } }); mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(Marker marker) { Log.d("Open profile page", marker.getTitle()); Intent intent = new Intent(MapActivity.this, Profile.class); intent.putExtra("name", marker.getTitle()); startActivity(intent); } }); mMap.setOnMarkerDragListener(new OnMarkerDragListener() { @Override public void onMarkerDragStart(Marker marker) { marker.remove(); MarkerOptions options; options = new MarkerOptions().title(marker.getTitle()).position(marker.getPosition()) .icon(BitmapDescriptorFactory.fromResource(R.drawable.custom_marker)) .anchor(.5f, .5f) //center the icon .draggable(true); String name = marker.getTitle(); if (selected_markers.contains(name)) { selected_markers.remove(name); } else { selected_markers.add(name); options.icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_checked)); } Marker addmarker = mMap.addMarker(options); PersonMarkers.add(addmarker); } @Override public void onMarkerDragEnd(Marker marker) { } @Override public void onMarkerDrag(Marker arg0) { } }); } } return (mMap != null); }
From source file:android.support.designox.widget.CoordinatorLayout.java
/** * Reset all Behavior-related tracking records either to clean up or in preparation * for a new event stream. This should be called when attached or detached from a window, * in response to an UP or CANCEL event, when intercept is request-disallowed * and similar cases where an event stream in progress will be aborted. *///ww w.ja v a 2 s.c o m private void resetTouchBehaviors() { if (mBehaviorTouchView != null) { final Behavior b = ((LayoutParams) mBehaviorTouchView.getLayoutParams()).getBehavior(); if (b != null) { final long now = SystemClock.uptimeMillis(); final MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); b.onTouchEvent(this, mBehaviorTouchView, cancelEvent); cancelEvent.recycle(); } mBehaviorTouchView = null; } final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { final View child = getChildAt(i); final LayoutParams lp = (LayoutParams) child.getLayoutParams(); lp.resetTouchBehaviorTracking(); } }
From source file:krishan.dhancha.view.superlistview.SwipeDismissListViewTouchListener.java
private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override//w w w .j av a2s. c o m public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingDismisses); int[] dismissPositions = new int[mPendingDismisses.size()]; for (int i = mPendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = mPendingDismisses.get(i).position; } mCallbacks.onDismiss(mListView, dismissPositions); // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss // animation with a stale position mDownPosition = ListView.INVALID_POSITION; ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : mPendingDismisses) { // Reset view presentation AnimatorProxy.wrap(pendingDismiss.view).setAlpha(1f); AnimatorProxy.wrap(pendingDismiss.view).setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalHeight; pendingDismiss.view.setLayoutParams(lp); } // Send a cancel event long time = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0); mListView.dispatchTouchEvent(cancelEvent); mPendingDismisses.clear(); } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
From source file:com.marshalchen.common.uimodule.superlistview.SwipeDismissListViewTouchListener.java
private void performDismiss(final View dismissView, final int dismissPosition) { // Animate the dismissed list item to zero-height and fire the dismiss callback when // all dismissed list item animations have completed. This triggers layout on each animation // frame; in the future we may want to do something smarter and more performant. final ViewGroup.LayoutParams lp = dismissView.getLayoutParams(); final int originalHeight = dismissView.getHeight(); ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime); animator.addListener(new AnimatorListenerAdapter() { @Override/*from ww w . ja v a 2s .c om*/ public void onAnimationEnd(Animator animation) { --mDismissAnimationRefCount; if (mDismissAnimationRefCount == 0) { // No active animations, process all pending dismisses. // Sort by descending position Collections.sort(mPendingDismisses); int[] dismissPositions = new int[mPendingDismisses.size()]; for (int i = mPendingDismisses.size() - 1; i >= 0; i--) { dismissPositions[i] = mPendingDismisses.get(i).position; } mCallbacks.onDismiss(mListView, dismissPositions); // Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss // animation with a stale position mDownPosition = ListView.INVALID_POSITION; ViewGroup.LayoutParams lp; for (PendingDismissData pendingDismiss : mPendingDismisses) { // Reset view presentation AnimatorProxy.wrap(pendingDismiss.view).setAlpha(1f); AnimatorProxy.wrap(pendingDismiss.view).setTranslationX(0); lp = pendingDismiss.view.getLayoutParams(); lp.height = originalHeight; pendingDismiss.view.setLayoutParams(lp); } // Send a cancel event long time = SystemClock.uptimeMillis(); MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0); mListView.dispatchTouchEvent(cancelEvent); mPendingDismisses.clear(); } } }); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { lp.height = (Integer) valueAnimator.getAnimatedValue(); dismissView.setLayoutParams(lp); } }); mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView)); animator.start(); }
From source file:com.oginotihiro.datepicker.DatePickerDialog.java
@Override public void tryVibrate() { if (mVibrator != null && mVibrate) { long timeInMillis = SystemClock.uptimeMillis(); if (timeInMillis - mLastVibrate >= 125L) { mVibrator.vibrate(20L);/*w w w . ja v a2 s.com*/ mLastVibrate = timeInMillis; } } }