Example usage for android.animation ObjectAnimator ofInt

List of usage examples for android.animation ObjectAnimator ofInt

Introduction

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

Prototype

public static <T> ObjectAnimator ofInt(T target, Property<T, Integer> xProperty, Property<T, Integer> yProperty,
        Path path) 

Source Link

Document

Constructs and returns an ObjectAnimator that animates coordinates along a Path using two properties.

Usage

From source file:com.offers.couponempire.ui.BaseActivity.java

protected void onActionBarAutoShowOrHide(boolean shown) {
    if (mStatusBarColorAnimator != null) {
        mStatusBarColorAnimator.cancel();
    }// w w w.j av  a 2s.com
    mStatusBarColorAnimator = ObjectAnimator
            .ofInt((mDrawerLayout != null) ? mDrawerLayout : mLPreviewUtils,
                    (mDrawerLayout != null) ? "statusBarBackgroundColor" : "statusBarColor",
                    shown ? Color.BLACK : mNormalStatusBarColor, shown ? mNormalStatusBarColor : Color.BLACK)
            .setDuration(250);
    if (mDrawerLayout != null) {
        mStatusBarColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                ViewCompat.postInvalidateOnAnimation(mDrawerLayout);
            }
        });
    }
    mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR);
    mStatusBarColorAnimator.start();

    for (View view : mHideableHeaderViews) {
        if (shown) {
            view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        } else {
            view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION)
                    .setInterpolator(new DecelerateInterpolator());
        }
    }
}

From source file:com.tr4android.support.extension.picker.time.RadialTimePickerView.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static ObjectAnimator getFadeOutAnimator(IntHolder target, int startAlpha, int endAlpha,
        InvalidateUpdateListener updateListener) {
    final ObjectAnimator animator = ObjectAnimator.ofInt(target, "value", startAlpha, endAlpha);
    animator.setDuration(FADE_OUT_DURATION);
    animator.addUpdateListener(updateListener);
    return animator;
}

From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java

private void openProfileList() {
    Log.d(TAG, "openProfileList()");
    if (!profileListOpen) {
        AnimatorSet set = new AnimatorSet();
        set.playTogether(ObjectAnimator.ofFloat(linearListView, "alpha", 1, 0f, 0f, 0f),
                ObjectAnimator.ofFloat(linearListView, "translationY", 0,
                        getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4),
                ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 0, 1),
                ObjectAnimator.ofFloat(linearListViewProfileList, "translationY",
                        -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0),
                ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 0, 10000),
                ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0));
        set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time));
        set.addListener(new Animator.AnimatorListener() {
            @Override/*from  www  .  j a  v a2 s .  c  o  m*/
            public void onAnimationStart(Animator animation) {
                linearListViewProfileList.setVisibility(VISIBLE);

                imageViewOpenProfileListIcon.setClickable(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                imageViewOpenProfileListIcon.setClickable(true);

                profileListOpen = true;

                updateListVisibility();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

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

From source file:com.android.calendar.AllInOneActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Time t = null;/*from   w ww. j a v  a2 s .  c o  m*/
    int viewType = ViewType.CURRENT;
    long extras = CalendarController.EXTRA_GOTO_TIME;
    final int itemId = item.getItemId();
    if (itemId == R.id.action_refresh) {
        mController.refreshCalendars();
        return true;
    } else if (itemId == R.id.action_today) {
        viewType = ViewType.CURRENT;
        t = new Time(mTimeZone);
        t.setToNow();
        extras |= CalendarController.EXTRA_GOTO_TODAY;
    } else if (itemId == R.id.action_goto) {
        Time todayTime;
        t = new Time(mTimeZone);
        t.set(mController.getTime());
        todayTime = new Time(mTimeZone);
        todayTime.setToNow();
        if (todayTime.month == t.month) {
            t = todayTime;
        }

        DatePickerDialog datePickerDialog = DatePickerDialog
                .newInstance(new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePickerDialog dialog, int year, int monthOfYear, int dayOfMonth) {
                        Time selectedTime = new Time(mTimeZone);
                        selectedTime.year = year;
                        selectedTime.month = monthOfYear;
                        selectedTime.monthDay = dayOfMonth;
                        long extras = CalendarController.EXTRA_GOTO_TIME | CalendarController.EXTRA_GOTO_DATE;
                        mController.sendEvent(this, EventType.GO_TO, selectedTime, null, selectedTime, -1,
                                ViewType.CURRENT, extras, null, null);
                    }
                }, t.year, t.month, t.monthDay);
        datePickerDialog.show(getFragmentManager(), "datePickerDialog");

    } else if (itemId == R.id.action_hide_controls) {
        mHideControls = !mHideControls;
        Utils.setSharedPreference(this, GeneralPreferences.KEY_SHOW_CONTROLS, !mHideControls);
        item.setTitle(mHideControls ? mShowString : mHideString);
        if (!mHideControls) {
            mMiniMonth.setVisibility(View.VISIBLE);
            mCalendarsList.setVisibility(View.VISIBLE);
            mMiniMonthContainer.setVisibility(View.VISIBLE);
        }
        final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
                mHideControls ? 0 : mControlsAnimateWidth, mHideControls ? mControlsAnimateWidth : 0);
        slideAnimation.setDuration(mCalendarControlsAnimationTime);
        ObjectAnimator.setFrameDelay(0);
        slideAnimation.start();
        return true;
    } else if (itemId == R.id.action_search) {
        return false;
    } else if (itemId == R.id.action_import) {
        ImportActivity.pickImportFile(this);
    } else {
        return mExtensions.handleItemSelected(item, this);
    }
    mController.sendEvent(this, EventType.GO_TO, t, null, t, -1, viewType, extras, null, null);
    return true;
}

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();//  w w  w .  java  2 s  .  co m

    ObjectAnimator colorAnim1 = ObjectAnimator.ofInt(this, "textColor", mIdleStateTextColorAfterClick,
            getNormalColor(this.getTextColors()));
    colorAnim1.setDuration(0);
    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:trendoidtechnologies.com.navigationdrawerlibrary.DrawerView.java

private void openProfileList() {
    if (loggingEnabled)
        Log.d(TAG, "openProfileList()");
    if (!profileListOpen) {
        AnimatorSet set = new AnimatorSet();
        set.playTogether(ObjectAnimator.ofFloat(linearListView, "alpha", 1, 0f, 0f, 0f),
                ObjectAnimator.ofFloat(linearListView, "translationY", 0,
                        getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4),
                ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 0, 1),
                ObjectAnimator.ofFloat(linearListViewProfileList, "translationY",
                        -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0),
                ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 0, 10000),
                ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0));
        set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time));
        set.addListener(new Animator.AnimatorListener() {
            @Override/*  w  ww . j a  v  a 2  s  . co m*/
            public void onAnimationStart(Animator animation) {
                linearListViewProfileList.setVisibility(VISIBLE);

                imageViewOpenProfileListIcon.setClickable(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                imageViewOpenProfileListIcon.setClickable(true);

                profileListOpen = true;

                updateListVisibility();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

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

From source file:com.github.shareme.gwsmaterialdrawer.library.DrawerView.java

private void closeProfileList() {
    Log.d(TAG, "closeProfileList()");
    if (profileListOpen) {
        AnimatorSet set = new AnimatorSet();
        set.playTogether(ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 1, 0f, 0f, 0f),
                ObjectAnimator.ofFloat(linearListViewProfileList, "translationY", 0,
                        -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4),
                ObjectAnimator.ofFloat(linearListView, "alpha", 0f, 1),
                ObjectAnimator.ofFloat(linearListView, "translationY",
                        getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0),
                ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 10000, 0),
                ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0));
        set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time));
        set.addListener(new Animator.AnimatorListener() {
            @Override/*  ww  w .j a  v  a 2s.  c o  m*/
            public void onAnimationStart(Animator animation) {
                linearListView.setVisibility(VISIBLE);
                imageViewOpenProfileListIcon.setClickable(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                imageViewOpenProfileListIcon.setClickable(true);

                profileListOpen = false;

                updateListVisibility();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

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

From source file:trendoidtechnologies.com.navigationdrawerlibrary.DrawerView.java

private void closeProfileList() {
    if (loggingEnabled)
        Log.d(TAG, "closeProfileList()");
    if (profileListOpen) {
        AnimatorSet set = new AnimatorSet();
        set.playTogether(ObjectAnimator.ofFloat(linearListViewProfileList, "alpha", 1, 0f, 0f, 0f),
                ObjectAnimator.ofFloat(linearListViewProfileList, "translationY", 0,
                        -getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 4),
                ObjectAnimator.ofFloat(linearListView, "alpha", 0f, 1),
                ObjectAnimator.ofFloat(linearListView, "translationY",
                        getResources().getDimensionPixelSize(R.dimen.md_list_item_height) / 2, 0),
                ObjectAnimator.ofInt(imageViewOpenProfileListIcon.getDrawable(), PROPERTY_LEVEL, 10000, 0),
                ObjectAnimator.ofInt(scrollView, PROPERTY_SCROLL_POSITION, 0));
        set.setDuration(getResources().getInteger(R.integer.md_profile_list_open_anim_time));
        set.addListener(new Animator.AnimatorListener() {
            @Override//from w ww  .  j  a va2  s  .c o m
            public void onAnimationStart(Animator animation) {
                linearListView.setVisibility(VISIBLE);
                imageViewOpenProfileListIcon.setClickable(false);
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                imageViewOpenProfileListIcon.setClickable(true);

                profileListOpen = false;

                updateListVisibility();
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }

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

From source file:io.doist.datetimepicker.time.RadialTimePickerView.java

private static ObjectAnimator getFadeOutAnimator(IntHolder target, int startAlpha, int endAlpha,
        InvalidateUpdateListener updateListener) {
    int duration = 500;
    ObjectAnimator animator = ObjectAnimator.ofInt(target, "value", startAlpha, endAlpha);
    animator.setDuration(duration);// w  w  w.  ja v a2s.  c o  m
    animator.addUpdateListener(updateListener);

    return animator;
}

From source file:com.xandy.calendar.AllInOneActivity.java

@Override
public void handleEvent(EventInfo event) {
    long displayTime = -1;
    if (event.eventType == EventType.GO_TO) {
        if ((event.extraLong & CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS) != 0) {
            mBackToPreviousView = true;//from w  w w. j ava2s  .  com
        } else if (event.viewType != mController.getPreviousViewType() && event.viewType != ViewType.EDIT) {
            // Clear the flag is change to a different view type
            mBackToPreviousView = false;
        }

        setMainPane(null, R.id.main_pane, event.viewType, event.startTime.toMillis(false), false);
        if (mSearchView != null) {
            mSearchView.clearFocus();
        }
        if (mShowCalendarControls) {
            int animationSize = (mOrientation == Configuration.ORIENTATION_LANDSCAPE) ? mControlsAnimateWidth
                    : mControlsAnimateHeight;
            boolean noControlsView = event.viewType == ViewType.MONTH || event.viewType == ViewType.AGENDA;
            if (mControlsMenu != null) {
                mControlsMenu.setVisible(!noControlsView);
                mControlsMenu.setEnabled(!noControlsView);
            }
            if (noControlsView || mHideControls) {
                // hide minimonth and calendar frag
                mShowSideViews = false;
                if (!mHideControls) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", 0,
                            animationSize);
                    slideAnimation.addListener(mSlideAnimationDoneListener);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                } else {
                    mMiniMonth.setVisibility(View.GONE);
                    mCalendarsList.setVisibility(View.GONE);
                    mMiniMonthContainer.setVisibility(View.GONE);
                }
            } else {
                // show minimonth and calendar frag
                mShowSideViews = true;
                mMiniMonth.setVisibility(View.VISIBLE);
                mCalendarsList.setVisibility(View.VISIBLE);
                mMiniMonthContainer.setVisibility(View.VISIBLE);
                if (!mHideControls && (mController.getPreviousViewType() == ViewType.MONTH
                        || mController.getPreviousViewType() == ViewType.AGENDA)) {
                    final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset",
                            animationSize, 0);
                    slideAnimation.setDuration(mCalendarControlsAnimationTime);
                    ObjectAnimator.setFrameDelay(0);
                    slideAnimation.start();
                }
            }
        }
        displayTime = event.selectedTime != null ? event.selectedTime.toMillis(true)
                : event.startTime.toMillis(true);
        if (!mIsTabletConfig) {
            mActionBarMenuSpinnerAdapter.setTime(displayTime);
        }
    } else if (event.eventType == EventType.VIEW_EVENT) {

        // If in Agenda view and "show_event_details_with_agenda" is "true",
        // do not create the event info fragment here, it will be created by the Agenda
        // fragment

        if (mCurrentView == ViewType.AGENDA && mShowEventDetailsWithAgenda) {
            if (event.startTime != null && event.endTime != null) {
                // Event is all day , adjust the goto time to local time
                if (event.isAllDay()) {
                    Utils.convertAlldayUtcToLocal(event.startTime, event.startTime.toMillis(false), mTimeZone);
                    Utils.convertAlldayUtcToLocal(event.endTime, event.endTime.toMillis(false), mTimeZone);
                }
                mController.sendEvent(this, EventType.GO_TO, event.startTime, event.endTime, event.selectedTime,
                        event.id, ViewType.AGENDA, CalendarController.EXTRA_GOTO_TIME, null, null);
            } else if (event.selectedTime != null) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, event.id,
                        ViewType.AGENDA);
            }
        } else {
            // TODO Fix the temp hack below: && mCurrentView !=
            // ViewType.AGENDA
            if (event.selectedTime != null && mCurrentView != ViewType.AGENDA) {
                mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, -1,
                        ViewType.CURRENT);
            }
            int response = event.getResponse();
            if ((mCurrentView == ViewType.AGENDA && mShowEventInfoFullScreenAgenda)
                    || ((mCurrentView == ViewType.DAY || (mCurrentView == ViewType.WEEK)
                            || mCurrentView == ViewType.MONTH) && mShowEventInfoFullScreen)) {
                // start event info as activity
                Intent intent = new Intent(Intent.ACTION_VIEW);
                Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id);
                intent.setData(eventUri);
                intent.setClass(this, EventInfoActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false));
                intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false));
                intent.putExtra(ATTENDEE_STATUS, response);
                startActivity(intent);
            } else {
                // start event info as a dialog
                EventInfoFragment fragment = new EventInfoFragment(this, event.id,
                        event.startTime.toMillis(false), event.endTime.toMillis(false), response, true,
                        EventInfoFragment.DIALOG_WINDOW_STYLE, null /* No reminders to explicitly pass in. */);
                fragment.setDialogParams(event.x, event.y, mActionBar.getHeight());
                //                    FragmentManager fm = getFragmentManager();
                FragmentManager fm = getSupportFragmentManager();
                FragmentTransaction ft = fm.beginTransaction();
                // if we have an old popup replace it
                Fragment fOld = fm.findFragmentByTag(EVENT_INFO_FRAGMENT_TAG);
                if (fOld != null && fOld.isAdded()) {
                    ft.remove(fOld);
                }
                ft.add(fragment, EVENT_INFO_FRAGMENT_TAG);
                ft.commit();
            }
        }
        displayTime = event.startTime.toMillis(true);
    } else if (event.eventType == EventType.UPDATE_TITLE) {
        setTitleInActionBar(event);
        if (!mIsTabletConfig) {
            mActionBarMenuSpinnerAdapter.setTime(mController.getTime());
        }
    }
    updateSecondaryTitleFields(displayTime);
}