List of usage examples for android.animation ObjectAnimator ofInt
public static <T> ObjectAnimator ofInt(T target, Property<T, Integer> xProperty, Property<T, Integer> yProperty, Path path)
Path
using two properties. From source file:com.mina.breathitout.AnalyzeActivity.java
public void animateProgressBar() { AnalyzeActivity.this.runOnUiThread(new Runnable() { @Override//from w ww . j ava 2s . c o m public void run() { if (android.os.Build.VERSION.SDK_INT >= 11) { // will update the "progress" propriety of seekbar until it reaches progress ObjectAnimator progressAnimation = ObjectAnimator.ofInt(progressBar, "progress", progressBar.getProgress(), lastMaxTime); progressAnimation.setDuration(1000); // 0.5 second progressAnimation.setInterpolator(new DecelerateInterpolator()); progressAnimation.start(); } else progressBar.setProgress(timerCounter); // no animation on Gingerbread or lower } }); }
From source file:com.cuelogic.android.WheelIndicatorView.java
public void startItemsAnimation() { ObjectAnimator animation = ObjectAnimator.ofInt(WheelIndicatorView.this, "filledPercent", 0, filledPercent); animation.setDuration(ANIMATION_DURATION); animation.setInterpolator(PathInterpolatorCompat.create(0.4F, 0.0F, 0.2F, 1.0F)); animation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override// w w w . j av a2s. c o m public void onAnimationUpdate(ValueAnimator animation) { recalculateItemsAngles(); invalidate(); } }); animation.start(); }
From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java
/** * Create a color change animation over a foreground property of a {@link FrameLayout}. * * @param target The target view./* ww w . j a v a 2 s . c o m*/ * @param startColorRes The color to start from. * @param targetColorRes The color this animation will end with. * @param interpolator The interpolator to use. * @return The color change animation. */ @NonNull public static ObjectAnimator createColorChange(@NonNull FrameLayout target, @ColorRes int startColorRes, @ColorRes int targetColorRes, @NonNull Interpolator interpolator) { Context context = target.getContext(); final int startColor = ContextCompat.getColor(context, startColorRes); final int targetColor = ContextCompat.getColor(context, targetColorRes); ObjectAnimator colorChange = ObjectAnimator.ofInt(target, ViewUtils.FOREGROUND_COLOR, startColor, targetColor); colorChange.setEvaluator(new ArgbEvaluator()); colorChange.setInterpolator(interpolator); colorChange.setDuration(context.getResources().getInteger(android.R.integer.config_longAnimTime)); return colorChange; }
From source file:com.josecalles.porridge.widget.BottomSheet.java
@Override public void onStopNestedScroll(View child) { final int dragDisplacement = dragView.getTop() - dragViewTop; if (dragDisplacement == 0) return;//w w w.j a va 2s . co m // check if we should perform a dismiss or settle back into place final boolean dismiss = lastNestedScrollWasDownward && dragDisplacement >= dragDismissDistance; // animate either back into place or to bottom ObjectAnimator settleAnim = ObjectAnimator.ofInt(dragViewOffsetHelper, ViewOffsetHelper.OFFSET_Y, dragView.getTop(), dismiss ? dragViewBottom : dragViewTop); settleAnim.setDuration(200L); settleAnim.setInterpolator( AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.fast_out_slow_in)); if (dismiss) { settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchDismissCallback(); } }); } settleAnim.start(); }
From source file:com.example.tt.pullrefresh.widget.CurveLayout.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;// w ww . j a v a2 s .c om Log.e(TAG, "animateSettle:TopAndBottom :::" + sheetOffsetHelper.getTopAndBottomOffset()); if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) { if (targetOffset >= dismissOffset) { dispatchDismissCallback(); } return; } settling = true; final boolean dismissing = targetOffset == dismissOffset; final long duration = computeSettleDuration(initialVelocity, dismissing); final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(getSettleInterpolator(dismissing, initialVelocity)); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (dismissing) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:com.appsimobile.appsii.Sidebar.java
@Override protected void onFinishInflate() { super.onFinishInflate(); // we need to find the actionbar before we initialize the view // pager adapter. All views inside the adapter will assume a // special SidebarContext that provides access to the actionbar. mAppsiViewPager = (ViewPager) findViewById(R.id.appsi_view_pager); mAppsiViewPager.addOnPageChangeListener(mOnPageChangeListener); mAdapter = new SidebarPagerAdapter(mAppsiContext); mAppsiViewPager.setAdapter(mAdapter); mAdapter.setFlagListener(this); mSidebarBackgroundView = findViewById(R.id.sidebar_back); mLeftShadow = findViewById(R.id.sidebar_left_shadow); mRightShadow = findViewById(R.id.sidebar_right_shadow); mCloseText = findViewById(R.id.always_close_text); mCancelClosingOverlayAlwaysCloseButton = findViewById(R.id.always_close); mCancelClosingOverlayNeverCloseButton = findViewById(R.id.never_close); mCancelClosingOverlayAlwaysCloseButton.setBackground(ThemingUtils.createButtonDrawable(mAppsiContext)); mCancelClosingOverlayNeverCloseButton.setBackground(ThemingUtils.createButtonDrawable(mAppsiContext)); mCancelClosingOverlay = findViewById(R.id.widget_action_overlay); mCancelClosingProgressBar = (ProgressBar) findViewById(R.id.closing_progress_bar); mCancelClosingOverlay.setOnTouchListener(new OnTouchListener() { @Override/*from w w w . j a v a 2s . com*/ public boolean onTouch(View v, MotionEvent event) { cancelClosingOverlay(); return true; } }); mClosingProgressBarAnimator = ObjectAnimator.ofInt(mCancelClosingProgressBar, "progress", 100, 0); mClosingProgressBarAnimator.setDuration(DELAYED_CLOSE_DURATION); setFocusableInTouchMode(true); if (!isInEditMode()) { findViewById(R.id.sidebar_close_area).setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { closeSidebar(); return true; } }); } mCancelClosingOverlayAlwaysCloseButton.setOnClickListener(this); mCancelClosingOverlayNeverCloseButton.setOnClickListener(this); }
From source file:com.cyanogenmod.eleven.ui.activities.HomeActivity.java
private void updateStatusBarColor(int color) { final Window window = getWindow(); ObjectAnimator animator = ObjectAnimator.ofInt(window, "statusBarColor", window.getStatusBarColor(), color); animator.setEvaluator(new ArgbEvaluator()); animator.setDuration(300);//from w ww . j a v a2 s . c o m animator.start(); }
From source file:com.amitupadhyay.aboutexample.ui.widget.BottomSheet.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;//from ww w.java 2 s . c o m if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) { if (targetOffset >= dismissOffset) { dispatchDismissCallback(); } return; } settling = true; final boolean dismissing = targetOffset == dismissOffset; final long duration = computeSettleDuration(initialVelocity, dismissing); final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(getSettleInterpolator(dismissing, initialVelocity)); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (dismissing) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }
From source file:com.xixicm.de.presentation.view.activity.MainActivity.java
@Override public void updateManualFetchFabAnimator(boolean needToEnd, boolean needToStart) { if (mManualFetchFabAnimator == null) { mManualFetchFabAnimator = ObjectAnimator.ofInt(mManualFetchFab.getDrawable(), "level", 0, 10000); mManualFetchFabAnimator.setDuration(1000); mManualFetchFabAnimator.setRepeatCount(ValueAnimator.INFINITE); }/*from ww w . ja v a 2 s . c om*/ if (needToEnd) { mManualFetchFabAnimator.end(); } else if (needToStart && !mManualFetchFabAnimator.isStarted()) { mManualFetchFabAnimator.start(); } }
From source file:com.lovejjfg.blogdemo.ui.BottomSheet.java
private void animateSettle(int initialOffset, final int targetOffset, long duration) { if (settling) return;/*from ww w. ja va2 s . com*/ if (sheetOffsetHelper.getTopAndBottomOffset() == targetOffset) return; settling = true; final ObjectAnimator settleAnim = ObjectAnimator.ofInt(sheetOffsetHelper, ViewOffsetHelper.OFFSET_Y, initialOffset, targetOffset); settleAnim.setDuration(duration); settleAnim.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(getContext())); settleAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { dispatchPositionChangedCallback(); if (targetOffset == dismissOffset) { dispatchDismissCallback(); } settling = false; } }); if (callbacks != null && !callbacks.isEmpty()) { settleAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { if (animation.getAnimatedFraction() > 0f) { dispatchPositionChangedCallback(); } } }); } settleAnim.start(); }