List of usage examples for android.animation ObjectAnimator start
@Override public void start()
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
@TargetApi(21) private void hideLollipopImpl() { int rootWidth = mRoot.getWidth(); float controlX; if (mFabOriginalX > rootWidth / 2f) { controlX = mFabOriginalX * 0.98f; } else {/* w w w.j ava 2 s. com*/ controlX = mFabOriginalX * 1.02f; } final Path path = new Path(); path.moveTo(mFab.getX(), mFab.getY()); final float x2 = controlX; final float y2 = getY(); path.quadTo(x2, y2, mFabOriginalX, mFabOriginalY + getTranslationY()); ObjectAnimator anim = ObjectAnimator.ofFloat(mFab, View.X, View.Y, path); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_UNMORPH_DURATION); anim.setStartDelay(FAB_UNMORPH_DELAY); anim.start(); /** * Animate FAB elevation back to 6dp */ anim = ObjectAnimator.ofFloat(mFab, View.TRANSLATION_Z, 0); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_UNMORPH_DURATION); anim.setStartDelay(FAB_UNMORPH_DELAY); anim.start(); /** * Restore alpha of FAB drawable */ Drawable drawable = mFab.getDrawable(); if (drawable != null) { anim = ObjectAnimator.ofPropertyValuesHolder(drawable, PropertyValuesHolder.ofInt("alpha", 255)); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setDuration(FAB_UNMORPH_DURATION); anim.setStartDelay(FAB_UNMORPH_DELAY); anim.start(); } Animator toolbarReveal = ViewAnimationUtils.createCircularReveal(this, getWidth() / 2, getHeight() / 2, (float) (Math.hypot(getWidth() / 2, getHeight() / 2)), (float) mFab.getWidth() / 2f); toolbarReveal.setTarget(this); toolbarReveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); setVisibility(View.INVISIBLE); mFab.setVisibility(View.VISIBLE); mMorphing = false; } }); toolbarReveal.setDuration(CIRCULAR_UNREVEAL_DURATION); toolbarReveal.setInterpolator(new AccelerateInterpolator()); toolbarReveal.setStartDelay(CIRCULAR_UNREVEAL_DELAY); toolbarReveal.start(); /** * Animate FloatingToolbar animation back to 6dp */ anim = ObjectAnimator.ofFloat(this, View.TRANSLATION_Z, 0); anim.setDuration(CIRCULAR_UNREVEAL_DURATION); anim.setStartDelay(CIRCULAR_UNREVEAL_DELAY); anim.start(); }
From source file:com.sinyuk.jianyimaterial.widgets.FloatingToolbar.java
private void showDefaultImpl() { int rootWidth = mRoot.getWidth(); setScaleX(0f);// ww w. j av a 2 s .co m float endFabX; if (mFabOriginalX > rootWidth / 2f) { endFabX = rootWidth / 2f + (mFabOriginalX - rootWidth / 2f) / 4f; } else { endFabX = rootWidth / 2f - (mFabOriginalX - rootWidth / 2f) / 4f; } if (mFab != null) { PropertyValuesHolder xProperty = PropertyValuesHolder.ofFloat(X, endFabX); PropertyValuesHolder yProperty = PropertyValuesHolder.ofFloat(Y, mFabOriginalY * 1.05f); PropertyValuesHolder scaleXProperty = PropertyValuesHolder.ofFloat(SCALE_X, 0); PropertyValuesHolder scaleYProperty = PropertyValuesHolder.ofFloat(SCALE_Y, 0); ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(mFab, xProperty, yProperty, scaleXProperty, scaleYProperty); animator.setDuration(FAB_MORPH_DURATION); animator.setInterpolator(new AccelerateInterpolator()); animator.start(); } ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(this, "scaleX", 1f); objectAnimator.setDuration(CIRCULAR_REVEAL_DURATION); objectAnimator.setStartDelay(CIRCULAR_REVEAL_DELAY); objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); setVisibility(View.VISIBLE); mFab.setVisibility(View.INVISIBLE); } @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); mMorphing = false; } }); objectAnimator.start(); }
From source file:com.hannesdorfmann.search.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//from w w w .j a va 2s .co m 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:de.baumann.thema.RequestActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.request_grid); switcherLoad = (ViewSwitcher) findViewById(R.id.viewSwitcherLoadingMain); context = this; android.support.v7.app.ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); }//w w w .j av a 2s . co m if (savedInstanceState == null) { //Loading Logo Animation ImageView logo = (ImageView) findViewById(R.id.imageViewLogo); ObjectAnimator logoAni = (ObjectAnimator) AnimatorInflater.loadAnimator(context, R.animator.request_flip); logoAni.setRepeatCount(Animation.INFINITE); logoAni.setRepeatMode(Animation.RESTART); logoAni.setTarget(logo); logoAni.setDuration(2000); logoAni.start(); taskList.execute(); } else { populateView(list_activities_final); switcherLoad.showNext(); } }
From source file:com.waz.zclient.pages.main.participants.ParticipantHeaderFragment.java
public void showCancelButton(boolean show, boolean animate) { if (closeButton == null || headerTopBorder == null) { return;//from ww w .j ava 2 s.co m } if (show) { if (!animate) { closeButton.setAlpha(1); } else { headerTopBorder.animate().alpha(0) .setDuration( getResources().getInteger(R.integer.open_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.open_close_button__alpha__delay)) .start(); ObjectAnimator animator = ObjectAnimator.ofFloat(closeButton, View.ALPHA, 1); animator.setDuration( getResources().getInteger(R.integer.open_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.open_close_button__alpha__delay)); animator.start(); } } else { if (!animate) { closeButton.setAlpha(0); } else { ObjectAnimator animator = ObjectAnimator.ofFloat(closeButton, View.ALPHA, 0); animator.setDuration( getResources().getInteger(R.integer.close_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.close_close_button__alpha__delay)); animator.start(); headerTopBorder.animate().alpha(1) .setDuration( getResources().getInteger(R.integer.close_close_button__alpha__animation_duration)) .setStartDelay(getResources().getInteger(R.integer.close_close_button__alpha__delay)) .start(); } } }
From source file:babbq.com.searchplace.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 v a 2 s. c o m*/ 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.android.deskclock.timer.TimerFullScreenFragment.java
private void gotoSetupView() { if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timer_setup) { mTimerSetup.setVisibility(View.VISIBLE); mTimerSetup.setScaleX(1f);/*from w w w.j a va 2 s .c o m*/ mTimersListPage.setVisibility(View.GONE); } else { // Animate ObjectAnimator a = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 1f, 0f); a.setInterpolator(new AccelerateInterpolator()); a.setDuration(125); a.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTimersListPage.setVisibility(View.GONE); mTimerSetup.setScaleX(0); mTimerSetup.setVisibility(View.VISIBLE); ObjectAnimator b = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 0f, 1f); b.setInterpolator(new DecelerateInterpolator()); b.setDuration(225); b.start(); } }); a.start(); } stopClockTicks(); mTimerSetup.updateDeleteButtonAndDivider(); mLastVisibleView = mTimerSetup; }
From source file:com.android.deskclock.timer.TimerFullScreenFragment.java
private void gotoTimersView() { if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timers_list_page) { mTimerSetup.setVisibility(View.GONE); mTimersListPage.setVisibility(View.VISIBLE); mTimersListPage.setScaleX(1f);//w ww.j a va2 s . c o m } else { // Animate ObjectAnimator a = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 1f, 0f); a.setInterpolator(new AccelerateInterpolator()); a.setDuration(125); a.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mTimerSetup.setVisibility(View.GONE); mTimersListPage.setScaleX(0); mTimersListPage.setVisibility(View.VISIBLE); ObjectAnimator b = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 0f, 1f); b.setInterpolator(new DecelerateInterpolator()); b.setDuration(225); b.start(); } }); a.start(); } startClockTicks(); mLastVisibleView = mTimersListPage; }
From source file:com.android.tv.settings.dialog.SettingsLayoutFragment.java
private void fadeIn(View v) { ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(v, "alpha", FADE_IN_ALPHA_START, FADE_IN_ALPHA_FINISH);/*from www . j av a2s .c om*/ alphaAnimator .setDuration(v.getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); alphaAnimator.start(); }
From source file:uk.org.crimetalk.fragments.ArticleContentFragment.java
/** * Setup the function that will show and hide the Toolbar when the ListView is scrolled. * * @param view The Toolbar View// w ww. j ava 2 s.c om */ private void setupScrollHide(final View view) { final ObjectAnimator hideObjectAnimator = getHideAnimator(view); final ObjectAnimator showObjectAnimator = getShowAnimator(view); getListView().setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView absListView, int i) { final int currentFirstVisibleItem = absListView.getFirstVisiblePosition(); // User is scrolling down so hide the Toolbar if (mLastFirstVisibleItem < currentFirstVisibleItem) { if (view.getVisibility() == View.VISIBLE) { hideObjectAnimator.start(); } // User is scrolling up so show the Toolbar } else if (mLastFirstVisibleItem > currentFirstVisibleItem) { if (view.getVisibility() == View.GONE) { showObjectAnimator.start(); } } mLastFirstVisibleItem = currentFirstVisibleItem; } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { // Do nothing } }); }