Example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

Introduction

In this page you can find the example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter.

Prototype

AnimatorListenerAdapter

Source Link

Usage

From source file:com.simplecityapps.recyclerview_fastscroll.views.FastScroller.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void show_11() {
    if (mAutoHideAnimator != null) {
        mAutoHideAnimator.cancel();// w w w  . j  a  v a2 s .com
    }
    mAutoHideAnimator = mFastScrollerOffsetxObjectAnimator.getOffsetXAnimator(this, 0);
    mAutoHideAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    mAutoHideAnimator.setDuration(150);
    mAutoHideAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationCancel(Animator animation) {
            super.onAnimationCancel(animation);
            mAnimatingShow = false;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mAnimatingShow = false;
        }
    });
    mAnimatingShow = true;
    mAutoHideAnimator.start();
}

From source file:com.wart.magister.SelectSchoolActivity.java

/**
 * Shows the progress UI and hides the login form.
 *///from   w  w  w.j ava  2  s  . c  om
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) {
    // On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow
    // for very easy animations. If available, use these APIs to fade-in
    // the progress spinner.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);

        mSearchLayout.setVisibility(View.VISIBLE);
        mSearchLayout.animate().setDuration(shortAnimTime).alpha(show ? 1 : 0)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mSearchLayout.setVisibility(show ? View.VISIBLE : View.GONE);
                    }
                });

        mSchoolsList.setVisibility(View.VISIBLE);
        mSchoolsList.animate().setDuration(shortAnimTime).alpha(show ? 0 : 1)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        mSchoolsList.setVisibility(show ? View.GONE : View.VISIBLE);
                    }
                });
    } else {
        // The ViewPropertyAnimator APIs are not available, so simply show
        // and hide the relevant UI components.
        mSearchLayout.setVisibility(show ? View.VISIBLE : View.GONE);
        mSchoolsList.setVisibility(show ? View.GONE : View.VISIBLE);
    }
}

From source file:com.gitstudy.rili.liarbry.CalendarView.java

/**
 * /* ww w.j a v a 2 s .  co m*/
 *  showYearSelectLayout(final int year) ?
 *
 * @param year 
 */
private void showSelectLayout(final int year) {
    if (mParentLayout != null && mParentLayout.mContentView != null) {
        if (!mParentLayout.isExpand()) {
            mParentLayout.expand();
            return;
        }
    }
    mWeekPager.setVisibility(GONE);
    mDelegate.isShowYearSelectedLayout = true;
    if (mParentLayout != null) {
        mParentLayout.hideContentView();
    }
    mWeekBar.animate().translationY(-mWeekBar.getHeight()).setInterpolator(new LinearInterpolator())
            .setDuration(260).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mWeekBar.setVisibility(GONE);
                    mSelectLayout.setVisibility(VISIBLE);
                    mSelectLayout.scrollToYear(year, false);
                    if (mParentLayout != null && mParentLayout.mContentView != null) {
                        mParentLayout.expand();
                    }
                }
            });

    mMonthPager.animate().scaleX(0).scaleY(0).setDuration(260).setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                }
            });
}

From source file:com.smp.musicspeed.MainActivity.java

private void animateLinkOn() {

    TranslateAnimation anim = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f,
            Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF,
            -1.0f);/*from w  w  w. j  a v  a2 s .  co m*/
    anim.setDuration(TRANS_ANIMATION_TIME);
    anim.setInterpolator(new AnticipateOvershootInterpolator());
    anim.setAnimationListener(new AnimationListenerAdaptor() {
        @Override
        public void onAnimationEnd(Animation animation) {
            rateText.setAlpha(0f);
            linkOn();

            rateText.animate().alpha(1f).setDuration(TRANS_ANIMATION_TIME)
                    .setListener(new AnimatorListenerAdapter() {
                    });
        }
    });
    tempoCard.startAnimation(anim);
    tempoText.animate().alpha(0f).setDuration(TEXT_ANIMATION_TIME).setListener(new AnimatorListenerAdapter() {
    });
}

From source file:com.hybris.mobile.lib.ui.view.Alert.java

/**
 * Show the alert//ww  w .  j  a v a 2 s  .  com
 *
 * @param context                 application-specific resources
 * @param configuration           describes all device configuration information
 * @param text                    message to be displayed
 * @param forceClearPreviousAlert true will clear previous alert else keep it
 */
@SuppressLint("NewApi")
private static void showAlertOnScreen(final Activity context, final Configuration configuration,
        final String text, boolean forceClearPreviousAlert) {

    final ViewGroup mainView = ((ViewGroup) context.findViewById(android.R.id.content));
    boolean currentlyDisplayed = false;
    int viewId = R.id.alert_view_top;
    final TextView textView;
    boolean alertAlreadyExists = false;

    if (configuration.getOrientation().equals(Configuration.Orientation.BOTTOM)) {
        viewId = R.id.alert_view_bottom;
    }

    // Retrieving the view
    RelativeLayout relativeLayout = (RelativeLayout) mainView.findViewById(viewId);

    if (forceClearPreviousAlert) {
        mainView.removeView(relativeLayout);
        relativeLayout = null;
    }

    // Creating the view
    if (relativeLayout == null) {

        // Main layout
        relativeLayout = new RelativeLayout(context);
        relativeLayout.setId(viewId);
        relativeLayout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, configuration.getHeight()));
        relativeLayout.setGravity(Gravity.CENTER);

        // Textview
        textView = new TextView(context);
        textView.setId(R.id.alert_view_text);
        textView.setGravity(Gravity.CENTER);
        textView.setLayoutParams(
                new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        relativeLayout.addView(textView);

        setIcon(context, configuration, relativeLayout, textView);

        if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) {
            relativeLayout.setY(-configuration.getHeight());
        } else {
            relativeLayout.setY(mainView.getHeight());
        }

        // Adding the view to the global layout
        mainView.addView(relativeLayout, 0);
        relativeLayout.bringToFront();
        relativeLayout.requestLayout();
        relativeLayout.invalidate();
    }
    // View already exists
    else {
        alertAlreadyExists = true;
        textView = (TextView) relativeLayout.findViewById(R.id.alert_view_text);

        if (configuration.getOrientation().equals(Configuration.Orientation.TOP)) {
            if (relativeLayout.getY() == 0) {
                currentlyDisplayed = true;
            }
        } else {
            if (relativeLayout.getY() < mainView.getHeight()) {
                currentlyDisplayed = true;
            }
        }

        // The view is currently shown to the user
        if (currentlyDisplayed) {

            // If the message is not the same, we hide the current message and display the new one
            if (!StringUtils.equals(text, textView.getText())) {
                // Anim out the current message
                ViewPropertyAnimator viewPropertyAnimator = animOut(configuration, mainView, relativeLayout);

                final RelativeLayout relativeLayoutFinal = relativeLayout;

                if (viewPropertyAnimator != null) {
                    // Anim in the new message after the animation out has finished
                    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                        viewPropertyAnimator.setListener(new AnimatorListenerAdapter() {
                            @Override
                            public void onAnimationEnd(Animator animation) {
                                setIcon(context, configuration, relativeLayoutFinal, textView);
                                animIn(configuration, relativeLayoutFinal, textView, mainView, text);
                            }
                        });
                    } else {
                        viewPropertyAnimator.withEndAction(new Runnable() {
                            @Override
                            public void run() {
                                setIcon(context, configuration, relativeLayoutFinal, textView);
                                animIn(configuration, relativeLayoutFinal, textView, mainView, text);
                            }
                        });
                    }
                } else {
                    setIcon(context, configuration, relativeLayoutFinal, textView);
                    animIn(configuration, relativeLayoutFinal, textView, mainView, text);
                }
            }
        }
    }

    final RelativeLayout relativeLayoutFinal = relativeLayout;

    // Close the alert by clicking the layout
    if (configuration.isCloseable()) {
        relativeLayout.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                animOut(configuration, mainView, relativeLayoutFinal);
                v.performClick();
                return true;
            }
        });
    }

    if (!currentlyDisplayed) {
        // Set the icon in case the alert already exists but it's not currently displayed
        if (alertAlreadyExists) {
            setIcon(context, configuration, relativeLayoutFinal, textView);
        }

        // We anim in the alert
        animIn(configuration, relativeLayoutFinal, textView, mainView, text);
    }
}

From source file:com.me.harris.androidanimations._06_touch.swipelistview.SwipeListViewTouchListener.java

/**
 * Create reveal animation//from   w  w w.  j  av a  2 s . c o  m
 * @param view affected view
 * @param swap If will change state. If "false" returns to the original position
 * @param swapRight If swap is true, this parameter tells if movement is toward right or left
 * @param position list position
 */
private void generateRevealAnimate(final View view, final boolean swap, final boolean swapRight,
        final int position) {
    int moveTo = 0;
    if (opened.get(position)) {
        if (!swap) {
            moveTo = openedRight.get(position) ? (int) (viewWidth - rightOffset)
                    : (int) (-viewWidth + leftOffset);
        }
    } else {
        if (swap) {
            moveTo = swapRight ? (int) (viewWidth - rightOffset) : (int) (-viewWidth + leftOffset);
        }
    }

    view.animate().translationX(moveTo).setDuration(animationTime).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            swipeListView.resetScrolling();
            if (swap) {
                boolean aux = !opened.get(position);
                opened.set(position, aux);
                if (aux) {
                    swipeListView.onOpened(position, swapRight);
                    openedRight.set(position, swapRight);
                } else {
                    swipeListView.onClosed(position, openedRight.get(position));
                }
            }
        }
    });
}

From source file:com.igniva.filemanager.utils.Futils.java

public void crossfade(View buttons, final View pathbar) {

    // Set the content view to 0% opacity but visible, so that it is visible
    // (but fully transparent) during the animation.
    buttons.setAlpha(0f);/*from   w  ww  .  ja  v  a  2 s. co  m*/
    buttons.setVisibility(View.VISIBLE);

    // Animate the content view to 100% opacity, and clear any animation
    // listener set on the view.
    buttons.animate().alpha(1f).setDuration(100).setListener(null);
    pathbar.animate().alpha(0f).setDuration(100).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            pathbar.setVisibility(View.GONE);
        }
    });
    // Animate the loading view to 0% opacity. After the animation ends,
    // set its visibility to GONE as an optimization step (it won't
    // participate in layout passes, etc.)

}

From source file:com.example.fansonlib.widget.calendar.CalendarView.java

/**
 * ??/*from  w w w  .  j  av a  2s .  com*/
 *
 * @param position ?
 */
public void closeSelectLayout(final int position) {
    mSelectLayout.setVisibility(GONE);
    mLinearWeek.setVisibility(VISIBLE);
    mViewPager.setVisibility(VISIBLE);
    if (position == mViewPager.getCurrentItem()) {
        if (mListener != null) {
            Calendar calendar = new Calendar();
            calendar.setYear(position / 12 + mMinYear);
            calendar.setMonth(position % 12 + 1);
            calendar.setDay(1);
            calendar.setLunar(LunarCalendar.numToChineseDay(
                    LunarCalendar.solarToLunar(calendar.getYear(), calendar.getMonth(), 1)[2]));
            mListener.onDateChange(calendar);
        }
    } else {
        mViewPager.setCurrentItem(position, true);
    }
    mLinearWeek.animate().translationY(0).setInterpolator(new LinearInterpolator()).setDuration(180)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mLinearWeek.setVisibility(VISIBLE);
                    if (mParentLayout != null && mParentLayout.mContentView != null) {
                        mParentLayout.mContentView.setVisibility(VISIBLE);
                    }
                }
            });
    mViewPager.animate().scaleX(1).scaleY(1).setDuration(180).setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mViewPager.setVisibility(VISIBLE);

                }
            });
}

From source file:com.google.samples.apps.topeka.view.quiz.QuizActivity.java

@Override
public void displayDoneFab() {
    /* We're re-using the already existing fab and give it some
     * new values. This has to run delayed due to the queued animation
     * to hide the fab initially./* w w  w  .  j  a  v a 2  s  .com*/
     */
    if (null != mCircularReveal && mCircularReveal.isRunning()) {
        mCircularReveal.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                showQuizFabWithDoneIcon();
                mCircularReveal.removeListener(this);
            }
        });
    } else {
        showQuizFabWithDoneIcon();
    }
}

From source file:com.androidinspain.deskclock.alarms.dataadapter.ExpandedAlarmViewHolder.java

@Override
public Animator onAnimateChange(List<Object> payloads, int fromLeft, int fromTop, int fromRight, int fromBottom,
        long duration) {
    if (payloads == null || payloads.isEmpty() || !payloads.contains(ANIMATE_REPEAT_DAYS)) {
        return null;
    }//  www.  java2  s .c o m

    final boolean isExpansion = repeatDays.getVisibility() == View.VISIBLE;
    final int height = repeatDays.getHeight();
    setTranslationY(isExpansion ? -height : 0f, isExpansion ? -height : height);
    repeatDays.setVisibility(View.VISIBLE);
    repeatDays.setAlpha(isExpansion ? 0f : 1f);

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            AnimatorUtils.getBoundsAnimator(itemView, fromLeft, fromTop, fromRight, fromBottom,
                    itemView.getLeft(), itemView.getTop(), itemView.getRight(), itemView.getBottom()),
            ObjectAnimator.ofFloat(repeatDays, View.ALPHA, isExpansion ? 1f : 0f),
            ObjectAnimator.ofFloat(repeatDays, TRANSLATION_Y, isExpansion ? 0f : -height),
            ObjectAnimator.ofFloat(ringtone, TRANSLATION_Y, 0f),
            ObjectAnimator.ofFloat(vibrate, TRANSLATION_Y, 0f),
            ObjectAnimator.ofFloat(editLabel, TRANSLATION_Y, 0f),
            ObjectAnimator.ofFloat(preemptiveDismissButton, TRANSLATION_Y, 0f),
            ObjectAnimator.ofFloat(hairLine, TRANSLATION_Y, 0f),
            ObjectAnimator.ofFloat(delete, TRANSLATION_Y, 0f),
            ObjectAnimator.ofFloat(arrow, TRANSLATION_Y, 0f));
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            setTranslationY(0f, 0f);
            repeatDays.setAlpha(1f);
            repeatDays.setVisibility(isExpansion ? View.VISIBLE : View.GONE);
            itemView.requestLayout();
        }
    });
    animatorSet.setDuration(duration);
    animatorSet.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);

    return animatorSet;
}