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.carver.paul.truesight.Ui.MainActivity.java

protected void showClearFab() {
    View fab = findViewById(R.id.fab_clear);
    fab.setVisibility(View.VISIBLE);
    if (fab.getAlpha() != 1f) {
        fab.animate().alpha(1f).setDuration(150).setStartDelay(50);
    }/*from  ww w  .j a v  a2s. c o m*/
}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Hides a view, using animation if the platform supports it
 *
 * @param v                 View to hide
 * @param animationDuration duration of animation
 *///from ww  w.  j av  a 2 s .  c o  m
@TargetApi(14)
public static void hideViewWithAnimation(final View v, int animationDuration) {
    // If we're on a legacy device, hide the view without the animation
    if (!canAnimateViewModern()) {
        hideViewWithoutAnimation(v);
        return;
    }

    if (v.getVisibility() == View.GONE) {
        // View is already gone, return without doing anything
        return;
    }

    v.clearAnimation();
    if (canCancelAnimation()) {
        v.animate().cancel();
    }

    // Animate the 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.)
    v.animate().alpha(0f).setDuration(animationDuration).setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            v.setVisibility(View.GONE);
        }
    });
}

From source file:io.bunnyblue.noticedog.app.overlay.ui.OverlayNotificationBarView.java

private void openPopup(final AnimationFinishListener animationListener) {
    View translationLayer = findViewById(R.id.translating_layer);
    cancelTranslation();/*  ww w . j a  va  2s.  c  o m*/
    translationLayer.setTranslationY((float) (-getHeight()));
    translationLayer.animate().setDuration((long) SLIDE_IN_TIME).translationYBy((float) getHeight())
            .withEndAction(new Runnable() {
                public void run() {
                    if (animationListener != null) {
                        animationListener.onAnimationEnd(null);
                    }
                }
            });
}

From source file:org.sufficientlysecure.keychain.ui.ViewKeyAdvActivity.java

private void animateMenuItem(final MenuItem vEditSubkeys, final boolean animateShow) {

    View actionView = LayoutInflater.from(this).inflate(R.layout.edit_icon, null);
    vEditSubkeys.setActionView(actionView);
    actionView.setTranslationX(animateShow ? 150 : 0);

    ViewPropertyAnimator animator = actionView.animate();
    animator.translationX(animateShow ? 0 : 150);
    animator.setDuration(300);/*ww w  .j  ava 2 s  .  co  m*/
    animator.setInterpolator(new OvershootInterpolator(1.5f));
    animator.setListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (!animateShow) {
                vEditSubkeys.setVisible(false);
            }
            vEditSubkeys.setActionView(null);
        }
    });
    animator.start();

}

From source file:org.onebusaway.android.util.UIUtils.java

/**
 * Shows a view, using animation if the platform supports it
 *
 * @param v                 View to show
 * @param animationDuration duration of animation
 *///  w w  w  .j  a  v  a 2s  . c  o m
@TargetApi(14)
public static void showViewWithAnimation(final View v, int animationDuration) {
    // If we're on a legacy device, show the view without the animation
    if (!canAnimateViewModern()) {
        showViewWithoutAnimation(v);
        return;
    }

    if (v.getVisibility() == View.VISIBLE && v.getAlpha() == 1) {
        // View is already visible and not transparent, return without doing anything
        return;
    }

    v.clearAnimation();
    if (canCancelAnimation()) {
        v.animate().cancel();
    }

    if (v.getVisibility() != View.VISIBLE) {
        // Set the content view to 0% opacity but visible, so that it is visible
        // (but fully transparent) during the animation.
        v.setAlpha(0f);
        v.setVisibility(View.VISIBLE);
    }

    // Animate the content view to 100% opacity, and clear any animation listener set on the view.
    v.animate().alpha(1f).setDuration(animationDuration).setListener(null);
}

From source file:org.projectbuendia.client.ui.ProgressFragment.java

private void crossfade(View inView, final View outView) {

    // Set the content view to 0% opacity but visible, so that it is visible
    // (but fully transparent) during the animation.
    inView.setAlpha(0f);//from  ww w.  jav  a2 s  . c o  m
    inView.setVisibility(View.VISIBLE);

    // Animate the content view to 100% opacity, and clear any animation
    // listener set on the view.
    inView.animate().alpha(1f).setDuration(mShortAnimationDuration).setListener(null);

    // 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.)
    if (outView != null) {
        outView.animate().alpha(0f).setDuration(mShortAnimationDuration)
                .setListener(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
                        outView.setVisibility(View.GONE);
                    }
                });
    }
}

From source file:com.crazymin2.retailstore.ui.BaseActivity.java

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

    trySetupSwipeRefresh();// ww w  .  j a  v a2s.c om
    updateSwipeRefreshProgressBarTop();

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        mainContent.setAlpha(0);
        mainContent.animate().alpha(1).setDuration(MAIN_CONTENT_FADEIN_DURATION);
    } else {
        LOGW(TAG, "No view with ID main_content to fade in.");
    }
}

From source file:heartware.com.heartware_master.MeetupsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_meetups, container, false);
    mMeetupDialog = new MeetupDialogFragment();
    dbAdapter = new DBAdapter(getActivity());

    final HeartwareApplication app = (HeartwareApplication) getActivity().getApplication();

    mListView = (ListView) rootView.findViewById(android.R.id.list);

    final ArrayList<HashMap<String, String>> meetups = dbAdapter.getAllMeetups(app.getCurrentProfileId());
    mMeetupArray = new ArrayList<>(meetups.size());

    setMeetupArray(meetups);//from  w w w  . ja  va  2  s. com

    mArrayAdapter = new ArrayAdapter(getActivity(), R.layout.meetups_entry, R.id.tvNote, mMeetupArray);

    setListAdapter(mArrayAdapter);

    if (meetups.size() != 0) {
        //            mListView.setOnItemClickListener(new AdapterView.OnItemClickListener()
        //            {
        //                @Override
        //                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
        //                    Log.d(TAG, "in onItemSelected listener");
        //                    tvNote = (TextView) view.findViewById(R.id.tvNote);
        //                    HashMap<String, String> meetup = dbAdapter.getMeetupInfo(tvNote.getText().toString(), app.getCurrentProfileId());
        //                    mMeetupDialog.setMeetupText(meetup.get(DBAdapter.EXERCISE), meetup.get(DBAdapter.LOCATION),
        //                            meetup.get(DBAdapter.PEOPLE), meetup.get(DBAdapter.NOTE), meetup.get(DBAdapter.DATE));
        //
        //                    mMeetupDialog.show(getActivity().getFragmentManager(), TAG);
        //                }
        //            });

        mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, final View view, int position, long id) {
                Log.d(TAG, "in the onItemLongClick listener");
                tvNote = (TextView) view.findViewById(R.id.tvNote);
                final String noteName = tvNote.getText().toString();
                //                    dbAdapter.deleteWorkout(exName);
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    view.animate().setDuration(2000).alpha(0).withEndAction(new Runnable() {
                        @Override
                        public void run() {
                            mMeetupArray.remove(noteName);
                            mArrayAdapter.notifyDataSetChanged();
                            view.setAlpha(1);
                        }
                    });
                } else {
                    mMeetupArray.remove(noteName);
                    mArrayAdapter.notifyDataSetChanged();
                }

                // delete from SQL database
                dbAdapter.deleteMeetup(noteName);
                Toast.makeText(getActivity(), "Deleting " + noteName, Toast.LENGTH_SHORT).show();
                return true;
            }
        });
    }

    return rootView;
}

From source file:com.ffmpeger.card.ui.BaseNaviActivity.java

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }/*from  w ww.jav  a2  s . c  o m*/
    mStatusBarColorAnimator = ObjectAnimator
            .ofInt((mDrawerLayout != null) ? mDrawerLayout : getLPreviewUtils(),
                    (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor",
                    shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK)
            .setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();

    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }
}

From source file:org.apps8os.motivator.ui.MainActivity.java

/**
 * Showing the guide of the main sections in the application
 *///from  ww  w. j  a v a  2  s.c  o  m
public void showHelp() {
    if (!mHelpIsVisible) {
        mHelpIsVisible = true;
        mViewPager.setCurrentItem(1);
        final FrameLayout contentRoot = (FrameLayout) findViewById(R.id.root_view);
        // Inflate the help overlay to the fragment.
        getLayoutInflater().inflate(R.layout.element_help_overlay, contentRoot, true);

        final TextView helpTitle = (TextView) contentRoot.findViewById(R.id.help_overlay_title);
        helpTitle.setText(getString(R.string.today_section));
        final TextView helpText = (TextView) contentRoot.findViewById(R.id.help_overlay_subtitle);
        helpText.setText(getString(R.string.today_section_help));
        final LinearLayout helpBackground = (LinearLayout) contentRoot.findViewById(R.id.help_text_background);
        helpBackground.setBackgroundResource(R.color.actionbar_green);
        ((Button) contentRoot.findViewById(R.id.help_overlay_button)).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mViewPager.getCurrentItem() == 0) {
                    final View helpOverlay = (View) contentRoot.findViewById(R.id.help_overlay);
                    helpOverlay.animate().alpha(0f).setDuration(500).setListener(new AnimatorListenerAdapter() {

                        // Set the visibility to gone when animation has ended.
                        @Override
                        public void onAnimationEnd(Animator animation) {
                            helpOverlay.setVisibility(View.GONE);
                            contentRoot.removeView(helpOverlay);
                        }
                    });
                    mViewPager.setCurrentItem(1);

                    SharedPreferences.Editor editor = mPrefs.edit();
                    editor.putBoolean(SEEN_HELP, true);
                    editor.commit();
                    mHelpIsVisible = false;
                } else if (mViewPager.getCurrentItem() == 1) {
                    mViewPager.setCurrentItem(2);
                    helpTitle.setText(getString(R.string.plan_section));
                    helpText.setText(getString(R.string.plan_section_help));
                    helpBackground.setBackgroundResource(R.color.actionbar_blue);
                } else {
                    mViewPager.setCurrentItem(0);
                    helpTitle.setText(getString(R.string.history_section));
                    helpText.setText(getString(R.string.history_section_help));
                    helpBackground.setBackgroundResource(R.color.actionbar_orange);
                    ((Button) contentRoot.findViewById(R.id.help_overlay_button))
                            .setText(getString(R.string.ok));
                }
            }
        });
    }
}