Example usage for android.animation ObjectAnimator start

List of usage examples for android.animation ObjectAnimator start

Introduction

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

Prototype

@Override
    public void start() 

Source Link

Usage

From source file:co.ceryle.radiorealbutton.library.RadioRealButtonGroup.java

private void animateSelectorSliding(int toPosition, String property, boolean hasAnimation,
        boolean enableDeselection) {
    boolean isViewDrawn = buttons.size() > 0 && buttons.get(0).getWidth() > 0;
    if (!isViewDrawn) {
        if (initialPosition != -1)
            v_selectors.get(initialPosition).setVisibility(INVISIBLE);
        v_selectors.get(toPosition).setVisibility(VISIBLE);
        initialPosition = toPosition;//from   w ww  .ja  v a 2 s. com
        return;
    }

    if (initialPosition < 0) {
        initialPosition = 0;

        View view = v_selectors.get(initialPosition);
        view.setTranslationX(-buttons.get(initialPosition).getWidth());
        view.setVisibility(VISIBLE);
    }

    if (enableDeselection && toPosition == lastPosition && buttons.get(toPosition).isChecked()) {
        toPosition = lastPosition > numberOfButtons / 2 ? numberOfButtons : -1;
    }

    float position = toPosition - initialPosition;

    float value = buttons.get(initialPosition).getWidth() * position + dividerSize * position;
    ObjectAnimator animator = createAnimator(v_selectors.get(initialPosition), property, value, false,
            hasAnimation);
    animator.start();
}

From source file:com.money.manager.ex.home.HomeFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
    switch (loader.getId()) {
    case LOADER_ACCOUNT_BILLS:
        try {//ww  w  .j  a  v a2s .c  o  m
            renderAccountsList(data);
        } catch (Exception e) {
            Timber.e(e, "rendering account list");
        }

        // set total for accounts in the main Drawer.
        EventBus.getDefault().post(new AccountsTotalLoadedEvent(txtTotalAccounts.getText().toString()));
        break;

    case LOADER_INCOME_EXPENSES:
        double income = 0, expenses = 0;
        if (data != null) {
            while (data.moveToNext()) {
                expenses = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Expenses));
                income = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Income));
            }
        }
        TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome);
        TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses);
        TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference);
        // set value
        if (txtIncome != null)
            txtIncome.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(),
                    MoneyFactory.fromDouble(income)));
        if (txtExpenses != null)
            txtExpenses.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(),
                    MoneyFactory.fromDouble(Math.abs(expenses))));
        if (txtDifference != null)
            txtDifference.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(),
                    MoneyFactory.fromDouble(income - Math.abs(expenses))));
        // manage progressbar
        final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome);
        final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses);

        if (barIncome != null && barExpenses != null) {
            barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses)));
            barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses)));

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
                ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress",
                        (int) Math.abs(income));
                animationIncome.setDuration(1000); // 0.5 second
                animationIncome.setInterpolator(new DecelerateInterpolator());
                animationIncome.start();

                ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress",
                        (int) Math.abs(expenses));
                animationExpenses.setDuration(1000); // 0.5 second
                animationExpenses.setInterpolator(new DecelerateInterpolator());
                animationExpenses.start();
            } else {
                barIncome.setProgress((int) Math.abs(income));
                barExpenses.setProgress((int) Math.abs(expenses));
            }
        }
        break;
    }

    // Close the cursor.
    MmxDatabaseUtils.closeCursor(data);
}

From source file:com.leavjenn.smoothdaterangepicker.date.SmoothDateRangePickerFragment.java

private void setViewSelected(View... views) {
    mMonthAndDayView.setSelected(false);
    mMonthAndDayViewEnd.setSelected(false);
    mYearView.setSelected(false);/*  w  w w  .  j a v  a  2  s. c  om*/
    mYearViewEnd.setSelected(false);
    mDurationView.setSelected(false);
    for (View view : views) {
        view.setSelected(true);
        if (view != mDurationView) { // disable DurationView animation
            ObjectAnimator pulseAnimator = Utils.getPulseAnimator(view, 0.9f, 1.05f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
            pulseAnimator.start();
        }
    }
}

From source file:org.namelessrom.devicecontrol.modules.appmanager.BaseAppListFragment.java

public void loadApps(final boolean animate) {
    if (mIsLoading) {
        return;/* ww  w.j  a v a  2  s.  c om*/
    }

    mIsLoading = true;
    mProgressContainer.post(new Runnable() {
        @Override
        public void run() {
            mProgressContainer.setVisibility(View.VISIBLE);

            if (animate) {
                final ObjectAnimator anim = ObjectAnimator.ofFloat(mProgressContainer, "alpha", 0f, 1f);
                anim.addListener(new Animator.AnimatorListener() {
                    @Override
                    public void onAnimationStart(Animator animation) {
                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {
                        new LoadApps().execute();
                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {
                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {
                    }
                });
                anim.setDuration(ANIM_DURATION);
                anim.start();
            } else {
                mProgressContainer.setAlpha(1f);
                new LoadApps().execute();
            }
        }
    });
}

From source file:com.nihaskalam.progressbuttonlibrary.CircularProgressButton.java

private void animateIdleStateButtonAfterClick() {
    int textColorChangeDuration = 10;
    ObjectAnimator colorAnim = ObjectAnimator.ofInt(this, "textColor", getNormalColor(this.getTextColors()),
            mIdleStateTextColorAfterClick);
    colorAnim.setDuration(textColorChangeDuration);
    colorAnim.setEvaluator(new ArgbEvaluator());
    colorAnim.start();

    ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick,
            getNormalColor(this.getTextColors()));
    colorAnim1.setDuration(0);//w ww  .  ja v  a2s .co m
    colorAnim1.setStartDelay(IDLE_STATE_ANIMATION_DURATION_AFTER_CLICK - textColorChangeDuration);
    colorAnim1.setEvaluator(new ArgbEvaluator());
    colorAnim1.setInterpolator(new BounceInterpolator());
    colorAnim1.start();

    ObjectAnimator bgAnim = ObjectAnimator.ofInt(this, "backgroundColor", getNormalColor(mIdleColorState),
            mIdleStateBackgroundColorAfterClick);
    bgAnim.setDuration(0);
    bgAnim.setEvaluator(new ArgbEvaluator());
    bgAnim.start();

    int textSizeAnimationDuration = 150;
    ValueAnimator animator = ValueAnimator.ofFloat(textSize, textSize - textSize / 4);
    animator.setDuration(textSizeAnimationDuration);
    animator.setRepeatCount(1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float animatedValue = (float) valueAnimator.getAnimatedValue();
            setTextSize(animatedValue);
        }
    });

    animator.start();
}

From source file:com.google.android.apps.santatracker.village.Village.java

private void easterEggInteraction() {
    mCallback.playSoundOnce(R.raw.easter_egg);

    // Fade into the distance
    ObjectAnimator anim = ObjectAnimator.ofFloat(mImageUfo, "size", 1.0f, 0f);
    anim.setInterpolator(new AccelerateInterpolator());
    anim.setDuration(ImageWithAlphaAndSize.ANIM_DURATION);
    anim.addListener(new Animator.AnimatorListener() {
        @Override//from w  w w  . j a va 2s. com
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            mImageUfo.setAlpha(ImageWithAlphaAndSize.INVISIBLE);
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

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

From source file:me.lizheng.deckview.views.DeckChildView.java

/**
 * Animates this task view as it enters recents
 *//* ww w  .  ja v  a  2  s  .  c o m*/
void startEnterRecentsAnimation(final ViewAnimation.TaskViewEnterContext ctx) {
    Log.i(getClass().getSimpleName(), "startEnterRecentsAnimation");
    final DeckChildViewTransform transform = ctx.currentTaskTransform;
    int startDelay = 0;

    if (mConfig.launchedFromHome) {
        Log.i(getClass().getSimpleName(), "mConfig.launchedFromHome false");

        // Animate the tasks up
        int frontIndex = (ctx.currentStackViewCount - ctx.currentStackViewIndex - 1);
        int delay = mConfig.transitionEnterFromHomeDelay
                + frontIndex * mConfig.taskViewEnterFromHomeStaggerDelay;

        setScaleX(transform.scale);
        setScaleY(transform.scale);

        ObjectAnimator animator = ObjectAnimator.ofFloat(this, "TranslationY", getTranslationY(),
                transform.translationY);
        animator.addUpdateListener(ctx.updateListener);
        animator.setDuration(
                mConfig.taskViewEnterFromHomeDuration + frontIndex * mConfig.taskViewEnterFromHomeStaggerDelay);
        animator.setStartDelay(delay);
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                // Decrement the post animation trigger
                ctx.postAnimationTrigger.decrement();
            }
        });
        animator.start();

        ctx.postAnimationTrigger.increment();
        startDelay = delay;
    }

    // Enable the focus animations from this point onwards so that they aren't affected by the
    // window transitions
    postDelayed(new Runnable() {
        @Override
        public void run() {
            enableFocusAnimations();
        }
    }, startDelay);
}

From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java

/**
 * Smoothly scrolls the seekbar to the indicated position.
 *//*  w ww. java2  s  .c  o  m*/
private void smoothScrollSeekbar(int progress) {
    ObjectAnimator animation = ObjectAnimator.ofInt(mSeekbar, "progress", progress);
    animation.setDuration(200);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.start();

}

From source file:me.hammarstrom.imagerecognition.activities.MainActivity.java

/**
 * Helper method to show / hide progress bar
 *
 * @param show if progress should be shown or not
 *//* ww  w.  j  a v a 2  s .c  o m*/
private void showLoading(final boolean show) {
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mLoadingLayout, "alpha", show ? 0f : 1f,
            show ? 1f : 0f);
    alphaAnimator.setDuration(200);
    alphaAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            if (!show) {
                mLoadingLayout.setVisibility(View.GONE);
            }
        }

        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            if (show) {
                mLoadingLayout.setAlpha(0f);
                mLoadingLayout.setVisibility(View.VISIBLE);
                mTts.speak(getString(R.string.tts_processing_image), TextToSpeech.QUEUE_FLUSH, null);
            }
        }
    });
    alphaAnimator.start();
}

From source file:com.amaze.carbonfilemanager.utils.files.Futils.java

public void revealShow(final View view, boolean reveal) {
    if (reveal) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f);
        animator.setDuration(300); //ms
        animator.addListener(new AnimatorListenerAdapter() {
            @Override//from   ww w .ja v a 2s .c  o m
            public void onAnimationStart(Animator animation) {
                view.setVisibility(View.VISIBLE);
            }
        });
        animator.start();
    } else {

        ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f);
        animator.setDuration(300); //ms
        animator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                view.setVisibility(View.GONE);
            }
        });
        animator.start();
    }
}