List of usage examples for android.animation ObjectAnimator start
@Override public void start()
From source file:com.mina.breathitout.AnalyzeActivity.java
private void moveRight() { AnalyzeActivity.this.runOnUiThread(new Runnable() { @Override//from ww w.j a v a 2 s .c o m public void run() { mViewFlipper.setInAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_in)); mViewFlipper.setOutAnimation(AnimationUtils.loadAnimation(mContext, R.anim.left_out)); // controlling animation mViewFlipper.getInAnimation().setAnimationListener(mAnimationListener); if (android.os.Build.VERSION.SDK_INT >= 11) { // will update the "progress" propriety of seekbar until it reaches progress ObjectAnimator progressAnimation = ObjectAnimator.ofInt(progressBar, "progress", lastMaxTime, 0); progressAnimation.setDuration(1000); // 0.5 second progressAnimation.setInterpolator(new DecelerateInterpolator()); progressAnimation.start(); } else progressBar.setProgress(0); // no animation on Gingerbread or lower mViewFlipper.showNext(); } }); }
From source file:net.tjohns.badgescanner.ScanActivity.java
public void flipToBack(View view) { // animate the card transition. We do this in 3 steps: // 1. Rotate out the front fragment // 2. Switch the fragments // 3. Rotate in the back if (Build.VERSION.SDK_INT > 11) { ObjectAnimator anim = ObjectAnimator.ofFloat(findViewById(R.id.card_front), ROTATION_AXIS_PROP, 0, 90) .setDuration(ROTATION_HALF_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override//from w w w .j a va2 s.co m public void onAnimationEnd(Animator animation) { findViewById(R.id.card_front).setVisibility(View.GONE); findViewById(R.id.card_back).setVisibility(View.VISIBLE); // rotate in the new note ObjectAnimator.ofFloat(findViewById(R.id.card_back), ROTATION_AXIS_PROP, -90, 0).start(); } }); anim.start(); } else { // Running on Gingerbread, animation class not available findViewById(R.id.card_front).setVisibility(View.GONE); findViewById(R.id.card_back).setVisibility(View.VISIBLE); } }
From source file:net.tjohns.badgescanner.ScanActivity.java
public void flipToFront(View view) { // animate the card transition. We do this in 3 steps: // 1. Rotate out the back fragment // 2. Switch the fragments // 3. Rotate in the front if (Build.VERSION.SDK_INT > 11) { ObjectAnimator anim = ObjectAnimator.ofFloat(findViewById(R.id.card_back), ROTATION_AXIS_PROP, 0, -90) .setDuration(ROTATION_HALF_DURATION); anim.addListener(new AnimatorListenerAdapter() { @Override/* ww w . j a va2s .c om*/ public void onAnimationEnd(Animator animation) { findViewById(R.id.card_back).setVisibility(View.GONE); findViewById(R.id.card_front).setVisibility(View.VISIBLE); // rotate in the new note ObjectAnimator.ofFloat(findViewById(R.id.card_front), ROTATION_AXIS_PROP, 90, 0).start(); } }); anim.start(); } else { // Running on Gingerbread, animation class not available findViewById(R.id.card_back).setVisibility(View.GONE); findViewById(R.id.card_front).setVisibility(View.VISIBLE); } }
From source file:com.josecalles.porridge.widget.BottomSheet.java
@Override public void onStopNestedScroll(View child) { final int dragDisplacement = dragView.getTop() - dragViewTop; if (dragDisplacement == 0) return;/*from w w w .j a v a 2 s. c om*/ // check if we should perform a dismiss or settle back into place final boolean dismiss = lastNestedScrollWasDownward && dragDisplacement >= dragDismissDistance; // animate either back into place or to bottom ObjectAnimator settleAnim = ObjectAnimator.ofInt(dragViewOffsetHelper, ViewOffsetHelper.OFFSET_Y, dragView.getTop(), dismiss ? dragViewBottom : dragViewTop); settleAnim.setDuration(200L); settleAnim.setInterpolator( AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in)); if (dismiss) { settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchDismissCallback(); } }); } settleAnim.start(); }
From source file:com.hannesdorfmann.home.filter.FilterAdapter.java
@Override public FilterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) { final FilterViewHolder holder = new FilterViewHolder( LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.filter_item, viewGroup, false)); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override//from www.java2s . c om public void onClick(View v) { final int position = holder.getAdapterPosition(); if (position == RecyclerView.NO_POSITION) return; final SourceFilterPresentationModel filter = filters.get(position); holder.itemView.setHasTransientState(true); ObjectAnimator fade = ObjectAnimator.ofInt(holder.filterIcon, ViewUtils.IMAGE_ALPHA, filter.getEnabled() ? FILTER_ICON_DISABLED_ALPHA : FILTER_ICON_ENABLED_ALPHA); fade.setDuration(300); fade.setInterpolator(AnimationUtils.loadInterpolator(holder.itemView.getContext(), android.R.interpolator.fast_out_slow_in)); fade.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.itemView.setHasTransientState(false); clickedListener.onSourceFilterClicked(filter); } }); fade.start(); } }); return holder; }
From source file:hide.com.android.datetimepicker.date.DatePickerDialog.java
private void setCurrentView(final int viewIndex) { long millis = mCalendar.getTimeInMillis(); switch (viewIndex) { case MONTH_AND_DAY_VIEW: ObjectAnimator pulseAnimator = startAnimator(mMonthAndDayView, 0.9f, 1.05f); mDayPickerView.onDateChanged();/*from www. jav a2 s. co m*/ if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(true); mYearView.setSelected(false); mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW); mCurrentView = viewIndex; } if (pulseAnimator != null) { pulseAnimator.start(); } int flags = DateUtils.FORMAT_SHOW_DATE; String dayString = DateUtils.formatDateTime(getActivity(), millis, flags); mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString); Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay); break; case YEAR_VIEW: pulseAnimator = startAnimator(mYearView, 0.85f, 1.1f); mYearPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(false); mYearView.setSelected(true); mAnimator.setDisplayedChild(YEAR_VIEW); mCurrentView = viewIndex; } if (pulseAnimator != null) { pulseAnimator.start(); } CharSequence yearString = YEAR_FORMAT.format(millis); mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString); Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear); break; } }
From source file:com.mina.breathitout.AnalyzeActivity.java
public void animateProgressBar() { AnalyzeActivity.this.runOnUiThread(new Runnable() { @Override//from w w w. ja v a 2 s . co m public void run() { if (android.os.Build.VERSION.SDK_INT >= 11) { // will update the "progress" propriety of seekbar until it reaches progress ObjectAnimator progressAnimation = ObjectAnimator.ofInt(progressBar, "progress", progressBar.getProgress(), lastMaxTime); progressAnimation.setDuration(1000); // 0.5 second progressAnimation.setInterpolator(new DecelerateInterpolator()); progressAnimation.start(); } else progressBar.setProgress(timerCounter); // no animation on Gingerbread or lower } }); }
From source file:com.android.contacts.activities.PhotoSelectionActivity.java
private void displayPhoto() { // Animate the photo view into its end location. final int[] pos = new int[2]; mBackdrop.getLocationOnScreen(pos);/* w w w. j a v a 2 s . c o m*/ LayoutParams layoutParams = new LayoutParams(mSourceBounds.width(), mSourceBounds.height()); mOriginalPos.left = mSourceBounds.left - pos[0]; mOriginalPos.top = mSourceBounds.top - pos[1]; mOriginalPos.right = mOriginalPos.left + mSourceBounds.width(); mOriginalPos.bottom = mOriginalPos.top + mSourceBounds.height(); layoutParams.setMargins(mOriginalPos.left, mOriginalPos.top, mOriginalPos.right, mOriginalPos.bottom); mPhotoStartParams = layoutParams; mPhotoView.setLayoutParams(layoutParams); mPhotoView.requestLayout(); // Load the photo. int photoWidth = getPhotoEndParams().width; if (mPhotoUri != null) { // If we have a URI, the bitmap should be cached directly. ContactPhotoManager.getInstance(this).loadPhoto(mPhotoView, mPhotoUri, photoWidth, false); } else { // Fall back to avatar image. mPhotoView.setImageResource(ContactPhotoManager.getDefaultAvatarResId(this, photoWidth, false)); } mPhotoView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (mAnimationPending) { mAnimationPending = false; PropertyValuesHolder pvhLeft = PropertyValuesHolder.ofInt("left", mOriginalPos.left, left); PropertyValuesHolder pvhTop = PropertyValuesHolder.ofInt("top", mOriginalPos.top, top); PropertyValuesHolder pvhRight = PropertyValuesHolder.ofInt("right", mOriginalPos.right, right); PropertyValuesHolder pvhBottom = PropertyValuesHolder.ofInt("bottom", mOriginalPos.bottom, bottom); ObjectAnimator anim = ObjectAnimator .ofPropertyValuesHolder(mPhotoView, pvhLeft, pvhTop, pvhRight, pvhBottom) .setDuration(PHOTO_EXPAND_DURATION); if (mAnimationListener != null) { anim.addListener(mAnimationListener); } anim.start(); } } }); attachPhotoHandler(); }
From source file:io.plaidapp.ui.SearchActivity.java
@OnClick(R.id.fab) protected void save() { // show the save confirmation bubble fab.setVisibility(View.INVISIBLE); confirmSaveContainer.setVisibility(View.VISIBLE); resultsScrim.setVisibility(View.VISIBLE); // expand it once it's been measured and show a scrim over the search results confirmSaveContainer.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override/* w ww .j a va 2 s .c om*/ public boolean onPreDraw() { // expand the confirmation confirmSaveContainer.getViewTreeObserver().removeOnPreDrawListener(this); Animator reveal = ViewAnimationUtils.createCircularReveal(confirmSaveContainer, confirmSaveContainer.getWidth() / 2, confirmSaveContainer.getHeight() / 2, fab.getWidth() / 2, confirmSaveContainer.getWidth() / 2); reveal.setDuration(250L); reveal.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); reveal.start(); // show the scrim int centerX = (fab.getLeft() + fab.getRight()) / 2; int centerY = (fab.getTop() + fab.getBottom()) / 2; Animator revealScrim = ViewAnimationUtils.createCircularReveal(resultsScrim, centerX, centerY, 0, (float) Math.hypot(centerX, centerY)); revealScrim.setDuration(400L); revealScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); revealScrim.start(); ObjectAnimator fadeInScrim = ObjectAnimator.ofArgb(resultsScrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim)); fadeInScrim.setDuration(800L); fadeInScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); fadeInScrim.start(); // ease in the checkboxes saveDribbble.setAlpha(0.6f); saveDribbble.setTranslationY(saveDribbble.getHeight() * 0.4f); saveDribbble.animate().alpha(1f).translationY(0f).setDuration(200L).setInterpolator(AnimationUtils .loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); saveDesignerNews.setAlpha(0.6f); saveDesignerNews.setTranslationY(saveDesignerNews.getHeight() * 0.5f); saveDesignerNews.animate().alpha(1f).translationY(0f).setDuration(200L) .setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); return false; } }); }
From source file:com.spatialnetworks.fulcrum.widget.DynamicListView.java
/** * This method determines whether the hover cell has been shifted far enough * to invoke a cell swap. If so, then the respective cell swap candidate is * determined and the data set is changed. Upon posting a notification of the * data set change, a layout is invoked to place the cells in the right place. * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can * offset the cell being swapped to where it previously was and then animate it to * its new position.//www. j a va 2 s .c om */ private void handleCellSwitch() { final int deltaY = mLastEventY - mDownY; int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY; View belowView = getViewForID(mBelowItemId); View mobileView = getViewForID(mMobileItemId); View aboveView = getViewForID(mAboveItemId); boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop()); boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop()); if (isBelow || isAbove) { final long switchItemID = isBelow ? mBelowItemId : mAboveItemId; View switchView = isBelow ? belowView : aboveView; final int originalItem = getPositionForView(mobileView); swapElements(originalItem, getPositionForView(switchView)); // Josh mobileView.setVisibility(VISIBLE); ((BaseAdapter) getAdapter()).notifyDataSetChanged(); mDownY = mLastEventY; final int switchViewStartTop = switchView.getTop(); // Josh // mobileView.setVisibility(View.VISIBLE); // switchView.setVisibility(View.INVISIBLE); updateNeighborViewsForID(mMobileItemId); final ViewTreeObserver observer = getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer.removeOnPreDrawListener(this); // Josh View mobileView = getViewForID(mMobileItemId); if (mobileView != null) { mobileView.setVisibility(INVISIBLE); } View switchView = getViewForID(switchItemID); mTotalOffset += deltaY; int switchViewNewTop = switchView.getTop(); int delta = switchViewStartTop - switchViewNewTop; switchView.setTranslationY(delta); ObjectAnimator animator = ObjectAnimator.ofFloat(switchView, View.TRANSLATION_Y, 0); animator.setDuration(MOVE_DURATION); animator.start(); return true; } }); } }