Example usage for android.view.animation DecelerateInterpolator DecelerateInterpolator

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

Introduction

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

Prototype

public DecelerateInterpolator() 

Source Link

Usage

From source file:ca.zadrox.dota2esportticker.ui.MatchDetailActivity.java

private void updateContentFromGG(Match data) {

    if (data == null) {
        Toast.makeText(this, "Network Connection issues", Toast.LENGTH_SHORT).show();
        return;/*w  w  w  . j  ava  2 s. c o  m*/
    }

    if (Long.parseLong(dateTime) < TimeUtils.getUTCTime()) {
        mMatchScoreView.setText(data.teamOne.score + " : " + data.teamTwo.score);
    } else {
        mMatchScoreView.setText(" vs ");
    }

    if (data.livestreams != null && data.livestreams.length != 0) {
        final ViewGroup livestreamsCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_livestream,
                mDetailsContainer, false);
        final ViewGroup livestreamsBlock = (ViewGroup) livestreamsCard
                .findViewById(R.id.card_livestreams_block);
        for (int i = 0; i < data.livestreams.length; i++) {
            if (data.livestreams[i].url == null) {
                continue;
            }
            final View livestreamItem = getLayoutInflater().inflate(R.layout.livestream_detail,
                    livestreamsBlock, false);
            final TextView livestreamNameView = (TextView) livestreamItem
                    .findViewById(R.id.livestream_name_view);
            final TextView livestreamServiceView = (TextView) livestreamItem
                    .findViewById(R.id.livestream_service_view);

            final Uri livestreamUri = Uri.parse(data.livestreams[i].url);

            livestreamNameView
                    .setText(data.livestreams[i].language.toUpperCase() + " - " + data.livestreams[i].title);
            livestreamServiceView
                    .setText(data.livestreams[i].url.contains("twitch.tv") ? "Twitch.tv" : "DailyMotion");

            livestreamItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent viewLivestreamIntent = new Intent(Intent.ACTION_VIEW, livestreamUri);
                    startActivity(viewLivestreamIntent);
                }
            });

            livestreamsBlock.addView(livestreamItem);

            final View divider = getLayoutInflater().inflate(R.layout.divider, livestreamsBlock, false);
            livestreamsBlock.addView(divider);
        }

        mDetailsContainer.addView(livestreamsCard, 1);

    }

    if (data.vods != null && data.vods.length != 0) {
        final ViewGroup vodsCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_vods,
                mDetailsContainer, false);
        final ViewGroup vodsBlock = (ViewGroup) vodsCard.findViewById(R.id.card_vods_block);
        for (int i = 0; i < data.vods.length; i++) {
            final TextView vodsItem = (TextView) getLayoutInflater().inflate(R.layout.vod_detail, vodsBlock,
                    false);

            vodsItem.setText(data.vods[i].vodDesc);

            final Uri vodUri = Uri.parse(data.vods[i].vodUrl);

            vodsItem.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent viewVodIntent = new Intent(Intent.ACTION_VIEW, vodUri);
                    startActivity(viewVodIntent);
                }
            });

            vodsBlock.addView(vodsItem);

            final View divider = getLayoutInflater().inflate(R.layout.divider, vodsBlock, false);
            vodsBlock.addView(divider);
        }

        mDetailsContainer.addView(vodsCard, 2);

    }

    data.teamOne.flagUrl = teamLeftFlagUrl;
    data.teamTwo.flagUrl = teamRightFlagUrl;
    data.teamOne.name = teamLeftName;
    data.teamTwo.name = teamRightName;

    mTeamCardOne = makeTeamView(data.teamOne, mDetailsContainer);
    mTeamCardTwo = makeTeamView(data.teamTwo, mDetailsContainer);

    mDetailsContainer.addView(mTeamCardOne);
    mDetailsContainer.addView(mTeamCardTwo);

    mMatchTeamOneImageView.setClickable(true);
    mMatchTeamTwoImageView.setClickable(true);

    mMatchTeamOneImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mScrollView.smoothScrollTo(0,
                    Math.round(mTeamCardOne.getY() + mTeamCardOne.getHeight() - mHeaderHeightPixels));
        }
    });

    mMatchTeamTwoImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mScrollView.smoothScrollTo(0,
                    Math.round(mTeamCardTwo.getY() + mTeamCardTwo.getHeight() - mHeaderHeightPixels));
        }
    });

    final ViewGroup extrasCard = (ViewGroup) getLayoutInflater().inflate(R.layout.card_links, mDetailsContainer,
            false);

    final ViewGroup extrasBlock = (ViewGroup) extrasCard.findViewById(R.id.card_links_block);

    final TextView extrasItem = (TextView) getLayoutInflater().inflate(R.layout.link_item, extrasBlock, false);

    extrasItem.setText("GosuGamers Match Page");

    extrasItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent viewGGNetMatchPage = new Intent(Intent.ACTION_VIEW, Uri.parse(mUrl));
            startActivity(viewGGNetMatchPage);
        }
    });

    extrasBlock.addView(extrasItem);

    mDetailsContainer.addView(extrasCard);

    mMatchViewContainer.setBackground(null);
    //getWindow().setBackgroundDrawable(null);

    mDetailsContainer.animate().translationY(0).setDuration(350).setInterpolator(new DecelerateInterpolator())
            .start();

}

From source file:com.goka.flickableview.ImageViewTouchBase.java

protected void scrollBy(final float distanceX, final float distanceY, final long durationMs) {
    ValueAnimatorCompat animatorCompat = AnimatorCompatHelper.emptyValueAnimator();
    animatorCompat.setDuration(durationMs);

    stopAllAnimations();// w  ww. j  a  v a  2s .c o m

    mCurrentAnimation = animatorCompat;
    mCurrentAnimation.start();

    final Interpolator interpolator = new DecelerateInterpolator();
    animatorCompat.addUpdateListener(new AnimatorUpdateListenerCompat() {
        float oldValueX = 0;

        float oldValueY = 0;

        @Override
        public void onAnimationUpdate(ValueAnimatorCompat animation) {
            float fraction = interpolator.getInterpolation(animation.getAnimatedFraction());
            float valueX = fraction * distanceX;
            float valueY = fraction * distanceY;
            panBy(valueX - oldValueX, valueY - oldValueY);

            oldValueX = valueX;
            oldValueY = valueY;
        }
    });

    mCurrentAnimation.addListener(new AnimatorListenerCompat() {
        @Override
        public void onAnimationStart(ValueAnimatorCompat animation) {

        }

        @Override
        public void onAnimationEnd(ValueAnimatorCompat animation) {
            RectF centerRect = getCenter(mSuppMatrix, true, true);
            if (centerRect.left != 0 || centerRect.top != 0) {
                scrollBy(centerRect.left, centerRect.top);
            }
        }

        @Override
        public void onAnimationCancel(ValueAnimatorCompat animation) {

        }

        @Override
        public void onAnimationRepeat(ValueAnimatorCompat animation) {

        }
    });

}

From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java

private void initRotateNotification(int orientation) {
    if (rotatorLayout != null && showLandscapeNotification) {
        if (!isRecording && (orientation == 90 || orientation == 270)) {
            try {
                int height = (int) ApplicationScreen.getAppResources().getDimension(R.dimen.gui_element_2size);
                Animation rotation = new RotateAnimation(0, -180, height / 2, height / 2);
                rotation.setDuration(2000);
                rotation.setRepeatCount(1000);
                rotation.setInterpolator(new DecelerateInterpolator());

                rotatorLayout.findViewById(R.id.rotatorImageView).startAnimation(rotation);
                rotatorLayout.findViewById(R.id.rotatorImageView).setVisibility(View.VISIBLE);
                rotatorLayout.findViewById(R.id.rotatorInnerImageView).setVisibility(View.VISIBLE);
            } catch (Exception e) {
                e.printStackTrace();/*from  www  .  j  a v  a 2 s .com*/
            }
        } else {
            rotatorLayout.findViewById(R.id.rotatorInnerImageView).setVisibility(View.GONE);
            rotatorLayout.findViewById(R.id.rotatorImageView).setVisibility(View.GONE);
            rotatorLayout.findViewById(R.id.rotatorImageView).clearAnimation();
        }
    } else
        //if we started video but orientation change already fired. Save and set orientation on rotator layout creation
        videoOrientation = orientation;
}

From source file:lewa.support.v7.internal.widget.ActionBarContextView.java

private ViewPropertyAnimatorCompatSet makeInAnimation() {
    ViewCompat.setTranslationX(mClose,//from w w  w .  j  a v a2  s. c om
            -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose).translationX(0);
    buttonAnimator.setDuration(200);
    buttonAnimator.setListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());

    ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
    set.play(buttonAnimator);

    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = count - 1, j = 0; i >= 0; i--, j++) {
                View child = mMenuView.getChildAt(i);
                ViewCompat.setScaleY(child, 0);
                ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(1);
                a.setDuration(300);
                set.play(a);
            }
        }
    }

    ///LEWA  BEGIN
    ViewPropertyAnimatorCompat rightBbuttonAnimator = makeRightButtonInAnimation();
    if (rightBbuttonAnimator != null) {
        set.play(rightBbuttonAnimator);
    }
    ///LEWA  END
    return set;
}

From source file:lewa.support.v7.internal.widget.ActionBarContextView.java

private ViewPropertyAnimatorCompatSet makeOutAnimation() {
    ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose)
            .translationX(-mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin);
    buttonAnimator.setDuration(200);/*from  www.j a  v a 2  s . c  om*/
    buttonAnimator.setListener(this);
    buttonAnimator.setInterpolator(new DecelerateInterpolator());

    ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet();
    set.play(buttonAnimator);

    if (mMenuView != null) {
        final int count = mMenuView.getChildCount();
        if (count > 0) {
            for (int i = 0; i < 0; i++) {
                View child = mMenuView.getChildAt(i);
                ViewCompat.setScaleY(child, 1);
                ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(0);
                a.setDuration(300);
                set.play(a);
            }
        }
    }
    ///LEWA BEGIN
    ViewPropertyAnimatorCompat rightBbuttonAnimator = makeRightButtonOutAnimation();
    if (rightBbuttonAnimator != null) {
        set.play(rightBbuttonAnimator);
    }
    ///LEWA END

    return set;
}

From source file:com.b44t.ui.ActionBar.BottomSheet.java

private void startOpenAnimation() {
    containerView.setVisibility(View.VISIBLE);

    if (!onCustomOpenAnimation()) {
        if (Build.VERSION.SDK_INT >= 20) {
            container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }//from  ww w .ja  v a 2 s  .c  o  m
        containerView.setTranslationY(containerView.getMeasuredHeight());
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0),
                ObjectAnimator.ofInt(backDrawable, "alpha", 51));
        animatorSet.setDuration(200);
        animatorSet.setStartDelay(20);
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                    if (delegate != null) {
                        delegate.onOpenAnimationEnd();
                    }
                    container.setLayerType(View.LAYER_TYPE_NONE, null);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                }
            }
        });
        animatorSet.start();
        currentSheetAnimation = animatorSet;
    }
}

From source file:kr.wdream.ui.ActionBar.BottomSheet.java

private void startOpenAnimation() {
    if (dismissed) {
        return;/*from w w  w .j av a  2s.com*/
    }
    containerView.setVisibility(View.VISIBLE);

    if (!onCustomOpenAnimation()) {
        if (Build.VERSION.SDK_INT >= 20) {
            container.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        }
        containerView.setTranslationY(containerView.getMeasuredHeight());
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(ObjectAnimator.ofFloat(containerView, "translationY", 0),
                ObjectAnimator.ofInt(backDrawable, "alpha", 51));
        animatorSet.setDuration(200);
        animatorSet.setStartDelay(20);
        animatorSet.setInterpolator(new DecelerateInterpolator());
        animatorSet.addListener(new AnimatorListenerAdapterProxy() {
            @Override
            public void onAnimationEnd(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                    if (delegate != null) {
                        delegate.onOpenAnimationEnd();
                    }
                    container.setLayerType(View.LAYER_TYPE_NONE, null);
                }
            }

            @Override
            public void onAnimationCancel(Animator animation) {
                if (currentSheetAnimation != null && currentSheetAnimation.equals(animation)) {
                    currentSheetAnimation = null;
                }
            }
        });
        animatorSet.start();
        currentSheetAnimation = animatorSet;
    }
}

From source file:com.klinker.android.sliding.MultiShrinkScroller.java

/**
 * Scroll the activity up as the entrace animation.
 * @param scrollToCurrentPosition if true, will scroll from the bottom of the screen to the
 * current position. Otherwise, will scroll from the bottom of the screen to the top of the
 * screen.//from  ww  w. j  a  v  a  2 s . co m
 */
public void performEntranceAnimation(OpenAnimation animation, boolean scrollToCurrentPosition) {
    final int currentPosition = getScroll();
    final int bottomScrollPosition = currentPosition - (getHeight() - getTransparentViewHeight()) + 1;

    final int desiredValue = currentPosition
            + (scrollToCurrentPosition ? currentPosition : getTransparentViewHeight());

    if (animation == OpenAnimation.EXPAND_FROM_VIEW) {
        scrollTo(0, desiredValue);
        runExpansionAnimation();

        openAnimation = animation;
    } else {
        final Interpolator interpolator;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            interpolator = AnimationUtils.loadInterpolator(getContext(),
                    android.R.interpolator.linear_out_slow_in);
        } else {
            interpolator = new DecelerateInterpolator();
        }

        final ObjectAnimator animator = ObjectAnimator.ofInt(this, "scroll", bottomScrollPosition,
                desiredValue);
        animator.setInterpolator(interpolator);
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                if (animation.getAnimatedValue().equals(desiredValue) && listener != null) {
                    listener.onEntranceAnimationDone();
                }
            }
        });

        animator.start();
    }

}

From source file:nl.thehyve.transmartclient.MainActivity.java

private void animateToArrow(boolean toArrow) {
    int start, stop;
    if (toArrow) {
        start = 0;/*from www . j  a  v  a  2s .  c om*/
        stop = 1;
    } else {
        start = 1;
        stop = 0;
    }
    ValueAnimator anim = ValueAnimator.ofFloat(start, stop);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float slideOffset = (Float) valueAnimator.getAnimatedValue();
            toggle.onDrawerSlide(drawer, slideOffset);
        }
    });
    anim.setInterpolator(new DecelerateInterpolator());
    anim.setDuration(300);
    anim.start();
}

From source file:com.klinker.android.sliding.MultiShrinkScroller.java

public void runExpansionAnimation() {

    final Interpolator interpolator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in);
    } else {/*from   ww  w . ja v a  2 s. c  om*/
        interpolator = new DecelerateInterpolator();
    }

    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenHeight = size.y;
    int screenWidth = size.x;

    final ValueAnimator heightExpansion = ValueAnimator.ofInt(expansionViewHeight, getHeight());
    heightExpansion.setInterpolator(interpolator);
    heightExpansion.setDuration(ANIMATION_DURATION);
    heightExpansion.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int val = (int) animation.getAnimatedValue();

            ViewGroup.LayoutParams params = getLayoutParams();
            params.height = val;
            setLayoutParams(params);
        }
    });
    heightExpansion.start();

    final ValueAnimator widthExpansion = ValueAnimator.ofInt(expansionViewWidth, getWidth());
    widthExpansion.setInterpolator(interpolator);
    widthExpansion.setDuration(ANIMATION_DURATION);
    widthExpansion.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int val = (int) animation.getAnimatedValue();

            ViewGroup.LayoutParams params = getLayoutParams();
            params.width = val;
            setLayoutParams(params);
        }
    });
    widthExpansion.start();

    ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, expansionLeftOffset, 0f);
    translationX.setInterpolator(interpolator);
    translationX.setDuration(ANIMATION_DURATION);
    translationX.start();

    ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, expansionTopOffset, 0f);
    translationY.setInterpolator(interpolator);
    translationY.setDuration(ANIMATION_DURATION);
    translationY.start();
}