Example usage for android.widget ViewAnimator setInAnimation

List of usage examples for android.widget ViewAnimator setInAnimation

Introduction

In this page you can find the example usage for android.widget ViewAnimator setInAnimation.

Prototype

public void setInAnimation(Context context, @AnimRes int resourceID) 

Source Link

Document

Specifies the animation used to animate a View that enters the screen.

Usage

From source file:Main.java

public static void setAnimation(Context context, ViewAnimator victim, int in_animRrs, int out_animRrs) {
    // victim.setInAnimation(AnimationUtils.loadAnimation(context,
    // animRrs));
    victim.setInAnimation(context, in_animRrs);
    victim.setOutAnimation(context, out_animRrs);
}

From source file:com.doplgangr.secrecy.views.VaultsListFragment.java

void switchView(final View parentView, final int showView) {
    getActivity().runOnUiThread(new Runnable() {
        @Override//from ww  w .j  av a  2 s. co m
        public void run() {
            EditText passwordView = (EditText) parentView.findViewById(R.id.open_password);
            final View renameView = parentView.findViewById(R.id.rename_name);
            ViewAnimator viewAnimator = (ViewAnimator) parentView.findViewById(R.id.viewAnimator);
            viewAnimator.setInAnimation(context, R.anim.slide_down);

            int viewIndex = 0;
            switch (showView) {
            case R.id.vault_name_layout:
                viewIndex = 0;
                break;
            case R.id.vault_decrypt_layout:
                viewIndex = 1;
                if (passwordView != null) {
                    passwordView.requestFocus();
                    passwordView.setText(""); //Reset password field everytime
                }

                // Only one vault selected at that time
                passwordView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                    @Override
                    public void onFocusChange(View v, boolean hasFocus) {
                        if (!hasFocus) {
                            ViewAnimator viewAnimator = (ViewAnimator) parentView
                                    .findViewById(R.id.viewAnimator);
                            viewAnimator.setDisplayedChild(0);
                        }
                    }
                });
                kbdView = passwordView;
                imm.showSoftInput(passwordView, InputMethodManager.SHOW_IMPLICIT);
                break;
            case R.id.vault_delete_layout:
                viewIndex = 2;
                break;
            case R.id.vault_rename_layout:
                viewIndex = 3;
                if (renameView != null)
                    renameView.requestFocus();

                // Only one vault selected at that time
                renameView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                    @Override
                    public void onFocusChange(View v, boolean hasFocus) {
                        if (!hasFocus) {
                            ViewAnimator viewAnimator = (ViewAnimator) parentView
                                    .findViewById(R.id.viewAnimator);
                            viewAnimator.setDisplayedChild(0);
                        }
                    }
                });
                kbdView = renameView;
                imm.showSoftInput(renameView, InputMethodManager.SHOW_IMPLICIT);
                break;
            }

            viewAnimator.setDisplayedChild(viewIndex);
        }
    });
}

From source file:com.doplgangr.secrecy.views.FilesListFragment.java

void switchView(final View frame, final int showView) {
    getActivity().runOnUiThread(new Runnable() {
        @Override//  w  w  w  .  j  av  a2s  .c o m
        public void run() {
            if (frame == null) {
                return;
            }
            FilesListAdapter.ViewHolder holder = (FilesListAdapter.ViewHolder) frame.getTag();
            ViewAnimator viewAnimator = holder.animator;
            viewAnimator.setInAnimation(context, R.anim.slide_down);
            int viewIndex = 0;
            switch (showView) {
            case R.id.dataLayout:
                viewIndex = 0;
                break;
            case R.id.DecryptLayout:
                viewIndex = 1;
                break;
            }
            viewAnimator.setDisplayedChild(viewIndex);
            viewAnimator.setInAnimation(null);
            holder.page = viewIndex;
        }
    });
}