List of usage examples for android.animation ObjectAnimator start
@Override public void 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 www . j av a2 s.com*/ 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.serenegiant.aceparrot.BaseFragment.java
/** * start?stop????//from w w w.j ava2s.c om * @param target * @param type ??????? * @param start [0.0f-1.0f] * @param stop [0.0f-1.0f] * @param duration [] * @param startDelay [] */ @SuppressLint("NewApi") protected final void alphaAnimation(final View target, final int type, final float start, final float stop, final long duration, final long startDelay, final AnimationCallback callback) { // if (DEBUG) Log.v(TAG, "fadeOut,target=" + target); if (target == null) return; target.clearAnimation(); if (target.getVisibility() == View.VISIBLE) { target.setTag(R.id.anim_type, type); target.setTag(R.id.anim_callback, callback); target.setScaleX(1.0f); target.setScaleY(1.0f); target.setAlpha(start); final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(target, "alpha", start, stop); objectAnimator.addListener(mAnimatorListener); if (BuildCheck.isAndroid4_3()) objectAnimator.setAutoCancel(true); // API >= 18 ??????Animator???? objectAnimator.setDuration(duration > 0 ? duration : 500); // 0.5??? objectAnimator.setStartDelay(startDelay > 0 ? startDelay : 0); // ??? objectAnimator.start(); // } }
From source file:org.codeforafrica.citizenreporter.eNCA.widgets.SlidingTabLayout.java
public void setBadge(int position, boolean isBadged) { final View badgeView = mTabStrip.findViewWithTag(makeBadgeTag(position)); if (badgeView == null) { return;/* ww w . j av a 2 s . c o m*/ } boolean wasBadged = (badgeView.getVisibility() == View.VISIBLE); if (isBadged == wasBadged) { return; } float start = isBadged ? 0f : 1f; float end = isBadged ? 1f : 0f; PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, start, end); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, start, end); ObjectAnimator animScale = ObjectAnimator.ofPropertyValuesHolder(badgeView, scaleX, scaleY); if (isBadged) { animScale.setInterpolator(new BounceInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_longAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { badgeView.setVisibility(View.VISIBLE); } }); } else { animScale.setInterpolator(new AccelerateInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { badgeView.setVisibility(View.GONE); } }); } animScale.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 va 2s . co m*/ 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(); }
From source file:com.waz.zclient.ui.cursor.CursorLayout.java
private void showEditMessageToolbar() { ObjectAnimator hideAnimator; if (mainToolbar.getVisibility() == VISIBLE) { if (hideMainToolbarAnimator == null) { hideMainToolbarAnimator = getHideToolbarAnimator(mainToolbar, 0, -cursorHeight); }/*from w w w . j a va2s . c o m*/ hideAnimator = hideMainToolbarAnimator; } else { if (hideSecondaryToolbarAnimator == null) { hideSecondaryToolbarAnimator = getHideToolbarAnimator(secondaryToolbar, 0, 2 * cursorHeight); } hideAnimator = hideSecondaryToolbarAnimator; } if (showEditMessageToolbarAnimator == null) { showEditMessageToolbarAnimator = getShowToolbarAnimator(editMessageCursorToolbar, 2 * cursorHeight, 0); } editMessageCursorToolbar.setVisibility(VISIBLE); hideAnimator.start(); showEditMessageToolbarAnimator.start(); }
From source file:com.example.tt.pullrefresh.widget.CurveLayout.java
private void animateSettle(int initialOffset, final int targetOffset, float initialVelocity) { if (settling) return;//from w w w . ja v a2 s. c o m 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:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Makes the view blink", example = "") @APIParam(params = { "View", "speed", "num" }) public void blink(View v, int speed, int num) { ObjectAnimator anim = ObjectAnimator.ofFloat(v, "alpha", 1f, 0f, 1f); anim.setDuration(speed);/*from w w w .j a va 2 s .c om*/ //anim.setInterpolator(new CycleInterpolator(num)); anim.setRepeatCount(num); anim.start(); }
From source file:com.yekertech.tvbarsetting.dialog.DialogFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;/*from w w w. j a v a 2s. c o m*/ // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); runDelayedAnim(new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, // so just bail return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(SECONDARY_ANIMATE_DELAY); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment // TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the // end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); // Fade in the selector. if (mSelectorAnimator != null) { mSelectorAnimator.fadeIn(); } } }); }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Makes the view blink", example = "") @APIParam(params = { "View", "num" }) public void blink(View v, int num) { ObjectAnimator anim = ObjectAnimator.ofFloat(v, "alpha", 1f, 0f, 1f); anim.setDuration(AppSettings.animGeneralSpeed); anim.setInterpolator(new CycleInterpolator(1)); anim.setRepeatCount(num);/*from w w w . j a v a 2 s . co m*/ anim.start(); }
From source file:com.android.tv.settings.dialog.DialogFragment.java
private void performEntryTransition() { final View dialogView = getView(); final View contentView = (View) dialogView.getTag(R.id.content_fragment); final View actionContainerView = dialogView.findViewById(R.id.action_fragment); mIntroAnimationInProgress = true;/*w ww .j a v a 2s. c o m*/ // Fade out the old activity. getActivity().overridePendingTransition(0, R.anim.lb_dialog_fade_out); int bgColor = contentView.getContext().getResources().getColor(R.color.lb_dialog_activity_background); final ColorDrawable bgDrawable = new ColorDrawable(); bgDrawable.setColor(bgColor); bgDrawable.setAlpha(0); dialogView.setBackground(bgDrawable); dialogView.setVisibility(View.INVISIBLE); runDelayedAnim(new Runnable() { @Override public void run() { if (!isAdded()) { // We have been detached before this could run, // so just bail return; } dialogView.setVisibility(View.VISIBLE); // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(bgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(SECONDARY_ANIMATE_DELAY); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == View.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionContainerView.getMeasuredWidth() : actionContainerView.getMeasuredWidth(); // Fade in and slide in the ContentFragment // TextViews from the start. prepareAndAnimateView((View) contentView.getTag(R.id.title), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.breadcrumb), startDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.description), startDist, false); // Fade in and slide in the ActionFragment from the // end. prepareAndAnimateView(actionContainerView, endDist, false); prepareAndAnimateView((View) contentView.getTag(R.id.icon), startDist, true); // Fade in the selector. if (mSelectorAnimator != null) { mSelectorAnimator.fadeIn(); } } }); }