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.cnm.cnmrc.fragment.search.SearchNaver.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation anim;//  w w w .  j  a v a 2  s  .  c o m

    if (enter)
        anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_entering);
    else
        anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_exit);

    anim.setAnimationListener(new AnimationListener() {
        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            ((MainActivity) getActivity()).getMyProgressBar().show();
            showSearchNaver();
        }

        public void onAnimationRepeat(Animation animation) {
        }
    });

    return anim;
}

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

public void hideDialog() {

    int overlayOutId = UserHook.getResourceId("uh_overlay_out", "anim");
    int dialogOutId = UserHook.getResourceId("uh_dialog_out", "anim");

    if (contentView != null) {
        contentView.startAnimation(AnimationUtils.loadAnimation(getContext(), dialogOutId));
    }//from   w w  w .ja v  a 2s  .com

    Animation a = AnimationUtils.loadAnimation(getContext(), overlayOutId);

    final View thisView = this;
    a.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            getRootView().post(new Runnable() {
                @Override
                public void run() {
                    ((ViewGroup) getParent()).removeView(thisView);
                }
            });

        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });

    overlay.startAnimation(a);

}

From source file:com.hhwt.travelplanner.adapter.VoteNextadapter.java

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    final City item = items.get(position);
    final ViewHolder vh = holder;
    holder.title.setText(item.getCity());
    holder.itemView.setTag(item);/* w  w w .j  a  va 2 s. c  o  m*/
    if ((position % 2) == 0) {
        holder.topcard.setBackgroundColor(ContextCompat.getColor(mContext, R.color.layoutBackground));
        holder.voteLayout.setBackgroundColor(ContextCompat.getColor(mContext, R.color.layoutBackground));

    } else {
        holder.topcard.setBackgroundColor(ContextCompat.getColor(mContext, R.color.white));
        holder.voteLayout.setBackgroundColor(ContextCompat.getColor(mContext, R.color.white));
    }
    if (item.getImg().length() > 0) {
        try {
            final String s = item.getImg();
            //         PicassoCache.getPicassoInstance(mContext).load(s).into(holder.image);
            Picasso.with(mContext).load(s).networkPolicy(NetworkPolicy.OFFLINE).into(holder.image,
                    new Callback() {
                        @Override
                        public void onSuccess() {

                        }

                        @Override
                        public void onError() {
                            //Try again online if cache failed
                            Picasso.with(mContext).load(s).error(R.drawable.background_default)
                                    .placeholder(R.drawable.loading).into(vh.image, new Callback() {
                                        @Override
                                        public void onSuccess() {

                                        }

                                        @Override
                                        public void onError() {
                                            //  vs.Icon.setImageResource(R.drawable.groupchat_icon_48dp);
                                        }
                                    });
                        }
                    });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    Animation animation = AnimationUtils.loadAnimation(mContext,
            (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top);
    vh.topcard.startAnimation(animation);
    lastPosition = position;
}

From source file:com.cnm.cnmrc.fragment.search.SearchVodSemi.java

@Override
public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) {
    Animation anim;//from   w  ww .  j  av  a2s.  co m

    if (enter)
        anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_entering);
    else
        anim = AnimationUtils.loadAnimation(getActivity(), R.anim.fragment_exit);

    anim.setAnimationListener(new AnimationListener() {
        public void onAnimationStart(Animation animation) {
        }

        public void onAnimationEnd(Animation animation) {
            ((MainActivity) getActivity()).getMyProgressBar().show();
            showSearchVodSemi();
        }

        public void onAnimationRepeat(Animation animation) {
        }
    });

    return anim;
}

From source file:com.daiv.android.twitter.manipulations.EmojiKeyboard.java

public void setVisibility(final boolean visible) {
    setVisibility(View.VISIBLE);//from ww  w.  ja v  a  2  s  .  c  o m
    Animation animation = AnimationUtils.loadAnimation(getContext(),
            visible ? R.anim.emoji_slide_out : R.anim.emoji_slide_in);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            setVisibility(visible ? View.VISIBLE : View.GONE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }
    });
    startAnimation(animation);
}

From source file:com.chromium.fontinstaller.util.ViewUtils.java

public static void animGrowFromCenter(View view, Context context) {
    if (context == null || view == null)
        return;//from  w  w w.  j  a  v  a 2  s  .co m
    view.startAnimation(AnimationUtils.loadAnimation(context, R.anim.grow_from_center));
}

From source file:com.lamcreations.scaffold.common.views.behaviors.FabBehavior.java

private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button).scaleX(1.0F).scaleY(1.0F).alpha(1.0F).setInterpolator(INTERPOLATOR)
                .withLayer().setListener(null).start();
    } else {// w ww  . j  av  a  2 s.c  om
        Animation anim = AnimationUtils.loadAnimation(button.getContext(), R.anim.scaffold_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}

From source file:com.pizidea.imagepicker.activity.ImageDeleteActivity.java

public void onImageSingleTap(MotionEvent e) {
    View topBar = findViewById(R.id.top_bar);
    View bottomBar = findViewById(R.id.bottom_bar);
    if (topBar.getVisibility() == View.VISIBLE) {
        topBar.setAnimation(AnimationUtils.loadAnimation(ImageDeleteActivity.this, R.anim.top_out));
        //bottomBar.setAnimation(AnimationUtils.loadAnimation(ImageDeleteActivity.this, R.anim.fade_out));
        topBar.setVisibility(View.GONE);
        //bottomBar.setVisibility(View.GONE);
    } else {//from w  ww  . j  a v a 2s  .c  o  m
        topBar.setAnimation(AnimationUtils.loadAnimation(ImageDeleteActivity.this, R.anim.top_in));
        //bottomBar.setAnimation(AnimationUtils.loadAnimation(ImageDeleteActivity.this, R.anim.fade_in));
        topBar.setVisibility(View.VISIBLE);
        //bottomBar.setVisibility(View.VISIBLE);
    }

}

From source file:com.afayear.android.client.activity.DualPaneActivity.java

@Override
public void onBackStackChanged() {
    if (isDualPaneMode()) {
        final FragmentManager fm = getSupportFragmentManager();
        final int count = fm.getBackStackEntryCount();
        final Fragment left_pane_fragment = fm.findFragmentById(PANE_LEFT);
        final Fragment right_pane_fragment = fm.findFragmentById(PANE_RIGHT);
        final View main_view = findViewById(R.id.main);
        final boolean left_pane_used = left_pane_fragment != null && left_pane_fragment.isAdded();
        final boolean right_pane_used = right_pane_fragment != null && right_pane_fragment.isAdded();
        if (count > 0) {
            final BackStackEntry entry = fm.getBackStackEntryAt(count - 1);
            if (entry == null)
                return;
            final Fragment fragment = BackStackEntryTrojan.getFragmentInBackStackRecord(entry);
            if (fragment instanceof Panes.Right) {
                showRightPane();//from   w w  w. j  a v a2s .c om
            } else if (fragment instanceof Panes.Left) {
                showLeftPane();
            }
        } else {
            if (fm.findFragmentById(R.id.main) != null || left_pane_used) {
                showLeftPane();
            } else if (right_pane_used) {
                showRightPane();
            }
        }
        if (main_view != null) {
            final int visibility = left_pane_used ? View.GONE : View.VISIBLE;
            // Visibility changed, so start animation.
            if (main_view.getVisibility() != visibility) {
                final Animation anim = AnimationUtils.loadAnimation(this,
                        left_pane_used ? android.R.anim.fade_out : android.R.anim.fade_in);
                main_view.startAnimation(anim);
            }
            main_view.setVisibility(visibility);
        }
    }
}