Example usage for android.view.animation AnimationUtils loadAnimation

List of usage examples for android.view.animation AnimationUtils loadAnimation

Introduction

In this page you can find the example usage for android.view.animation AnimationUtils loadAnimation.

Prototype

public static Animation loadAnimation(Context context, @AnimRes int id) throws NotFoundException 

Source Link

Document

Loads an Animation object from a resource

Usage

From source file:com.architjn.acjmusicplayer.elements.ScrollAwareFABBehavior.java

private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.abc_slide_in_bottom);
    anim.setDuration(600L);//from  ww  w .  ja va  2 s . c om
    anim.setInterpolator(INTERPOLATOR);
    button.startAnimation(anim);
}

From source file:com.android.projectz.teamrocket.thebusapp.adapters.MainRecyclerAdapter.java

@Override
public void onBindViewHolder(final MainRecyclerAdapter.ViewHolder holder, final int position) {
    int lastPosition = -1;
    if (position > lastPosition) {
        Animation animation = AnimationUtils.loadAnimation(context,
                (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
        holder.itemView.startAnimation(animation);
        lastPosition = position;//from ww  w  . jav  a  2  s  . c  om
    }

    if (SharedPreferencesUtils.getSelectedTheme(context).equals("ThemeDark")) {
        holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.cardview_dark_background));
        holder.txtTitle.setTextColor(ContextCompat.getColor(context, android.R.color.primary_text_dark));
        holder.txtSubtitle.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_dark));
        holder.txtOther.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_dark));
        image = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_arrow_row));
        DrawableCompat.setTint(image, context.getResources().getColor(R.color.iconDark));
    } else {
        holder.cardView.setBackgroundColor(ContextCompat.getColor(context, R.color.cardview_light_background));
        holder.txtTitle.setTextColor(ContextCompat.getColor(context, android.R.color.primary_text_light));
        holder.txtSubtitle.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_light));
        holder.txtOther.setTextColor(ContextCompat.getColor(context, android.R.color.secondary_text_light));
        image = DrawableCompat.wrap(ContextCompat.getDrawable(context, R.drawable.ic_arrow_row));
        DrawableCompat.setTint(image, context.getResources().getColor(R.color.iconLight));
    }

    holder.txtTitle.setText(myObjects.get(position).getTextTitle());
    holder.txtSubtitle.setText(myObjects.get(position).getTextSubtitle());
    holder.txtOther.setText(myObjects.get(position).getTextOther());
    holder.imageView.setImageResource(myObjects.get(position).getImageId());
    holder.arrowRow.setImageDrawable(image);

    //ascoltatore del *tap* sulla card
    holder.relativeLayout.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Toast.makeText(context, "Loading...", Toast.LENGTH_SHORT).show();
            Intent intent = new Intent(context, DetailViewerActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); //senza di esso va in crash, perch bisogna creare l'intent come se fosse una nuova activity
            intent.putExtra("title", myObjects.get(position).getTextTitle());
            intent.putExtra("subtitle", myObjects.get(position).getTextSubtitle());
            intent.putExtra("other", myObjects.get(position).getTextOther());
            intent.putExtra("fermataId", myObjects.get(position).getFermataId());
            ArrayList<String> holderData = new ArrayList<String>();
            holderData.add(myObjects.get(position).getTextTitle());
            holderData.add(myObjects.get(position).getTextSubtitle());
            holderData.add(myObjects.get(position).getTextOther());
            intent.putStringArrayListExtra("holderData", holderData);
            context.startActivity(intent);
        }
    });

    //MainActivity.recyclerView.scrollToPosition(myObjects.get(position).isNear != -1 ? position : null);
}

From source file:br.com.devfestsul.planetas.utils.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }/* www.  ja  v  a 2s . c o m*/

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.orangemoo.com.beta.widget.ScrollFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollFABBehavior.this.mIsAnimatingOut = true;
                    }//from  ww  w  . j a  va2s.  co  m

                    public void onAnimationCancel(View view) {
                        ScrollFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).setDuration(Utils.SWIPE_BEHAVIOR_ANIMATION_TIME).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.abc_fade_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(Utils.SWIPE_BEHAVIOR_ANIMATION_TIME);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.example.xyzreader.util.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {

        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }//from   www.  j a  v a  2 s  .c  o m

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.battlelancer.seriesguide.ui.AddFragment.java

/**
 * Hides the content container and shows a progress bar.
 */// w w w .j av a2s .c  om
public void setProgressVisible(boolean visible, boolean animate) {
    if (animate) {
        Animation out = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out);
        Animation in = AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in);
        contentContainer.startAnimation(visible ? out : in);
        progressBar.startAnimation(visible ? in : out);
    }
    contentContainer.setVisibility(visible ? View.GONE : View.VISIBLE);
    progressBar.setVisibility(visible ? View.VISIBLE : View.GONE);
}

From source file:cn.lingox.android.share.view.ScrollAwareFABBehavior.java

private void animateOut(final FloatingActionButton button) {
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(0.0F).scaleY(0.0F).alpha(0.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(new ViewPropertyAnimatorListener() {
                    public void onAnimationStart(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
                    }/*  w ww.j av a 2s  . co  m*/

                    public void onAnimationCancel(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                    }

                    public void onAnimationEnd(View view) {
                        ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                        view.setVisibility(View.GONE);
                    }
                }).start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_out);
        anim.setInterpolator(INTERPOLATOR);
        anim.setDuration(200L);
        anim.setAnimationListener(new Animation.AnimationListener() {
            public void onAnimationStart(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = true;
            }

            public void onAnimationEnd(Animation animation) {
                ScrollAwareFABBehavior.this.mIsAnimatingOut = false;
                button.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationRepeat(final Animation animation) {
            }
        });
        button.startAnimation(anim);
    }
}

From source file:com.commov.app.dv.PhotoViewActivity.java

private Animation getImgIndexInfoShowAnim() {
    if (imgIndexShowAnim == null) {
        imgIndexShowAnim = AnimationUtils.loadAnimation(this, R.anim.img_index_show);
    }//w  w  w .  jav  a2s .  c  o  m
    return imgIndexShowAnim;
}

From source file:com.userhook.view.UHMessageView.java

public void showDialog() {

    if (contentLoaded) {

        int overlayInId = UserHook.getResourceId("uh_overlay_in", "anim");
        int dialogInId = UserHook.getResourceId("uh_dialog_in", "anim");

        overlay.setVisibility(VISIBLE);/*from  w  w w.j  a v a 2  s.co m*/
        overlay.startAnimation(AnimationUtils.loadAnimation(getContext(), overlayInId));
        if (contentView != null) {
            contentView.startAnimation(AnimationUtils.loadAnimation(getContext(), dialogInId));
        }
    } else {
        showAfterLoad = true;
    }
}

From source file:com.csumax.maxgithubclient.fragment.ProgressFragment.java

private void setContentShown(boolean shown, boolean animate) {
    ensureContent();//from   w w w  .j a va 2 s.co m
    if (mContentShown == shown) {
        return;
    }
    mContentShown = shown;
    if (shown) {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            mContentContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        } else {
            mProgressContainer.clearAnimation();
            mContentContainer.clearAnimation();
        }
        mProgressContainer.setVisibility(View.GONE);
        mContentContainer.setVisibility(View.VISIBLE);
    } else {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            mContentContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        } else {
            mProgressContainer.clearAnimation();
            mContentContainer.clearAnimation();
        }
        mProgressContainer.setVisibility(View.VISIBLE);
        mContentContainer.setVisibility(View.GONE);
    }
}