List of usage examples for android.animation ObjectAnimator start
@Override public void start()
From source file:com.customdatepicker.date.DatePickerDialog.java
private void setCurrentView(final int viewIndex) { long millis = mCalendar.getTimeInMillis(); switch (viewIndex) { case MONTH_AND_DAY_VIEW: if (mVersion == Version.VERSION_1) { ObjectAnimator pulseAnimator = Utils.getPulseAnimator(mMonthAndDayView, 0.9f, 1.05f); if (mDelayAnimation) { pulseAnimator.setStartDelay(ANIMATION_DELAY); mDelayAnimation = false; }// ww w . ja v a 2 s . c om mDayPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(true); mYearView.setSelected(false); mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW); mCurrentView = viewIndex; } pulseAnimator.start(); } else { mDayPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(true); mYearView.setSelected(false); mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW); mCurrentView = viewIndex; } } int flags = DateUtils.FORMAT_SHOW_DATE; String dayString = DateUtils.formatDateTime(getActivity(), millis, flags); mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString); Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay); break; case YEAR_VIEW: if (mVersion == Version.VERSION_1) { ObjectAnimator pulseAnimator = Utils.getPulseAnimator(mYearView, 0.85f, 1.1f); if (mDelayAnimation) { pulseAnimator.setStartDelay(ANIMATION_DELAY); mDelayAnimation = false; } mYearPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(false); mYearView.setSelected(true); mAnimator.setDisplayedChild(YEAR_VIEW); mCurrentView = viewIndex; } pulseAnimator.start(); } else { mYearPickerView.onDateChanged(); if (mCurrentView != viewIndex) { mMonthAndDayView.setSelected(false); mYearView.setSelected(true); mAnimator.setDisplayedChild(YEAR_VIEW); mCurrentView = viewIndex; } } CharSequence yearString = YEAR_FORMAT.format(millis); mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString); Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear); break; } }
From source file:com.borax12.materialdaterangepicker.single.time.TimePickerDialog.java
private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate, boolean announce) { mTimePicker.setCurrentItemShowing(index, animateCircle); TextView labelToAnimate;//from www . j a v a 2 s . c o m switch (index) { case HOUR_INDEX: int hours = mTimePicker.getHours(); if (!mIs24HourMode) { hours = hours % 12; } mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours); if (announce) { Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours); } labelToAnimate = mHourView; break; case MINUTE_INDEX: int minutes = mTimePicker.getMinutes(); mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes); if (announce) { Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes); } labelToAnimate = mMinuteView; break; default: int seconds = mTimePicker.getSeconds(); mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds); if (announce) { Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds); } labelToAnimate = mSecondView; } int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor; int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor; int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor; mHourView.setTextColor(hourColor); mMinuteView.setTextColor(minuteColor); mSecondView.setTextColor(secondColor); ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f); if (delayLabelAnimate) { pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY); } pulseAnimator.start(); }
From source file:com.example.customview.DynamicListView.java
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. *//* w w w. j a v a 2s. c o m*/ private void touchEventsEnded() { final View mobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { mIsWaitingForScrollFinish = true; return; } mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds); hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); hoverViewAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setEnabled(false); } @Override public void onAnimationEnd(Animator animation) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mobileView.setVisibility(VISIBLE); mHoverCell = null; setEnabled(true); invalidate(); } }); hoverViewAnimator.start(); } else { touchEventsCancelled(); } }
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 {//w w w. j ava 2 s .c o m 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(); }
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
public void reverseExpansionAnimation() { 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 w ww . jav a2 s . com*/ 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(screenHeight, expansionViewHeight); 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(getWidth(), expansionViewWidth); 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, 0f, expansionLeftOffset); translationX.setInterpolator(interpolator); translationX.setDuration(ANIMATION_DURATION); translationX.start(); ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, 0f, expansionTopOffset); translationY.setInterpolator(interpolator); translationY.setDuration(ANIMATION_DURATION); translationY.addListener(exitAnimationListner); translationY.start(); }
From source file:io.plaidapp.core.ui.FeedAdapter.java
private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder, int position) { final Images.ImageSize imageSize = shot.getImages().bestSize(); GlideApp.with(host).load(shot.getImages().best()).listener(new RequestListener<Drawable>() { @Override/*from w w w. jav a 2s.c om*/ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { if (!shot.getHasFadedIn()) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); final ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(valueAnimator -> { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( holder.image.setColorFilter(new ColorMatrixColorFilter(cm)); }); saturation.setDuration(2000L); saturation.setInterpolator(getFastOutSlowInInterpolator(host)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.clearColorFilter(); holder.image.setHasTransientState(false); } }); saturation.start(); shot.setHasFadedIn(true); } return false; } @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.DATA).fitCenter() .transition(DrawableTransitionOptions.withCrossFade()) .override(imageSize.getWidth(), imageSize.getHeight()) .into(new DribbbleTarget(holder.image, false)); // need both placeholder & background to prevent seeing through shot as it fades in holder.image.setBackground(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]); holder.image.setDrawBadge(shot.getAnimated()); // need a unique transition name per shot, let's use it's url holder.image.setTransitionName(shot.getHtmlUrl()); shotPreloadSizeProvider.setView(holder.image); }
From source file:com.igniva.filemanager.utils.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/* w w w . j ava 2 s. 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(); } }
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 ww . j a v a 2 s.co m*/ } 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); }
From source file:ucsc.hci.rankit.DynamicListView.java
/** * Resets all the appropriate fields to a default state while also animating * the hover cell back to its correct location. *///from w w w.j a v a 2 s . c o m private void touchEventsEnded() { final View mobileView = getViewForID(mMobileItemId); if (mCellIsMobile || mIsWaitingForScrollFinish) { mCellIsMobile = false; mIsWaitingForScrollFinish = false; mIsMobileScrolling = false; mActivePointerId = INVALID_POINTER_ID; // If the autoscroller has not completed scrolling, we need to wait for it to // finish in order to determine the final location of where the hover cell // should be animated to. if (mScrollState != OnScrollListener.SCROLL_STATE_IDLE) { mIsWaitingForScrollFinish = true; return; } try { mHoverCellCurrentBounds.offsetTo(mHoverCellOriginalBounds.left, mobileView.getTop()); } catch (Exception e) { e.printStackTrace(); } ObjectAnimator hoverViewAnimator = ObjectAnimator.ofObject(mHoverCell, "bounds", sBoundEvaluator, mHoverCellCurrentBounds); hoverViewAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { invalidate(); } }); hoverViewAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { setEnabled(false); } @Override public void onAnimationEnd(Animator animation) { mAboveItemId = INVALID_ID; mMobileItemId = INVALID_ID; mBelowItemId = INVALID_ID; mobileView.setVisibility(VISIBLE); mHoverCell = null; setEnabled(true); invalidate(); } }); try { hoverViewAnimator.start(); } catch (Exception e) { e.printStackTrace(); } } else { touchEventsCancelled(); } }
From source file:com.android.calendar.AllInOneActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { Time t = null;//from w w w .j av a 2 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; }