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:co.herdy.manager.presentation.view.behaviour.ScrollAwareFloatingActionButtonBehavior.java

@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target,
        int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
    super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);

    if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
        child.hide();/*from   w  ww. ja va2s.c o  m*/
    } else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
        child.show();
        // Create a Simple growth Animation
        Animation simpleGrowAnimation = AnimationUtils.loadAnimation(child.getContext(), R.anim.grow_bigger);
        child.startAnimation(simpleGrowAnimation);
    }
}

From source file:com.csipsimple.widgets.CSSListFragment.java

private void setListShown(boolean shown, boolean animate) {
    ensureCustomList();/*  w  w  w. j a v a 2  s. c  o m*/
    if (mListShown == shown) {
        return;
    }
    mListShown = shown;
    if (mListContainer != null && mProgressContainer != null) {
        if (shown) {
            if (animate) {
                mListContainer
                        .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_in));
            }
            mListContainer.setVisibility(View.VISIBLE);
            mProgressContainer.setVisibility(View.GONE);
        } else {
            if (animate) {
                mListContainer
                        .startAnimation(AnimationUtils.loadAnimation(getActivity(), android.R.anim.fade_out));
            }
            mListContainer.setVisibility(View.GONE);
            mProgressContainer.setVisibility(View.VISIBLE);
        }
    }
}

From source file:com.example.examplersqr.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //////////////////////
    //  Setup QR Bar    //
    //////////////////////
    inAnim = AnimationUtils.loadAnimation(this, R.anim.abc_slide_in_top);
    outAnim = AnimationUtils.loadAnimation(this, R.anim.abc_slide_out_top);
    qrBar = (LinearLayout) findViewById(R.id.myQRBar);

    // In production, better to get this from a "values.xml" resource
    // in a res folder appropriate to screen size / orientation
    columnCount = 2;/*from ww w  . jav  a2 s  .  c  om*/

    // Set the QRBar Height to that of the ActionBar
    TypedValue tv = new TypedValue();
    if (getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
        qrBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    }

    tvQRBarTitle = (TextView) findViewById(R.id.tvQRBarTitle);
    tvQRBarTitle.setText("Tap to add item at top...");
    tvQRBarTitle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            addItemAtPosition(0, "NEW CARD ADDED ON: " + new Date().toString());
        }
    });

    //////////////////////////////
    //  Setup Swipe To Refresh  //
    //////////////////////////////
    swiper = (TargetedSwipeRefreshLayout) findViewById(R.id.swipe_container);
    swiper.setSize(SwipeRefreshLayout.LARGE);
    swiper.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_orange_light,
            android.R.color.holo_green_light, android.R.color.holo_red_light);

    swiper.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            // This is where you should kickoff the
            // refreshing task.

            // For now, just wait a few seconds and turn off refreshing.
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    if (myDataset != null && mAdapter != null) {
                        Collections.shuffle(myDataset);
                        mAdapter.notifyDataSetChanged();
                    }
                    swiper.setRefreshing(false);
                }
            }, 5000);
        }
    });

    //////////////////////////////////////////////
    //  Grab the StaggeredGrid & Layout Manager //
    //////////////////////////////////////////////
    mRecycler = (RecyclerView) findViewById(R.id.rvExampleGrid);
    mRecycler.addItemDecoration(new QRBarDecoration(columnCount, qrBarHeight));
    // mRecycler.addItemDecoration(new OverlapDecoration());

    mSGLM = new StaggeredGridLayoutManager(columnCount, StaggeredGridLayoutManager.VERTICAL);

    mRecycler.setLayoutManager(mSGLM);

    //////////////////////////////
    //  Setup Adapter & DataSet //
    //////////////////////////////
    myDataset = new ArrayList<String>();

    // Load up the dataset with random titles
    for (int x = 0; x < 50; x++) {
        myDataset.add(someTitles[randy.nextInt(someTitles.length)]);
    }

    mAdapter = new RVAdapter(this, myDataset);

    /////////////////////////////////////////////
    //  Setup the RecyclerView Scroll Listener //
    /////////////////////////////////////////////
    mRecycler.setOnScrollListener(new RecyclerView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {

            // Simple check if moved vertically.
            // React to scrolls of a minimum amount (3, in this case)
            if (dy > 3) {

                if (qrBar.getVisibility() == View.VISIBLE)
                    hideQRBar();

            } else if (dy < -3) {

                if (qrBar.getVisibility() == View.GONE)
                    showQRBar();
            }
        }
    });

    // Set the RecyclerView's Adapter
    mRecycler.setAdapter(mAdapter);

    // Set the Recyclerview to be the target scrollable view
    // for the TargetedSwipeRefreshAdapter.
    swiper.setTargetScrollableView(mRecycler);

}

From source file:com.adityarathi.muo.ui.fragments.BuildingLibraryProgressFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;/*from  ww w.  j  a  v  a  2s  .c  o m*/
    mRootView = (View) getActivity().getLayoutInflater().inflate(R.layout.fragment_building_library_progress,
            null);

    mProgressElementsContainer = (RelativeLayout) mRootView.findViewById(R.id.progress_elements_container);
    mProgressElementsContainer.setVisibility(View.INVISIBLE);

    mCurrentTaskText = (TextView) mRootView.findViewById(R.id.building_library_task);
    mCurrentTaskText
            .setPaintFlags(mCurrentTaskText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG);

    mProgressBar = (ProgressBar) mRootView.findViewById(R.id.building_library_progress);
    mProgressBar.setMax(1000000);

    mFadeInAnimation = AnimationUtils.loadAnimation(mContext, R.anim.fade_in);
    mFadeInAnimation.setAnimationListener(fadeInListener);
    mFadeInAnimation.setDuration(700);

    return mRootView;
}

From source file:com.hybris.mobile.app.commerce.utils.UIUtils.java

/**
 * Animate the layout to expand/* ww  w  . j av a 2  s . c o m*/
 */
public static void expandLayout(Context context, View view) {
    Animation animation = AnimationUtils.loadAnimation(context, R.anim.expand);
    view.setAnimation(animation);
    view.animate();
    animation.start();
}

From source file:com.koushikdutta.superuser.FragmentIntro.java

@Nullable
@Override//from w w w . j  av  a  2  s.  c om
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View parent = inflater.inflate(layoutResId, container, false);

    if (layoutResId != R.layout.fragment_intro_0)
        return parent;

    final ImageView superuser = (ImageView) parent.findViewById(R.id.superuser);
    final ImageView background = (ImageView) parent.findViewById(R.id.superuser_back);

    final TextView title = (TextView) parent.findViewById(R.id.title);
    final TextView desc = (TextView) parent.findViewById(R.id.tour);

    final Animation fadeIn, zoomIn;

    fadeIn = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in);
    zoomIn = AnimationUtils.loadAnimation(getContext(), R.anim.zoom_in);

    fadeIn.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            background.startAnimation(zoomIn);
            background.setVisibility(View.VISIBLE);
        }

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

    zoomIn.setAnimationListener(new Animation.AnimationListener() {
        @Override
        public void onAnimationStart(Animation animation) {
            Animation fadeIn2 = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in);
            fadeIn2.setDuration(1000);

            fadeIn2.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    Animation fadeIn3 = AnimationUtils.loadAnimation(getContext(), R.anim.fade_in);
                    fadeIn3.setDuration(400);

                    fadeIn3.setAnimationListener(new Animation.AnimationListener() {
                        @Override
                        public void onAnimationStart(Animation animation) {
                        }

                        @Override
                        public void onAnimationEnd(Animation animation) {
                            ((ActivityIntro) getActivity()).setProgressButtonEnabled(true);
                        }

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

                    desc.startAnimation(fadeIn3);
                    desc.setVisibility(View.VISIBLE);

                }

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

            title.startAnimation(fadeIn2);
            title.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
        }

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

    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            superuser.startAnimation(fadeIn);

            superuser.setVisibility(View.VISIBLE);
        }
    }, 600);

    return parent;
}

From source file:com.nikhilnayak.games.octoshootar.TutoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_tuto);
    mLastPosition = 0;//from   w  w  w  .  j  ava2  s.c om

    //load animation
    mSlideLeftInAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_left_in);
    mSlideLeftOutAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_left_out);
    mSlideRightInAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_right_in);
    mSlideRightOutAnimation = AnimationUtils.loadAnimation(this, R.anim.slide_right_out);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    final boolean firstLaunch = mPrefs.getBoolean(HomeActivity.KEY_HAS_TUTO_BEEN_SEEN, false);
    if (!firstLaunch) {
        final SharedPreferences.Editor editor = mPrefs.edit();
        editor.putBoolean(HomeActivity.KEY_HAS_TUTO_BEEN_SEEN, true);
        editor.apply();
    }

    mPageTitles = new String[] { getResources().getString(R.string.tuto_title_page_0),
            getResources().getString(R.string.tuto_title_page_8),
            getResources().getString(R.string.tuto_title_page_9),
            getResources().getString(R.string.tuto_title_page_10),
            getResources().getString(R.string.tuto_title_page_11),
            getResources().getString(R.string.tuto_title_page_7),
            getResources().getString(R.string.tuto_title_page_12) };

    //initialize title text switcher
    mTitleSwitcher = (TextSwitcher) findViewById(R.id.tuto_text_switcher);
    mTitleSwitcher.setFactory(this);
    mTitleSwitcher.setCurrentText(getResources().getString(R.string.tuto_title_page_0));

    final ViewPager pager = (ViewPager) findViewById(R.id.pager);
    final TutoPagerAdapter adapter = new TutoPagerAdapter(getSupportFragmentManager());
    pager.setAdapter(adapter);
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.tuto_page_margin));
    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int i, float v, int i2) {
        }

        @Override
        public void onPageSelected(int newPosition) {
            if (newPosition > mLastPosition) {
                mTitleSwitcher.setInAnimation(mSlideLeftInAnimation);
                mTitleSwitcher.setOutAnimation(mSlideLeftOutAnimation);
            } else {
                mTitleSwitcher.setInAnimation(mSlideRightInAnimation);
                mTitleSwitcher.setOutAnimation(mSlideRightOutAnimation);
            }
            mTitleSwitcher.setText(adapter.getPageTitle(newPosition));
            mLastPosition = newPosition;
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });

    final Button closeButton = (Button) findViewById(R.id.closeButton);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            closeTutorial();
        }
    });
}

From source file:com.github.vignesh_iopex.confirmdialog.DialogFragment.java

protected void dismissDialogContent() {
    Animation animation = AnimationUtils.loadAnimation(activity, R.anim.slide_to_bottom);
    animation.setAnimationListener(new Animation.AnimationListener() {
        @Override/*from   w  w w  .j av a2  s  .c o  m*/
        public void onAnimationStart(Animation animation) {

        }

        @Override
        public void onAnimationEnd(Animation animation) {
            dismiss();
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    this.dialogContentContainer.startAnimation(animation);
}

From source file:id.zelory.tanipedia.activity.KomoditasActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_komoditas);
    toolbar = (Toolbar) findViewById(R.id.anim_toolbar);
    setSupportActionBar(toolbar);//from   w  ww.  j  a  v a2  s .  c o m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("Harga Komoditas");

    animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);

    drawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer);
    setUpNavDrawer();
    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.getMenu().getItem(3).setChecked(true);
    TextView nama = (TextView) navigationView.findViewById(R.id.nama);
    nama.setText(PrefUtils.ambilString(this, "nama"));
    TextView email = (TextView) navigationView.findViewById(R.id.email);
    email.setText(PrefUtils.ambilString(this, "email"));
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(MenuItem menuItem) {
            menuItem.setChecked(true);
            drawerLayout.closeDrawers();
            Intent intent;
            switch (menuItem.getItemId()) {
            case R.id.cuaca:
                intent = new Intent(KomoditasActivity.this, CuacaActivity.class);
                break;
            case R.id.berita:
                intent = new Intent(KomoditasActivity.this, BeritaActivity.class);
                break;
            case R.id.tanya:
                intent = new Intent(KomoditasActivity.this, TanyaActivity.class);
                break;
            case R.id.harga:
                return true;
            case R.id.logout:
                PrefUtils.simpanString(KomoditasActivity.this, "nama", null);
                intent = new Intent(KomoditasActivity.this, LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                startActivity(intent);
                return true;
            case R.id.tentang:
                intent = new Intent(KomoditasActivity.this, TentangActivity.class);
                startActivity(intent);
                return true;
            default:
                return true;
            }
            startActivity(intent);
            finish();
            return true;
        }
    });

    recyclerView = (RecyclerView) findViewById(R.id.scrollableview);
    recyclerView.setHasFixedSize(true);
    LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
    recyclerView.setLayoutManager(linearLayoutManager);

    imageHeader = (ImageView) findViewById(R.id.header);
    imageHeader.setVisibility(View.GONE);

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.showProgress(true);
    new DownloadData().execute();
    fabButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            fabButton.showProgress(true);
            new DownloadData().execute();
        }
    });
}

From source file:com.hctrom.romcontrol.licenseadapter.LicenseDialogoAlerta.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ThemeSelectorUtility theme = new ThemeSelectorUtility(getActivity());
    theme.onActivityCreateSetTheme(getActivity());
    final View view = inflater.inflate(R.layout.license_app, container, false);
    titulo = (TextView) view.findViewById(R.id.textViewTitulo);
    licenses = (Button) view.findViewById(R.id.imageButtonCompartir);
    buttonBack = (ActionButton) view.findViewById(R.id.boton_flotante_back);
    email = (ImageView) view.findViewById(R.id.mail);
    apache = (TextView) view.findViewById(R.id.textViewApache);
    Linkify.addLinks(apache, Linkify.WEB_URLS);
    applyBlurMaskFilter(titulo, BlurMaskFilter.Blur.OUTER);
    getDialog().setCanceledOnTouchOutside(false);
    licenses.setOnClickListener(this);
    buttonBack.setOnClickListener(new View.OnClickListener() {
        @Override/*  w ww .  ja v  a2 s. c  o  m*/
        public void onClick(View v) {
            getDialog().cancel();
        }
    });

    email.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN: {
                Drawable mDrawable = getActivity().getResources().getDrawable(R.drawable.mail);
                mDrawable.setColorFilter(new PorterDuffColorFilter(
                        getActivity().getResources().getColor(R.color.selector), PorterDuff.Mode.MULTIPLY));

                email.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fab_close));
                email.invalidate();
                break;
            }
            case MotionEvent.ACTION_UP: {
                Drawable mDrawable = getActivity().getResources().getDrawable(R.drawable.mail);
                mDrawable.setColorFilter(new PorterDuffColorFilter(
                        getActivity().getResources().getColor(R.color.selector), PorterDuff.Mode.MULTIPLY));
                email.setAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.fab_open));
                email.invalidate();
                break;
            }
            }
            return false;
        }
    });

    email.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(getActivity(), Mail.class));
        }
    });
    return view;
}