Example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator

List of usage examples for android.view.animation AccelerateInterpolator AccelerateInterpolator

Introduction

In this page you can find the example usage for android.view.animation AccelerateInterpolator AccelerateInterpolator.

Prototype

public AccelerateInterpolator() 

Source Link

Usage

From source file:com.librelio.activity.StartupActivity.java

private void applyRotation(float start, float end) {
    // Find the center of image
    final float centerX = startupImage.getWidth() / 2.0f;
    final float centerY = startupImage.getHeight() / 2.0f;

    // Create a new 3D rotation with the supplied parameter
    // The animation listener is used to trigger the next animation
    final Rotate3dAnimation rotation = new Rotate3dAnimation(start, end, centerX, centerY, 0, false);
    rotation.setDuration(500);// w  w w. j  av  a  2 s.co m
    rotation.setFillAfter(true);
    rotation.setInterpolator(new AccelerateInterpolator());
    rotation.setAnimationListener(new DisplayNextView(isFirstImage, startupImage, advertisingImage));

    if (isFirstImage) {
        startupImage.startAnimation(rotation);
    } else {
        advertisingImage.startAnimation(rotation);
    }
}

From source file:com.tmall.wireless.tangram.ext.SwipeItemTouchListener.java

private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge,
        final int direction) {
    int contentWidth = recyclerView.getWidth();
    AnimatorSet animatorSet = new AnimatorSet();
    List<Animator> list = new ArrayList<>();
    String translation = "translationX";
    if (swipingType == SWIPING_VER) {
        translation = "translationY";
    }/*from w  w w.ja va2  s.  c o m*/
    for (View view : mChildList) {
        ObjectAnimator animator;
        if (reachActionEdge) {
            animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction)
                    .setDuration(ANIMATE_DURATION);
            animator.setInterpolator(new AccelerateInterpolator());
        } else {
            animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION);
            animator.setInterpolator(new DecelerateInterpolator());
        }
        list.add(animator);
    }
    animatorSet.playTogether(list);
    animatorSet.addListener(new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (swipingType == SWIPING_HOR && reachActionEdge) {
                if (mSwipeCardRef != null && mSwipeCardRef.get() != null) {
                    SwipeCard swipeCard = mSwipeCardRef.get();
                    swipeCard.switchTo(swipeCard.getCurrentIndex() - direction);
                }
            }
            mChildList.clear();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    });
    animatorSet.start();

    if (swipingType == SWIPING_VER) {
        if (pullFromEndListener != null) {
            if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) {
                pullFromEndListener.onAction();
            } else {
                pullFromEndListener.onReset();
            }
        }
    }

    swipeType = SWIPING_NONE;
}

From source file:com.google.android.apps.forscience.whistlepunk.intro.TutorialActivity.java

private void finishTutorial() {
    // Need to mark ourselves as done and finish.
    SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
    preferences.edit().putInt(KEY_TUTORIAL_VERSION_SEEN, TUTORIAL_VERSION).apply();

    ImageView view = (ImageView) findViewById(R.id.logo);
    view.animate().scaleXBy(3).scaleYBy(3).alpha(.1f).setDuration(500).setStartDelay(50)
            .setInterpolator(new AccelerateInterpolator()).setListener(new Animator.AnimatorListener() {
                @Override/*from www  .  j a va 2  s  .c  o m*/
                public void onAnimationStart(Animator animation) {
                }

                @Override
                public void onAnimationEnd(Animator animation) {
                    launchOrFinish();
                }

                @Override
                public void onAnimationCancel(Animator animation) {
                }

                @Override
                public void onAnimationRepeat(Animator animation) {
                }
            }).start();
}

From source file:com.echo.holographlibrarysample.BarFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View v = inflater.inflate(R.layout.fragment_bargraph, container, false);
    final Resources resources = getResources();
    ArrayList<Bar> aBars = new ArrayList<Bar>();
    Bar bar = new Bar();
    bar.setColor(resources.getColor(R.color.green_light));
    bar.setSelectedColor(resources.getColor(R.color.transparent_orange));
    bar.setName("Test1");
    bar.setValue(1000);// ww w  .j  a  v a 2s  . c  o m
    bar.setValueString("$1,000");
    aBars.add(bar);
    bar = new Bar();
    bar.setColor(resources.getColor(R.color.orange));
    bar.setName("Test2");
    bar.setValue(2000);
    bar.setValueString("$2,000");
    aBars.add(bar);
    bar = new Bar();
    bar.setColor(resources.getColor(R.color.purple));
    bar.setName("Test3");
    bar.setValue(1500);
    bar.setValueString("$1,500");
    aBars.add(bar);

    final BarGraph barGraph = (BarGraph) v.findViewById(R.id.bargraph);
    bg = barGraph;
    barGraph.setBars(aBars);

    barGraph.setOnBarClickedListener(new OnBarClickedListener() {

        @Override
        public void onClick(int index) {
            Toast.makeText(getActivity(),
                    "Bar " + index + " clicked " + String.valueOf(barGraph.getBars().get(index).getValue()),
                    Toast.LENGTH_SHORT).show();
        }
    });
    Button animateBarButton = (Button) v.findViewById(R.id.animateBarButton);
    Button animateInsertBarButton = (Button) v.findViewById(R.id.animateInsertBarButton);
    Button animateDelteBarButton = (Button) v.findViewById(R.id.animateDeleteBarButton);

    //animate to random values
    animateBarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            for (Bar b : barGraph.getBars()) {
                b.setGoalValue((float) Math.random() * 1000);
                b.setValuePrefix("$");//display the prefix throughout the animation
                Log.d("goal val", String.valueOf(b.getGoalValue()));
            }
            barGraph.setDuration(1200);//default if unspecified is 300 ms
            barGraph.setInterpolator(new AccelerateDecelerateInterpolator());//Only use over/undershoot  when not inserting/deleting
            barGraph.setAnimationListener(getAnimationListener());
            barGraph.animateToGoalValues();

        }
    });

    //insert a bar
    animateInsertBarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            barGraph.cancelAnimating(); //must clear existing to call onAnimationEndListener cleanup BEFORE adding new bars
            int newPosition = barGraph.getBars().size() == 0 ? 0
                    : new Random().nextInt(barGraph.getBars().size());
            Bar bar = new Bar();
            bar.setColor(Color.parseColor("#AA0000FF"));
            bar.setName("Insert bar " + String.valueOf(barGraph.getBars().size()));
            bar.setValue(0);
            bar.mAnimateSpecial = HoloGraphAnimate.ANIMATE_INSERT;
            barGraph.getBars().add(newPosition, bar);
            for (Bar b : barGraph.getBars()) {
                b.setGoalValue((float) Math.random() * 1000);
                b.setValuePrefix("$");//display the prefix throughout the animation
                Log.d("goal val", String.valueOf(b.getGoalValue()));
            }
            barGraph.setDuration(1200);//default if unspecified is 300 ms
            barGraph.setInterpolator(new AccelerateDecelerateInterpolator());//Don't use over/undershoot interpolator for insert/delete
            barGraph.setAnimationListener(getAnimationListener());
            barGraph.animateToGoalValues();

        }
    });

    //delete a bar
    animateDelteBarButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            barGraph.cancelAnimating(); //must clear existing to call onAnimationEndListener cleanup BEFORE adding new bars
            if (barGraph.getBars().size() == 0)
                return;

            for (Bar b : barGraph.getBars()) {
                b.setGoalValue((float) Math.random() * 1000);
                b.setValuePrefix("$");//display the prefix throughout the animation
                Log.d("goal val", String.valueOf(b.getGoalValue()));
            }
            int newPosition = new Random().nextInt(barGraph.getBars().size());
            Bar bar = barGraph.getBars().get(newPosition);
            bar.mAnimateSpecial = HoloGraphAnimate.ANIMATE_DELETE;
            bar.setGoalValue(0);//animate to 0 then delete
            barGraph.setDuration(1200);//default if unspecified is 300 ms
            barGraph.setInterpolator(new AccelerateInterpolator());//Don't use over/undershoot interpolator for insert/delete
            barGraph.setAnimationListener(getAnimationListener());
            barGraph.animateToGoalValues();

        }
    });
    return v;
}

From source file:com.ruesga.rview.widget.MergedStatusChart.java

public void update(List<Stats> stats) {
    int total = 0, open = 0, merged = 0, abandoned = 0;
    for (Stats s : stats) {
        if (s.mStatus.equals(ChangeStatus.NEW)) {
            open++;/*from w w w  .j a  v a 2s  . c om*/
        } else if (s.mStatus.equals(ChangeStatus.MERGED)) {
            merged++;
        } else if (s.mStatus.equals(ChangeStatus.ABANDONED)) {
            abandoned++;
        }
        total++;
    }
    synchronized (mLock) {
        mOpen = open;
        mMerged = merged;
        mAbandoned = abandoned;
        mTotal = total;
        computeDrawObjects();
    }

    // Animate the chart
    if (mAnimator != null && mAnimator.isRunning()) {
        mAnimator.cancel();
    }
    mAnimationDelta = 0f;
    mAnimator = ValueAnimator.ofFloat(0f, 1f);
    mAnimator.setInterpolator(new AccelerateInterpolator());
    mAnimator.setDuration(350L);
    mAnimator.addUpdateListener(animation -> {
        mAnimationDelta = animation.getAnimatedFraction();
        ViewCompat.postInvalidateOnAnimation(this);
    });
    mAnimator.start();
}

From source file:com.tmall.wireless.tangram3.ext.SwipeItemTouchListener.java

private void resetViews(RecyclerView recyclerView, final int swipingType, final boolean reachActionEdge,
        final int direction) {
    if (enableAnim) {
        int contentWidth = recyclerView.getWidth();
        AnimatorSet animatorSet = new AnimatorSet();
        List<Animator> list = new ArrayList<>();
        String translation = "translationX";
        if (swipingType == SWIPING_VER) {
            translation = "translationY";
        }//from  w w  w .  j  ava2  s .  c  om
        for (View view : mChildList) {
            ObjectAnimator animator;
            if (reachActionEdge) {
                animator = ObjectAnimator.ofFloat(view, translation, contentWidth * direction)
                        .setDuration(ANIMATE_DURATION);
                animator.setInterpolator(new AccelerateInterpolator());
            } else {
                animator = ObjectAnimator.ofFloat(view, translation, 0).setDuration(ANIMATE_DURATION);
                animator.setInterpolator(new DecelerateInterpolator());
            }
            list.add(animator);
        }
        animatorSet.playTogether(list);
        animatorSet.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animation) {

            }

            @Override
            public void onAnimationEnd(Animator animation) {
                if (swipingType == SWIPING_HOR && reachActionEdge) {
                    if (mSwipeCardRef != null && mSwipeCardRef.get() != null) {
                        SwipeCard swipeCard = mSwipeCardRef.get();
                        swipeCard.switchTo(swipeCard.getCurrentIndex() - direction);
                    }
                }
                mChildList.clear();
            }

            @Override
            public void onAnimationCancel(Animator animation) {

            }

            @Override
            public void onAnimationRepeat(Animator animation) {

            }
        });
        animatorSet.start();
    } else {
        if (swipingType == SWIPING_HOR && reachActionEdge) {
            if (mSwipeCardRef != null && mSwipeCardRef.get() != null) {
                SwipeCard swipeCard = mSwipeCardRef.get();
                swipeCard.switchTo(swipeCard.getCurrentIndex() - direction);
            }
        }
        mChildList.clear();
    }

    if (swipingType == SWIPING_VER) {
        if (pullFromEndListener != null) {
            if (mDistanceY < 0 && (mDistanceY < -pullFromEndListener.getPullEdge())) {
                pullFromEndListener.onAction();
            } else {
                pullFromEndListener.onReset();
            }
        }
    }

    swipeType = SWIPING_NONE;
}

From source file:ly.apps.android.rest.client.example.activities.MainActivity.java

private void animateContent() {

    ViewHelper.setRotation(imageViewIcon, 20);
    ViewHelper.setTranslationY(imageViewIcon, -100);
    ViewHelper.setTranslationX(textViewCity, 100);
    ViewHelper.setAlpha(linearLayoutContent, 0);
    ViewHelper.setTranslationY(descriptionTempContent, 200);
    ViewHelper.setTranslationY(contentBottom, 200);

    animate(imageViewIcon).setDuration(300).setInterpolator(new AccelerateInterpolator()).translationY(0)
            .setListener(new Animator.AnimatorListener() {
                @Override/*  ww w.j av a  2  s. c o m*/
                public void onAnimationStart(Animator animator) {

                }

                @Override
                public void onAnimationEnd(Animator animator) {
                    iconFall(imageViewIcon, 10);
                }

                @Override
                public void onAnimationCancel(Animator animator) {

                }

                @Override
                public void onAnimationRepeat(Animator animator) {

                }
            }).start();

    animate(textViewCity).setDuration(1000).setInterpolator(new AccelerateDecelerateInterpolator())
            .translationX(0).start();

    animate(linearLayoutContent).setDuration(1000).alpha(1).start();

    animate(contentBottom).setDuration(1000).translationY(0).start();

    animate(descriptionTempContent).setDuration(1000).translationY(0).start();
}

From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java

public BufferTextInputLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    ThemeUtils.checkAppCompatTheme(context);
    setOrientation(VERTICAL);/*  w  w w  .j a  v a2 s .co m*/
    setWillNotDraw(false);
    setAddStatesFromChildren(true);
    inputFrame = new FrameLayout(context);
    inputFrame.setAddStatesFromChildren(true);
    addView(inputFrame);
    collapsingTextHelper.setTextSizeInterpolator(AnimationUtils.FAST_OUT_SLOW_IN_INTERPOLATOR);
    collapsingTextHelper.setPositionInterpolator(new AccelerateInterpolator());
    collapsingTextHelper.setCollapsedTextGravity(Gravity.TOP | GravityCompat.START);
    isHintExpanded = collapsingTextHelper.getExpansionFraction() == 1f;
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs,
            R.styleable.BufferTextInputLayout, defStyleAttr, R.style.BufferTextInputLayout);
    isHintEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_hintEnabled, true);
    setHint(a.getText(R.styleable.BufferTextInputLayout_android_hint));
    hintAnimationEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_hintAnimationEnabled, true);
    if (a.hasValue(R.styleable.BufferTextInputLayout_android_textColorHint)) {
        defaultTextColor = focusedTextColor = a
                .getColorStateList(R.styleable.BufferTextInputLayout_android_textColorHint);
    }
    final int hintAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_hintTextAppearance, -1);
    if (hintAppearance != -1) {
        setHintTextAppearance(a.getResourceId(R.styleable.BufferTextInputLayout_hintTextAppearance, 0));
    }
    errorTextAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_errorTextAppearance, 0);
    final boolean errorEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_errorEnabled, false);
    final boolean counterEnabled = a.getBoolean(R.styleable.BufferTextInputLayout_counterEnabled, false);
    setCounterMaxLength(a.getInt(R.styleable.BufferTextInputLayout_counterMaxLength, INVALID_MAX_LENGTH));
    counterTextAppearance = a.getResourceId(R.styleable.BufferTextInputLayout_counterTextAppearance, 0);
    counterOverflowTextAppearance = a
            .getResourceId(R.styleable.BufferTextInputLayout_counterOverflowTextAppearance, 0);
    counterVisible = counterEnabled;

    counterMode = CounterMode.fromId(a.getInt(R.styleable.BufferTextInputLayout_counterMode, 2));

    charactersRemainingUntilCounterDisplay = a.getInt(R.styleable.BufferTextInputLayout_displayFromCount,
            getCounterMaxLength());

    a.recycle();
    setErrorEnabled(errorEnabled);
    setCounterEnabled(counterEnabled);
    setCounterVisible(counterVisible && (charactersRemainingUntilCounterDisplay == getCounterMaxLength()));
    applyPasswordToggleTint();
    if (ViewCompat.getImportantForAccessibility(this) == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO) {
        // Make sure we're important for accessibility if we haven't been explicitly not
        ViewCompat.setImportantForAccessibility(this, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_YES);
    }
    ViewCompat.setAccessibilityDelegate(this, new TextInputAccessibilityDelegate());
}

From source file:com.fabernovel.alertevoirie.HomeActivity.java

@Override
public void onRequestcompleted(int requestCode, Object result) {
    try {/*from  www  .  ja  va 2 s  .  co  m*/
        JSONArray responses;
        //Log.d(Constants.PROJECT_TAG, (String) result);
        responses = new JSONArray((String) result);

        JSONObject response = responses.getJSONObject(0);

        final AnimationSet set = new AnimationSet(false);

        final float centerX = findViewById(R.id.LinearLayout02).getWidth() / 2;
        final float centerY = findViewById(R.id.LinearLayout02).getHeight() / 2;
        final Flip3dAnimation animation = new Flip3dAnimation(0, 360, centerX, centerY);
        animation.setDuration(500);
        set.setFillAfter(true);
        set.setFillBefore(true);
        animation.setInterpolator(new AccelerateInterpolator());

        set.addAnimation(animation);

        if (requestCode == AVService.REQUEST_JSON) {
            if (JsonData.VALUE_REQUEST_GET_INCIDENTS_STATS.equals(response.getString(JsonData.PARAM_REQUEST))) {
                Last_Location.Incidents = response.getJSONObject(JsonData.PARAM_ANSWER);
                int resolved_incidents = response.getJSONObject(JsonData.PARAM_ANSWER)
                        .getInt(JsonData.PARAM_RESOLVED_INCIDENTS);
                int ongoing_incidents = response.getJSONObject(JsonData.PARAM_ANSWER)
                        .getInt(JsonData.PARAM_ONGOING_INCIDENTS);
                int updated_incidents = response.getJSONObject(JsonData.PARAM_ANSWER)
                        .getInt(JsonData.PARAM_UPDATED_INCIDENTS);

                ((TextView) findViewById(R.id.Home_TextView_Solved)).setText(getResources().getQuantityString(
                        R.plurals.home_label_solved, resolved_incidents, resolved_incidents));
                ((TextView) findViewById(R.id.Home_TextView_Current)).setText(getResources()
                        .getQuantityString(R.plurals.home_label_current, ongoing_incidents, ongoing_incidents));
                ((TextView) findViewById(R.id.Home_TextView_Update)).setText(getResources()
                        .getQuantityString(R.plurals.home_label_update, updated_incidents, updated_incidents));
            }
        }

        findViewById(R.id.LinearLayout02).startAnimation(set);
        findViewById(R.id.LinearLayout04).startAnimation(set);
        findViewById(R.id.LinearLayout03).startAnimation(set);
    } catch (JSONException e) {
        Log.e(Constants.PROJECT_TAG, "JSONException", e);
    } catch (ClassCastException e) {
        Log.e(Constants.PROJECT_TAG, "Invalid result. Trying to cast " + result.getClass() + "into String", e);
    } finally {
        if (hidedialog)
            dismissDialog(DIALOG_PROGRESS);
        dialog_shown = false;
    }
}

From source file:acr.browser.lightning.browser.fragment.anim.HorizontalItemAnimator.java

private void animateRemoveImpl(final ViewHolder holder) {
    final View view = holder.itemView;
    final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view);
    mRemoveAnimations.add(holder);// w  ww . j a v a  2 s  .c o  m
    animation.setDuration(getRemoveDuration()).alpha(0).translationY(holder.itemView.getHeight())
            .setInterpolator(new AccelerateInterpolator()).setListener(new VpaListenerAdapter() {
                @Override
                public void onAnimationStart(View view) {
                    dispatchRemoveStarting(holder);
                }

                @Override
                public void onAnimationEnd(View view) {
                    animation.setListener(null);
                    ViewCompat.setAlpha(view, 1);
                    ViewCompat.setTranslationY(view, 0);
                    dispatchRemoveFinished(holder);
                    mRemoveAnimations.remove(holder);
                    dispatchFinishedWhenDone();
                }
            }).start();
}