Example usage for android.view View animate

List of usage examples for android.view View animate

Introduction

In this page you can find the example usage for android.view View animate.

Prototype

public ViewPropertyAnimator animate() 

Source Link

Document

This method returns a ViewPropertyAnimator object, which can be used to animate specific properties on this View.

Usage

From source file:com.amaze.filemanager.utils.files.FileUtils.java

public static void crossfade(View buttons, final View pathbar) {
    // Set the content view to 0% opacity but visible, so that it is visible
    // (but fully transparent) during the animation.
    buttons.setAlpha(0f);/*from  w  w  w.j av  a  2s  . co  m*/
    buttons.setVisibility(View.VISIBLE);

    // Animate the content view to 100% opacity, and clear any animation
    // listener set on the view.
    buttons.animate().alpha(1f).setDuration(100).setListener(null);
    pathbar.animate().alpha(0f).setDuration(100).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            pathbar.setVisibility(View.GONE);
        }
    });
    // Animate the loading view to 0% opacity. After the animation ends,
    // set its visibility to GONE as an optimization step (it won't
    // participate in layout passes, etc.)
}

From source file:com.oprisnik.navdrawer.widget.NavDrawerLayout.java

public void fadeOutContent() {
    for (int i = 0; i < getChildCount(); i++) {
        View v = getChildAt(i);
        if (isContentView(v)) {
            v.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
        }//from   ww w.jav a  2  s .com
    }
}

From source file:com.oprisnik.navdrawer.widget.NavDrawerLayout.java

public void fadeInContent() {
    for (int i = 0; i < getChildCount(); i++) {
        View v = getChildAt(i);
        if (isContentView(v)) {
            v.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
        }//from  ww  w.j a v  a2 s . co m
    }
}

From source file:com.microsoft.mimickeralarm.onboarding.OnboardingTutorialFragment.java

@Override
public void onResume() {
    super.onResume();
    final View welcomePage = getView().findViewById(R.id.onboarding_welcome);
    View tutorialContainer = getView().findViewById(R.id.onboarding_tutorial);
    if (!mStarted) {
        mStarted = true;/*from   w  w  w .j a v a  2  s .  c o m*/
        tutorialContainer.setAlpha(0f);
        tutorialContainer.setVisibility(View.VISIBLE);
        tutorialContainer.animate().alpha(1f).setDuration(WELCOME_MSG_CROSSFADE_DURATION)
                .setStartDelay(WELCOME_MSG_DURATION).setListener(null);
        welcomePage.animate().alpha(0).setDuration(WELCOME_MSG_CROSSFADE_DURATION)
                .setStartDelay(WELCOME_MSG_DURATION).setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        welcomePage.setVisibility(View.GONE);
                    }
                });
    } else {
        tutorialContainer.setAlpha(1f);
    }
}

From source file:ir.newway.jazzylistview.JazzyHelper.java

private void doJazzinessImpl(View item, int position, int scrollDirection) {
    try {//from  w ww .  ja  v a  2 s .com
        ViewPropertyAnimator animator = item.animate().setDuration(DURATION).setInterpolator(mInterpolator);

        scrollDirection = scrollDirection > 0 ? 1 : -1;
        mTransitionEffect.initView(item, position, scrollDirection);
        mTransitionEffect.setupAnimation(item, position, scrollDirection, animator);
        animator.start();

    } catch (Exception e) {
        //    e.printStackTrace();
    }
}

From source file:com.sj.android.appusage.ui.widgets.listview.SwipeListViewTouchListener.java

/**
 * Create reveal animation//www  .  ja  va  2 s . c om
 *
 * @param view      affected view
 * @param swap      If will change state. If "false" returns to the original position
 * @param swapRight If swap is true, this parameter tells if movement is toward right or left
 * @param position  list position
 */
private void generateRevealAnimate(final View view, final boolean swap, final boolean swapRight,
        final int position, final float deltaX) {

    view.animate().translationX(viewWidth).setDuration(400).setListener(new AnimatorListener() {

        @Override
        public void onAnimationCancel(android.animation.Animator animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationStart(android.animation.Animator animation) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onAnimationEnd(android.animation.Animator animation) {
            if (mSwipeListener != null) {
                mSwipeListener.onItemSwiped(downPosition);
            }

            resetCell();
        }

        @Override
        public void onAnimationRepeat(android.animation.Animator animation) {
            // TODO Auto-generated method stub

        }
    });
}

From source file:com.eggwall.SoundSleep.SleepActivity.java

/**
 * Moves the icons to some random location.
 *//*from   w w  w.  j  av  a  2  s.  c  om*/
private void changeIconLocation() {
    populateTopLevelDimen();
    setGlobalScreenSettings();
    if (cloudSize == null || noteSize == null) {
        return;
    }
    final double locationX = Math.random();
    // The top half of the screen is for the note.
    final int noteY = 0;
    // The bottom half of the screen is for white noise.
    final int cloudY = mHeight - cloudSize.mSecond;
    // The cloud and the note mirror each other on opposite sides to
    // increase visual separation.
    final int cloudX = (int) (locationX * (mWidth - cloudSize.mFirst));
    final float newCloudAlpha = (float) (.35 - (mAlphaDecrement / 100.0));
    final float newNoteAlpha = (float) (.50 - (mAlphaDecrement / 100.0));
    final int noteX = (int) ((1 - locationX) * (mWidth - noteSize.mFirst));
    mAlphaDecrement += 5;
    if (mAlphaDecrement > 20) {
        mAlphaDecrement = 20;
    }
    final View cloud = findViewById(R.id.cloud);
    final View note = findViewById(R.id.note);
    if (SDK >= 11) {
        cloud.setY(cloudY);
        cloud.animate().x(cloudX).alpha(newCloudAlpha);
        note.setY(noteY);
        note.animate().x(noteX).alpha(newNoteAlpha);
    } else {
        cloud.setPadding(cloudX, cloudY, 0, 0);
        note.setPadding(noteX, noteY, 0, 0);
    }
}

From source file:pl.mrwojtek.sensrec.app.RecordsActivity.java

private void animateHide(final View view, boolean animate) {
    if (animate) {
        view.bringToFront();//from   w  ww. j av  a  2 s  . c o  m
        view.animate().alpha(0.0f).setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
    } else {
        view.setVisibility(View.GONE);
    }
}

From source file:com.carver.paul.truesight.Ui.MainActivity.java

/**
 * stopHeroRecognitionLoadingAnimations shows makes the the camera do one final pulse, and
 * then fades it away//from   w w w. jav a2s  .com
 */
protected void stopHeroRecognitionLoadingAnimations() {
    View processingText = findViewById(R.id.text_processing_image);
    processingText.animate().alpha(0).setDuration(150);

    View cameraImage = findViewById(R.id.image_pulsing_camera);
    Animation animation = cameraImage.getAnimation();
    if (animation != null) {
        animation.setRepeatCount(0);
    }

    cameraImage.animate().alpha(0).setDuration(150);
}

From source file:com.dm.material.dashboard.candybar.fragments.IconsBaseFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_search, menu);
    MenuItem search = menu.findItem(R.id.menu_search);

    MenuItemCompat.setOnActionExpandListener(search, new MenuItemCompat.OnActionExpandListener() {
        @Override//from ww  w. j a va 2  s. c  om
        public boolean onMenuItemActionExpand(MenuItem item) {
            FragmentManager fm = getActivity().getSupportFragmentManager();
            if (fm == null)
                return false;

            setHasOptionsMenu(false);
            View view = getActivity().findViewById(R.id.shadow);
            if (view != null)
                view.animate().translationY(-mTabLayout.getHeight()).setDuration(200).start();
            mTabLayout.animate().translationY(-mTabLayout.getHeight()).setDuration(200)
                    .setListener(new AnimatorListenerAdapter() {
                        @Override
                        public void onAnimationEnd(android.animation.Animator animation) {
                            super.onAnimationEnd(animation);
                            Fragment prev = fm.findFragmentByTag("home");
                            if (prev != null)
                                return;

                            PagerIconsAdapter adapter = (PagerIconsAdapter) mPager.getAdapter();
                            if (adapter == null)
                                return;

                            SearchListener listener = (SearchListener) getActivity();
                            listener.onSearchExpanded(true);

                            FragmentTransaction ft = fm.beginTransaction()
                                    .replace(R.id.container, new IconsSearchFragment(), IconsSearchFragment.TAG)
                                    .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                                    .addToBackStack(null);

                            try {
                                ft.commit();
                            } catch (Exception e) {
                                ft.commitAllowingStateLoss();
                            }
                        }
                    }).start();

            return false;
        }

        @Override
        public boolean onMenuItemActionCollapse(MenuItem item) {
            return true;
        }
    });
}