Example usage for android.animation ValueAnimator start

List of usage examples for android.animation ValueAnimator start

Introduction

In this page you can find the example usage for android.animation ValueAnimator start.

Prototype

@Override
    public void start() 

Source Link

Usage

From source file:com.nshmura.recyclertablayout.RecyclerTabLayout.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
protected void startAnimation(final int position) {

    float distance = 1;

    View view = mLinearLayoutManager.findViewByPosition(position);
    if (view != null) {
        float currentX = view.getX() + view.getMeasuredWidth() / 2.f;
        float centerX = getMeasuredWidth() / 2.f;
        distance = Math.abs(centerX - currentX) / view.getMeasuredWidth();
    }//from  w w w. ja  v  a2  s.co m

    ValueAnimator animator;
    if (position < mIndicatorPosition) {
        animator = ValueAnimator.ofFloat(distance, 0);
    } else {
        animator = ValueAnimator.ofFloat(-distance, 0);
    }
    animator.setDuration(DEFAULT_SCROLL_DURATION);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            scrollToTab(position, (float) animation.getAnimatedValue(), true);
        }
    });
    animator.start();
}

From source file:com.github.shareme.gwsswwipetodismiss.library.SwipeDismissTouchListener.java

private void performDismiss() {
    // Animate the dismissed view to zero-height and then fire the dismiss
    // callback.//www . j  a va  2  s .  co m
    // This triggers layout on each animation frame; in the future we may
    // want to do something
    // smarter and more performant.

    final ViewGroup.LayoutParams lp = mView.getLayoutParams();
    final int originalHeight = mView.getHeight();

    ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mCallback.onDismiss(mView, mToken);
            // Reset view presentation
            setAlpha(mView, 1f);
            setTranslationX(mView, 0);
            lp.height = originalHeight;
            mView.setLayoutParams(lp);
        }
    });

    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            lp.height = (Integer) valueAnimator.getAnimatedValue();
            mView.setLayoutParams(lp);
        }
    });

    animator.start();
}

From source file:com.bitants.wally.fragments.ImageZoomFragment.java

private void animateIn(final Dialog dialog) {
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) zoomableImageView.getLayoutParams();
    params.width = rect.right;/*from ww  w .  java  2  s  .c  o  m*/
    params.height = rect.bottom;
    zoomableImageView.setLayoutParams(params);

    zoomableImageView.setX(rect.left);
    zoomableImageView.setY(rect.top - statusBarHeightCorrection);
    zoomableImageView.setAlpha(0.0f);
    zoomableImageView.setImageBitmap(bitmap);

    WindowManager win = getActivity().getWindowManager();
    Display d = win.getDefaultDisplay();
    int displayWidth = d.getWidth(); // Width of the actual device
    int displayHeight = d.getHeight() + statusBarHeightCorrection;

    ValueAnimator animWidth = ValueAnimator.ofInt(rect.right, displayWidth);
    animWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.width = val;
            zoomableImageView.setLayoutParams(layoutParams);
        }
    });
    animWidth.setDuration(500);
    animWidth.setInterpolator(new LinearOutSlowInInterpolator());
    animWidth.start();

    ValueAnimator animHeight = ValueAnimator.ofInt(rect.bottom, displayHeight);
    animHeight.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            int val = (Integer) valueAnimator.getAnimatedValue();
            ViewGroup.LayoutParams layoutParams = zoomableImageView.getLayoutParams();
            layoutParams.height = val;
            zoomableImageView.setLayoutParams(layoutParams);
        }
    });
    animHeight.setDuration(500);
    animHeight.setInterpolator(new LinearOutSlowInInterpolator());

    animHeight.start();

    if (statusBarHeightCorrection > 0) {
        zoomableImageView.animate().y(0.0f).setDuration(300).start();
    }

    ValueAnimator animDim = ValueAnimator.ofFloat(0.0f, 0.5f);
    animDim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
            layoutParams.copyFrom(dialog.getWindow().getAttributes());
            layoutParams.dimAmount = (Float) valueAnimator.getAnimatedValue();
            dialog.getWindow().setAttributes(layoutParams);
        }
    });
    animDim.setDuration(300);
    animDim.setStartDelay(300);
    animDim.start();
    zoomableImageView.animate().alpha(1.0f).setDuration(300).start();
}

From source file:com.jungle.toolbaractivity.layout.HorizontalSwipeBackLayout.java

private void continueAnimation(float horzOffset, int width) {
    ValueAnimator animator = ValueAnimator.ofFloat(horzOffset, width);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.setDuration((long) (150 * Math.abs(width - horzOffset) / width));
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override//  w  w  w . j  ava2 s.c o  m
        public void onAnimationUpdate(ValueAnimator animation) {
            float value = (float) animation.getAnimatedValue();
            updateSlideOffset(value);
        }
    });

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (mSlideListener != null) {
                mSlideListener.onSlideFinished();
            }
        }
    });

    animator.start();
}

From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java

private void animateScanMediaMessage() {
    TranslateAnimation anim = new TranslateAnimation(0, 0, -200, 0);
    anim.setDuration(900);//  w  w w .  j  a v  a 2 s  .  c  o m
    messageContainer.startAnimation(anim);

    messageContainer.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    ValueAnimator animator = ValueAnimator.ofInt(initialCourseListPadding,
            messageContainer.getMeasuredHeight());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        //@Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            courseList.setPadding(0, (Integer) valueAnimator.getAnimatedValue(), 0, 0);
            courseList.setSelectionAfterHeaderView();
        }
    });
    animator.setStartDelay(200);
    animator.setDuration(700);
    animator.start();
}

From source file:io.github.trulyfree.easyaspi.MainActivity.java

/**
 *
 *//*from   w w w.  ja  v  a  2s  .c o  m*/
private void resetConfigReturned() {
    final ImageView configResponseBlock = (ImageView) findViewById(R.id.block_module_returned);
    LinearLayout layout = (LinearLayout) findViewById(R.id.module_returned_config);
    EditText moduleName = (EditText) findViewById(R.id.module_returned_configname);
    EditText moduleVersion = (EditText) findViewById(R.id.module_returned_configversion);
    EditText moduleConfigUrl = (EditText) findViewById(R.id.module_returned_configurl);
    EditText moduleJarUrl = (EditText) findViewById(R.id.module_returned_jarurl);
    LinearLayout moduleDependencies = (LinearLayout) findViewById(R.id.module_returned_dependencies);
    Button validate = (Button) findViewById(R.id.module_returned_validate);
    Button cancel = (Button) findViewById(R.id.module_returned_cancel);
    moduleName.setText(R.string.module_returned_configname);
    moduleVersion.setText(R.string.module_returned_configversion);
    moduleConfigUrl.setText(R.string.module_returned_configurl);
    moduleJarUrl.setText(R.string.module_returned_jarurl);
    moduleDependencies.removeAllViewsInLayout();
    validate.setOnClickListener(null);
    cancel.setOnClickListener(null);
    final int colorFrom = ContextCompat.getColor(MainActivity.this, R.color.colorClear);
    final int colorTo = ContextCompat.getColor(MainActivity.this, R.color.colorFillingTint);
    ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(), colorFrom, colorTo);
    colorAnimation.setDuration(ANIMATION_DURATION);
    colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animator) {
            configResponseBlock.setBackgroundColor((Integer) animator.getAnimatedValue());
        }
    });
    layout.setClickable(false);
    configResponseBlock.setVisibility(View.VISIBLE);
    colorAnimation.start();
}

From source file:fr.julienvermet.bugdroid.ui.tablet.AbsBugsMultiPaneFragment.java

public void collapseLeftPane(int speed) {
    int targetWidth = mMinLeftWidth;
    ValueAnimator animator = ValueAnimator.ofObject(new WidthEvaluator(mLeftPane), mLeftPane.getWidth(),
            targetWidth);//from   w w w . j  a v  a 2 s.  co  m
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            mLeftName.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mLeftView.setVisibility(View.GONE);
            mIsLeftCollapsed = true;
        }
    });
    animator.setInterpolator(new DecelerateInterpolator());
    animator.setDuration(speed);
    animator.start();
}

From source file:com.rks.musicx.ui.fragments.PlayingViews.Playing1Fragment.java

@Override
protected void playingView() {
    if (getMusicXService() != null) {
        String title = getMusicXService().getsongTitle();
        String artist = getMusicXService().getsongArtistName();
        SongTitle.setText(title);/*from   w ww.j  a  va2  s . c o m*/
        SongTitle.setSelected(true);
        SongTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
        SongArtist.setText(artist);
        Helper.rotationAnim(playpausebutton);
        Helper.rotationAnim(mAlbumCoverView);
        mSeekBar.setOnSeekBarChangeListener(new CircularSeekBar.OnCircularSeekBarChangeListener() {
            @Override
            public void onProgressChanged(CircularSeekBar circularSeekBar, int progress, boolean fromUser) {
                if (fromUser && getMusicXService() != null
                        && (getMusicXService().isPlaying() || getMusicXService().isPaused())) {
                    getMusicXService().seekto(circularSeekBar.getProgress());
                }
            }

            @Override
            public void onStopTrackingTouch(CircularSeekBar seekBar) {
            }

            @Override
            public void onStartTrackingTouch(CircularSeekBar seekBar) {
            }
        });
        int duration = getMusicXService().getDuration();
        if (duration != -1) {
            mSeekBar.setMax(duration);
            TotalDur.setText(Helper.durationCalculator(duration));
        }
        LyricsHelper.LoadLyrics(getContext(), title, artist, getMusicXService().getsongAlbumName(),
                getMusicXService().getsongData(), lrcView);
        // NetworkHelper.absolutesLyrics(getContext(),artist, title, getMusicXService().getsongAlbumName(), getMusicXService().getsongData(), lrcView);
        updateQueuePos(getMusicXService().returnpos());
        bitmap = new bitmap() {
            @Override
            public void bitmapwork(Bitmap bitmap) {
                ArtworkUtils.blurPreferances(getContext(), bitmap, blur_artowrk);
                mAlbumCoverView.setImageBitmap(bitmap);
            }

            @Override
            public void bitmapfailed(Bitmap bitmap) {
                ArtworkUtils.blurPreferances(getContext(), bitmap, blur_artowrk);
                mAlbumCoverView.setImageBitmap(bitmap);
            }
        };
        palette = new palette() {
            @Override
            public void palettework(Palette palette) {
                final int[] colors = Helper.getAvailableColor(getContext(), palette);
                if (getActivity() == null || getActivity().getWindow() == null) {
                    return;
                }
                getActivity().getWindow().setStatusBarColor(colors[0]);
                getActivity().getWindow().setNavigationBarColor(colors[0]);
                ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
                        ((ColorDrawable) Playing3view.getBackground()).getColor(), colors[0]);
                colorAnimation.setDuration(250); // milliseconds
                colorAnimation.addUpdateListener(
                        animator -> Playing3view.setBackgroundColor((int) animator.getAnimatedValue()));
                colorAnimation.start();
                if (Extras.getInstance().artworkColor()) {
                    colorMode(colors[0]);
                } else {
                    colorMode(accentColor);
                }
            }
        };

    }
}

From source file:nuclei.ui.view.ButtonBarView.java

private void setSelected(final Item item, boolean selected) {
    if (mItems.length < 5)
        return;//from w w w .  j  ava 2 s.c o  m
    if (selected) {
        item.imageView.setColorFilter(mSelectedTint, PorterDuff.Mode.SRC_ATOP);
        if (item.textView != null) {
            item.textView.setTextColor(mSelectedTint);
            item.textView.setVisibility(View.VISIBLE);
            item.textView.setTextSize(0);
            ValueAnimator animator = mLabelAnimators.get(item);
            if (animator != null)
                animator.cancel();
            animator = new ValueAnimator();
            mLabelAnimators.put(item, animator);
            animator.setDuration(200);
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    int animatedValue = (Integer) valueAnimator.getAnimatedValue();
                    item.textView.setTextSize(animatedValue);
                }
            });
            animator.setIntValues(0, 14);
            animator.start();
        }
    } else {
        item.imageView.setColorFilter(mUnselectedTint, PorterDuff.Mode.SRC_ATOP);
        if (item.textView != null) {
            item.textView.setTextColor(mUnselectedTint);
            ValueAnimator animator = mLabelAnimators.get(item);
            if (animator != null)
                animator.cancel();
            animator = new ValueAnimator();
            mLabelAnimators.put(item, animator);
            animator.setDuration(200);
            animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator valueAnimator) {
                    int animatedValue = (Integer) valueAnimator.getAnimatedValue();
                    item.textView.setTextSize(animatedValue);
                    if (animatedValue == 0)
                        item.textView.setVisibility(View.GONE);
                }
            });
            animator.setIntValues(14, 0);
            animator.start();
        }
    }
}

From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java

public void onPictureClicked() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE && !fullscreen) {
        ValueAnimator animation = ValueAnimator.ofFloat(header.getAlpha(), 0f);
        animation.setDuration(500);//  www.j  a  v a2 s.com
        animation.addUpdateListener(new AnimationUpdateListener());
        animation.start();
        detailsLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_IMMERSIVE);
        ActionBar bar = getActionBar();
        if (bar != null)
            bar.hide();
        android.support.v7.app.ActionBar sbar = getSupportActionBar();
        if (sbar != null)
            sbar.hide();
        fullscreen = true;
    } else {
        ValueAnimator animation = ValueAnimator
                .ofFloat(header == null ? tvBahnhofName.getAlpha() : header.getAlpha(), 1.0f);
        animation.setDuration(500);
        animation.addUpdateListener(new AnimationUpdateListener());
        animation.start();
        detailsLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
        ActionBar bar = getActionBar();
        if (bar != null)
            bar.show();
        android.support.v7.app.ActionBar sbar = getSupportActionBar();
        if (sbar != null)
            sbar.show();
        fullscreen = false;
    }

}