Example usage for android.animation Animator setInterpolator

List of usage examples for android.animation Animator setInterpolator

Introduction

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

Prototype

public abstract void setInterpolator(TimeInterpolator value);

Source Link

Document

The time interpolator used in calculating the elapsed fraction of the animation.

Usage

From source file:com.truizlop.fabreveallayout.FABRevealLayout.java

private void setupAnimationParams(Animator animator) {
    animator.setInterpolator(INTERPOLATOR);
    animator.setDuration(ANIMATION_DURATION);
}

From source file:com.rks.musicx.ui.adapters.AlbumListAdapter.java

@Override
public void onBindViewHolder(AlbumListAdapter.AlbumViewHolder holder, int position) {
    Album albums = getItem(position);/*w w  w .j  a  va2  s  .  c  o  m*/
    if (layoutID == R.layout.item_grid_view || layoutID == R.layout.recent_list) {
        int pos = holder.getAdapterPosition();
        if (lastpos < pos) {
            for (Animator animator : Helper.getAnimator(holder.backgroundColor)) {
                animator.setDuration(duration);
                animator.setInterpolator(interpolator);
                animator.start();
            }
        }
        holder.AlbumArtwork.setTransitionName("TransitionArtwork" + position);
        holder.AlbumName.setText(albums.getAlbumName());
        holder.ArtistName.setText(albums.getArtistName());
        ArtworkUtils.ArtworkLoader(getContext(), 300, 600, albums.getAlbumName(), albums.getId(),
                new palette() {
                    @Override
                    public void palettework(Palette palette) {
                        final int[] colors = Helper.getAvailableColor(getContext(), palette);
                        holder.backgroundColor.setBackgroundColor(colors[0]);
                        holder.AlbumName.setTextColor(Helper.getTitleTextColor(colors[0]));
                        holder.ArtistName.setTextColor(Helper.getTitleTextColor(colors[0]));
                        Helper.animateViews(getContext(), holder.backgroundColor, colors[0]);
                    }
                }, holder.AlbumArtwork);
        holder.menu.setVisibility(View.GONE);
    }
    if (layoutID == R.layout.item_list_view) {
        holder.AlbumListName.setText(albums.getAlbumName());
        holder.ArtistListName.setText(albums.getArtistName());
        ArtworkUtils.ArtworkLoader(getContext(), 300, 600, albums.getAlbumName(), albums.getId(),
                new palette() {
                    @Override
                    public void palettework(Palette palette) {
                    }
                }, holder.AlbumListArtwork);
        if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
            holder.AlbumListName.setTextColor(Color.WHITE);
            holder.ArtistListName
                    .setTextColor(ContextCompat.getColor(getContext(), R.color.darkthemeTextColor));
        }
    }
}

From source file:tech.salroid.filmy.fragment.FullReadFragment.java

@Nullable
@Override// w  ww.  ja va 2s.  c  o  m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.read_full_layout, container, false);
    ButterKnife.bind(this, view);

    crossButton.setOnClickListener(this);

    // To run the animation as soon as the view is layout in the view hierarchy we add this
    // listener and remove it
    // as soon as it runs to prevent multiple animations if the view changes bounds
    view.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) {
            v.removeOnLayoutChangeListener(this);

            int cx = getArguments().getInt("cx");
            int cy = getArguments().getInt("cy");

            // get the hypothenuse so the radius is from one corner to the other
            int radius = (int) Math.hypot(right, bottom);

            Animator reveal;

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);
                reveal.setInterpolator(new DecelerateInterpolator(2f));
                reveal.setDuration(1000);
                reveal.start();
            }

        }
    });

    return view;
}

From source file:com.rks.musicx.ui.adapters.ArtistListAdapter.java

@Override
public void onBindViewHolder(ArtistViewHolder holder, int position) {
    Artist artists = getItem(position);/*from   www.j av a2s.c  o m*/
    Helper helper = new Helper(getContext());
    if (layoutID == R.layout.item_grid_view) {
        int pos = holder.getAdapterPosition();
        if (lastpos < pos) {
            for (Animator animator : Helper.getAnimator(holder.backgroundColor)) {
                animator.setDuration(duration);
                animator.setInterpolator(interpolator);
                animator.start();
            }
        }
        holder.ArtistsArtwork.setTransitionName("TransitionArtworks" + position);
        holder.ArtistName.setText(getContext().getResources().getQuantityString(R.plurals.albums_count,
                artists.getAlbumCount(), artists.getAlbumCount()));
        holder.AlbumCount.setText(artists.getName());
        ArtworkUtils.ArtworkLoader(getContext(), 300, 600, helper.loadArtistImage(artists.getName()),
                new palette() {
                    @Override
                    public void palettework(Palette palette) {
                        final int[] colors = Helper.getAvailableColor(getContext(), palette);
                        holder.backgroundColor.setBackgroundColor(colors[0]);
                        holder.ArtistName.setTextColor(Helper.getTitleTextColor(colors[0]));
                        holder.AlbumCount.setTextColor(Helper.getTitleTextColor(colors[0]));
                        Helper.animateViews(getContext(), holder.backgroundColor, colors[0]);
                    }
                }, holder.ArtistsArtwork);
        holder.menu.setVisibility(View.GONE);
    }
    if (layoutID == R.layout.item_list_view) {
        holder.ArtistListName.setText(artists.getName());
        holder.ArtistListAlbumCount.setText(getContext().getResources()
                .getQuantityString(R.plurals.albums_count, artists.getAlbumCount(), artists.getAlbumCount()));
        ArtworkUtils.ArtworkLoader(getContext(), 300, 600, helper.loadArtistImage(artists.getName()),
                new palette() {
                    @Override
                    public void palettework(Palette palette) {

                    }
                }, holder.ArtistListArtwork);
        if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
            holder.ArtistListName.setTextColor(Color.WHITE);
            holder.ArtistListAlbumCount
                    .setTextColor(ContextCompat.getColor(getContext(), R.color.darkthemeTextColor));
        }
    }

}

From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java

private Animator createCollapsingAnimator(ArrowItemViewHolder newHolder, long duration) {
    if (arrow != null) {
        arrow.setVisibility(View.INVISIBLE);
    }/*from ww  w  .  ja va  2  s . co  m*/

    final View oldView = itemView;
    final View newView = newHolder.itemView;

    final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(oldView,
            PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 255, 0));
    backgroundAnimator.setDuration(duration);

    final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(oldView, oldView, newView);
    boundsAnimator.setDuration(duration);
    boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);

    final AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(backgroundAnimator, boundsAnimator);
    return animatorSet;
}

From source file:com.chrynan.guitartuner.PitchFragment.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void circularReveal(final float x, final float y) {
    if (x != -1 && y != -1) {
        float finalRadius = (float) Math.hypot(viewRoot.getWidth(), viewRoot.getHeight());
        Animator anim = ViewAnimationUtils.createCircularReveal(viewRoot, (int) x, (int) y, 0, finalRadius);
        //viewRoot.setBackgroundColor(getActivity().getResources().getColor(R.color.white));
        anim.setInterpolator(new DecelerateInterpolator(2f));
        anim.setDuration(1000);/*  ww w  .  ja v  a2s. c o m*/
        anim.start();
    }
}

From source file:com.sysdata.widget.accordion.ExpandedViewHolder.java

private Animator createExpandingAnimator(ArrowItemViewHolder oldHolder, long duration) {
    final View oldView = oldHolder.itemView;
    final View newView = itemView;
    final Animator boundsAnimator = AnimatorUtils.getBoundsAnimator(newView, oldView, newView);
    boundsAnimator.setDuration(duration);
    boundsAnimator.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);

    final Animator backgroundAnimator = ObjectAnimator.ofPropertyValuesHolder(newView,
            PropertyValuesHolder.ofInt(AnimatorUtils.BACKGROUND_ALPHA, 0, 255));
    backgroundAnimator.setDuration(duration);

    final AnimatorSet animatorSet;
    if (arrow != null) {
        final View oldArrow = oldHolder.arrow;
        final Rect oldArrowRect = new Rect(0, 0, oldArrow.getWidth(), oldArrow.getHeight());
        final Rect newArrowRect = new Rect(0, 0, arrow.getWidth(), arrow.getHeight());
        ((ViewGroup) newView).offsetDescendantRectToMyCoords(arrow, newArrowRect);
        ((ViewGroup) oldView).offsetDescendantRectToMyCoords(oldArrow, oldArrowRect);
        final float arrowTranslationY = oldArrowRect.bottom - newArrowRect.bottom;

        arrow.setTranslationY(arrowTranslationY);
        arrow.setVisibility(View.VISIBLE);

        final Animator arrowAnimation = ObjectAnimator.ofFloat(arrow, View.TRANSLATION_Y, 0f)
                .setDuration(duration);/*from  w w w  .ja  v  a 2s .  c  o m*/
        arrowAnimation.setInterpolator(AnimatorUtils.INTERPOLATOR_FAST_OUT_SLOW_IN);

        animatorSet = new AnimatorSet();
        animatorSet.playTogether(backgroundAnimator, boundsAnimator, arrowAnimation);
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationStart(Animator animator) {
                AnimatorUtils.startDrawableAnimation(arrow);
            }
        });
    } else {
        animatorSet = new AnimatorSet();
        animatorSet.playTogether(backgroundAnimator, boundsAnimator);
    }

    return animatorSet;
}

From source file:tech.salroid.filmy.fragment.AllTrailerFragment.java

@Nullable
@Override/*from  w w w  .ja va2  s  . c om*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
    nightMode = sp.getBoolean("dark", false);

    View view = inflater.inflate(R.layout.all_trailer_layout, container, false);
    ButterKnife.bind(this, view);

    if (!nightMode)
        allThemeLogic();
    else {
        nightModeLogic();
    }

    crossButton.setOnClickListener(this);

    // To run the animation as soon as the view is layout in the view hierarchy we add this
    // listener and remove it
    // as soon as it runs to prevent multiple animations if the view changes bounds
    view.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) {
            v.removeOnLayoutChangeListener(this);

            int cx = getArguments().getInt("cx");
            int cy = getArguments().getInt("cy");

            // get the hypothenuse so the radius is from one corner to the other
            int radius = (int) Math.hypot(right, bottom);

            Animator reveal;

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
                reveal = ViewAnimationUtils.createCircularReveal(v, cx, cy, 0, radius);
                reveal.setInterpolator(new DecelerateInterpolator(2f));
                reveal.setDuration(1000);
                reveal.start();
            }

        }
    });

    init(view);

    return view;
}

From source file:com.hadis.mylunbo.carrousel.CircleIndicator.java

private Animator createAnimatorIn(Context context) {
    Animator animatorIn;
    if (mAnimatorReverseResId == 0) {
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorResId);
        animatorIn.setInterpolator(new ReverseInterpolator());
    } else {/* ww w  .  java2 s.  com*/
        animatorIn = AnimatorInflater.loadAnimator(context, mAnimatorReverseResId);
    }
    return animatorIn;
}

From source file:com.rks.musicx.ui.adapters.SongListAdapter.java

@Override
public void onBindViewHolder(SongListAdapter.SongViewHolder holder, int position) {
    Song song = getItem(position);//from  w w  w.  jav a 2  s  .c o  m
    if (layout == R.layout.song_list) {
        holder.SongTitle.setText(song.getTitle());
        holder.SongArtist.setText(song.getArtist());
        ArtworkUtils.ArtworkLoader(getContext(), 300, 600, song.getAlbum(), song.getAlbumId(), new palette() {
            @Override
            public void palettework(Palette palette) {

            }
        }, holder.SongArtwork);
        holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu));
        Drawable drawable = holder.menu.getDrawable();
        int accentColor = Config.accentColor(getContext(), Helper.getATEKey(getContext()));
        if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
            drawable.setTint(Color.WHITE);
            holder.SongTitle.setTextColor(Color.WHITE);
            holder.SongArtist.setTextColor(ContextCompat.getColor(getContext(), R.color.darkthemeTextColor));
            holder.itemView.setBackgroundColor(storeChecked.get(position)
                    ? ContextCompat.getColor(getContext(), R.color.translucent_white_8p)
                    : Color.TRANSPARENT);
        } else {
            drawable.setTint(ContextCompat.getColor(getContext(), R.color.MaterialGrey));
            holder.SongTitle.setTextColor(Color.BLACK);
            holder.SongArtist.setTextColor(Color.DKGRAY);
            holder.itemView
                    .setBackgroundColor(storeChecked.get(position) ? Helper.getColorWithAplha(accentColor, 0.7f)
                            : Color.TRANSPARENT);
        }
    }
    if (layout == R.layout.detail_list) {
        holder.SongTitle.setText(song.getTitle());
        holder.SongArtist.setText(song.getArtist());
        holder.number.setText(position + 1 + ".");
        holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu));
        Drawable drawable = holder.menu.getDrawable();
        if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
            drawable.setTint(Color.WHITE);
            holder.SongTitle.setTextColor(Color.WHITE);
            holder.number.setTextColor(Color.WHITE);
            holder.SongArtist.setTextColor(ContextCompat.getColor(getContext(), R.color.darkthemeTextColor));
        } else {
            drawable.setTint(ContextCompat.getColor(getContext(), R.color.MaterialGrey));
            holder.SongTitle.setTextColor(Color.BLACK);
            holder.number.setTextColor(Color.BLACK);
            holder.SongArtist.setTextColor(Color.DKGRAY);
        }
    }
    if (layout == R.layout.item_grid_view || layout == R.layout.recent_list) {
        int pos = holder.getAdapterPosition();
        if (lastpos < pos) {
            for (Animator animator : getAnimator(holder.songView)) {
                animator.setDuration(duration);
                animator.setInterpolator(interpolator);
                animator.start();
            }
        }
        holder.SongTitle.setText(song.getTitle());
        holder.SongArtist.setText(song.getArtist());
        ArtworkUtils.ArtworkLoader(getContext(), 300, 600, song.getAlbum(), song.getAlbumId(), new palette() {
            @Override
            public void palettework(Palette palette) {
                final int[] colors = Helper.getAvailableColor(getContext(), palette);
                holder.songView.setBackgroundColor(colors[0]);
                holder.SongTitle.setTextColor(Helper.getTitleTextColor(colors[0]));
                holder.SongArtist.setTextColor(Helper.getTitleTextColor(colors[0]));
                Helper.animateViews(getContext(), holder.itemView, colors[0]);
            }
        }, holder.songGridArtwork);
        holder.menu.setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.ic_menu));
        holder.menu.setVisibility(View.VISIBLE);
        Drawable drawable = holder.menu.getDrawable();
        if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
            drawable.setTint(Color.WHITE);
        }
    }
}