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.pixelpixel.pyp.SplashActivity.java

/** Called when the activity is first created. */
@Override/*from  ww  w  .  j a  v  a2s  .  c o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splash);

    //Initializing the application cache
    final int memClass = ((ActivityManager) this.getSystemService(Context.ACTIVITY_SERVICE)).getMemoryClass();
    final int cacheSize = 1024 * 1024 * memClass / 4;
    mMemoryCache = new LruCache<String, Object>(cacheSize);

    /*
     * Setting up the animation for the logo
     * */
    final ImageView splash_logo = (ImageView) findViewById(R.id.SplashLogo);
    Animation sa1 = AnimationUtils.loadAnimation(this, R.anim.splash_anim);
    sa1.setAnimationListener(new AnimationListener() {

        public void onAnimationEnd(Animation arg0) {
            /*
             * After the end of the "growing" animation, we call the "shrinking" animation.
             * */
            Animation sa2 = AnimationUtils.loadAnimation(SplashActivity.this, R.anim.splash_anim2);
            sa2.setAnimationListener(new AnimationListener() {

                public void onAnimationEnd(Animation animation) {
                    /*
                     * After the end of the "shrinking" animation, we proceed to the
                     * next screen, the start screen.
                     * */
                    Handler mHandler = new Handler();
                    mHandler.postDelayed(new Runnable() {
                        public void run() {
                            startActivity(new Intent(SplashActivity.this, StartActivity.class));
                            SplashActivity.this.finish();
                        }
                    }, 5000);
                }

                public void onAnimationRepeat(Animation animation) {
                }

                public void onAnimationStart(Animation animation) {
                }

            });
            splash_logo.startAnimation(sa2);
        }

        public void onAnimationRepeat(Animation animation) {
        }

        public void onAnimationStart(Animation animation) {
        }

    });

    splash_logo.startAnimation(sa1);
}

From source file:com.example.t_danbubbletea.MySelections.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_tea_selections, container, false);
    getActivity().setTitle("Tea Selections");
    // animation when enter home page
    rootView.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.image_click));
    //download the URL's asynchronously (put the info in the teaInfo object)
    try {//w w  w .  j a v a  2  s .com
        teaInfo = new GetTeaInfoTask().execute(new ApiConnector()).get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }
    //make the gridview, set its adapter
    GridView gridView = (GridView) rootView.findViewById(R.id.grid_view_tea_selections);
    GridViewCustomAdapter gvAdapter = new GridViewCustomAdapter(getActivity(), teaInfo.imageURLs,
            teaInfo.teaNames);
    gridView.setAdapter(gvAdapter);
    //make the on click listeners
    gridView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Fragment newFragment;
            switch (position) {
            default:
                Bundle teaViewArgs = new Bundle();
                teaViewArgs.putString("teaName", teaInfo.teaNames.get(position));
                teaViewArgs.putString("teaImgUrl", teaInfo.imageURLs.get(position));
                teaViewArgs.putString("teaDesc", teaInfo.teaDescriptions.get(position));
                newFragment = new TeaViewFragment();
                newFragment.setArguments(teaViewArgs);
                break;

            }
            if (newFragment != null) {
                flipCard(newFragment);
            }
        }

        private void flipCard(Fragment newFragment) {
            mShowingBack = true;
            FragmentManager fragmentManager = getFragmentManager();
            fragmentManager.beginTransaction()
                    .setCustomAnimations(R.anim.card_flip_right_in, R.anim.card_flip_right_out,
                            R.anim.card_flip_left_in, R.anim.card_flip_left_out)
                    .replace(R.id.frame_container, newFragment).addToBackStack(null).commit(); // create new fragment and allow user to go back to previous fragment          
        }
    });
    return rootView;
}

From source file:com.androzic.GPSInfo.java

@SuppressLint("InflateParams")
@Override/*w w  w.ja v a 2 s .com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getString(R.string.information_name));
    View view = getActivity().getLayoutInflater().inflate(R.layout.dlg_gps_info, null);
    builder.setView(view);
    builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            GPSInfo.this.dismiss();
        }
    });
    builder.setNeutralButton(R.string.update_almanac, updateOnClickListener);

    satsValue = (TextView) view.findViewById(R.id.sats);
    lastfixValue = (TextView) view.findViewById(R.id.lastfix);
    accuracyValue = (TextView) view.findViewById(R.id.accuracy);
    hdopValue = (TextView) view.findViewById(R.id.hdop);
    vdopValue = (TextView) view.findViewById(R.id.vdop);

    //TODO Make it update periodically
    updateGPSInfo();

    return builder.create();
}

From source file:com.raja.knowme.FragmentSpecialization.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_specialization, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    knowmeData = new KnowMeDataObject(getActivity());
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading));

    mSpecializationHolder = (LinearLayout) mHolderView.findViewById(R.id.specialization_container_view);
    mProgressDialog.show();//from   ww w .j ava  2  s.  c  om
    new LoadData().execute();
    return mHolderView;
}

From source file:com.raja.knowme.FragmentSkills.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mHolderView = inflater.inflate(R.layout.fragment_skills, null);
    shake = AnimationUtils.loadAnimation(getActivity(), R.anim.shake);
    knowmeData = new KnowMeDataObject(getActivity());
    mProgressDialog = new ProgressDialog(getActivity());
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading));

    mSkillsHolder = (LinearLayout) mHolderView.findViewById(R.id.skills_container_view);
    mProgressDialog.show();/*w w w . j av a2 s. c o  m*/
    new LoadData().execute();
    return mHolderView;
}

From source file:com.bilibili.socialize.share.utils.selector.PopFullScreenSharePlatformSelector.java

private void showEnterAnimation() {
    if (enterAnimation == null)
        enterAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.socialize_shareboard_animation_in);
    grid.setAnimation(enterAnimation);/*from   w w w.  j ava 2  s  .  co  m*/
    enterAnimation.start();
}

From source file:com.github.pennyfive.cinemafinlando.ui.UiUtils.java

public static View inflateDefaultLoadingView(Context context, int backgroundResource) {
    View view = View.inflate(context, R.layout.state_loading, null);
    view.setBackgroundResource(backgroundResource);
    view.findViewById(R.id.spinner)/*from   w  ww.j a v  a 2  s .co  m*/
            .startAnimation(AnimationUtils.loadAnimation(context, R.anim.spinner_spin_around));
    return view;
}

From source file:com.sonymobile.androidapp.gridcomputing.views.StatusProgressBar.java

/**
 * Transition through states of progress bar.
 *
 * @param mode Mode to transition to./*ww w  . j a va 2  s .c o m*/
 */
public void changeMode(final ProgressStatus mode) {
    if (mCurrentStatus != mode && !ApplicationData.isJUnit()) {
        mCurrentStatus = mode;
        final Drawable drawable;
        final Animation anim;
        setVisibility(View.VISIBLE);
        clearAnimation();
        switch (mode) {
        case RUNNING:
            drawable = ContextCompat.getDrawable(getContext(), R.drawable.img_processing);
            anim = AnimationUtils.loadAnimation(getContext(), R.anim.progress_spinner_anim);
            startAnimation(anim);
            break;
        case STAND_BY:
            drawable = ContextCompat.getDrawable(getContext(), R.drawable.ic_proc_pause);
            anim = AnimationUtils.loadAnimation(getContext(), R.anim.fade_anim);
            startAnimation(anim);
            break;
        case NONE:
            drawable = null;
            setVisibility(View.INVISIBLE);
            break;
        default:
            drawable = null;
            setVisibility(View.INVISIBLE);
            break;
        }
        setIndeterminateDrawable(drawable);
        requestLayout();
    }
}

From source file:com.offers.couponempire.fragment.BaseNativeListFragment.java

/**
 * @param shown//from   w w  w.j ava2 s .c o m
 * @param animate
 */
protected void setListShown(boolean shown, boolean animate) {
    if (mListShown == shown) {
        return;
    }
    mListShown = shown;
    if (shown) {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            mListContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
        }
        mProgressContainer.setVisibility(View.GONE);
        mListContainer.setVisibility(View.VISIBLE);
    } else {
        if (animate) {
            mProgressContainer
                    .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            mListContainer.startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
        }
        mProgressContainer.setVisibility(View.VISIBLE);
        mListContainer.setVisibility(View.INVISIBLE);
    }
}

From source file:com.poussiere_violette.poussieremagique.TextFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layoutView = inflater.inflate(R.layout.fragment_text, container, false);
    tv = (TextView) layoutView.findViewById(R.id.tasty);
    v = (View) layoutView.findViewById(R.id.conteneur);
    grandConteneur = (View) getActivity().findViewById(R.id.main_content);

    destinNumber = ((MainActivity2) this.getActivity()).getDestinNumber();
    destin = new Destin(destinNumber, getContext());

    animation = AnimationUtils.loadAnimation(getContext(), R.anim.zoomout);
    animation2 = AnimationUtils.loadAnimation(getContext(), R.anim.blink);
    seq1 = AnimationUtils.loadAnimation(getContext(), R.anim.seq1);
    animation3 = AnimationUtils.loadAnimation(getContext(), R.anim.blink_no_repeat);

    return layoutView;

}