List of usage examples for android.animation ObjectAnimator start
@Override public void start()
From source file:com.bluros.music.nowplaying.BaseNowplayingFragment.java
public void changeDigit(TimelyView tv, int end) { ObjectAnimator obja = tv.animate(end); obja.setDuration(400); obja.start(); }
From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java
public void performEntryTransition(final Activity activity, final ViewGroup contentView, int iconResourceId, Uri iconResourceUri, final ImageView icon, final TextView title, final TextView description, final TextView breadcrumb) { // Pull out the root layout of the dialog and set the background drawable, to be // faded in during the transition. final ViewGroup twoPane = (ViewGroup) contentView.getChildAt(0); twoPane.setVisibility(View.INVISIBLE); // If the appropriate data is embedded in the intent and there is an icon specified // in the content fragment, we animate the icon from its initial position to the final // position. Otherwise, we perform a simpler transition in which the ActionFragment // slides in and the ContentFragment text fields slide in. mIntroAnimationInProgress = true;//from w w w .j a v a 2s . c o m List<TransitionImage> images = TransitionImage.readMultipleFromIntent(activity, activity.getIntent()); TransitionImageAnimation ltransitionAnimation = null; final Uri iconUri; final int color; if (images != null && images.size() > 0) { if (iconResourceId != 0) { iconUri = Uri.parse(UriUtils.getAndroidResourceUri(activity, iconResourceId)); } else if (iconResourceUri != null) { iconUri = iconResourceUri; } else { iconUri = null; } TransitionImage src = images.get(0); color = src.getBackground(); if (iconUri != null) { ltransitionAnimation = new TransitionImageAnimation(contentView); ltransitionAnimation.addTransitionSource(src); ltransitionAnimation.transitionDurationMs(ANIMATE_IN_DURATION).transitionStartDelayMs(0) .interpolator(new DecelerateInterpolator(1f)); } } else { iconUri = null; color = 0; } final TransitionImageAnimation transitionAnimation = ltransitionAnimation; // Fade out the old activity, and hard cut the new activity. activity.overridePendingTransition(R.anim.hard_cut_in, R.anim.fade_out); int bgColor = mFragment.getResources().getColor(R.color.dialog_activity_background); mBgDrawable.setColor(bgColor); mBgDrawable.setAlpha(0); twoPane.setBackground(mBgDrawable); // If we're animating the icon, we create a new ImageView in which to place the embedded // bitmap. We place it in the root layout to match its location in the previous activity. mShadowLayer = (FrameLayoutWithShadows) twoPane.findViewById(R.id.shadow_layout); if (transitionAnimation != null) { transitionAnimation.listener(new TransitionImageAnimation.Listener() { @Override public void onRemovedView(TransitionImage src, TransitionImage dst) { if (icon != null) { //want to make sure that users still see at least the source image // if the dst image is too large to finish downloading before the // animation is done. Check if the icon is not visible. This mean // BaseContentFragement have not finish downloading the image yet. if (icon.getVisibility() != View.VISIBLE) { icon.setImageDrawable(src.getBitmap()); int intrinsicWidth = icon.getDrawable().getIntrinsicWidth(); LayoutParams lp = icon.getLayoutParams(); lp.height = lp.width * icon.getDrawable().getIntrinsicHeight() / intrinsicWidth; icon.setVisibility(View.VISIBLE); } icon.setAlpha(1f); } if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(1f); } onIntroAnimationFinished(); } }); icon.setAlpha(0f); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } // We need to defer the remainder of the animation preparation until the first // layout has occurred, as we don't yet know the final location of the icon. twoPane.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { twoPane.getViewTreeObserver().removeOnGlobalLayoutListener(this); // if we buildLayer() at this time, the texture is actually not created // delay a little so we can make sure all hardware layer is created before // animation, in that way we can avoid the jittering of start animation twoPane.postOnAnimationDelayed(mEntryAnimationRunnable, ANIMATE_DELAY); } final Runnable mEntryAnimationRunnable = new Runnable() { @Override public void run() { if (!mFragment.isAdded()) { // We have been detached before this could run, so just bail return; } twoPane.setVisibility(View.VISIBLE); final int secondaryDelay = SLIDE_IN_DISTANCE; // Fade in the activity background protection ObjectAnimator oa = ObjectAnimator.ofInt(mBgDrawable, "alpha", 255); oa.setDuration(ANIMATE_IN_DURATION); oa.setStartDelay(secondaryDelay); oa.setInterpolator(new DecelerateInterpolator(1.0f)); oa.start(); View actionFragmentView = activity.findViewById(mActionAreaId); boolean isRtl = ViewCompat.getLayoutDirection(contentView) == ViewCompat.LAYOUT_DIRECTION_RTL; int startDist = isRtl ? SLIDE_IN_DISTANCE : -SLIDE_IN_DISTANCE; int endDist = isRtl ? -actionFragmentView.getMeasuredWidth() : actionFragmentView.getMeasuredWidth(); // Fade in and slide in the ContentFragment TextViews from the start. prepareAndAnimateView(title, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(breadcrumb, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); prepareAndAnimateView(description, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); // Fade in and slide in the ActionFragment from the end. prepareAndAnimateView(actionFragmentView, 0, endDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), false); if (icon != null && transitionAnimation != null) { // now we get the icon view in place, update the transition target TransitionImage target = new TransitionImage(); target.setUri(iconUri); target.createFromImageView(icon); if (icon.getBackground() instanceof ColorDrawable) { ColorDrawable d = (ColorDrawable) icon.getBackground(); target.setBackground(d.getColor()); } transitionAnimation.addTransitionTarget(target); transitionAnimation.startTransition(); } else if (icon != null) { prepareAndAnimateView(icon, 0, startDist, secondaryDelay, ANIMATE_IN_DURATION, new DecelerateInterpolator(1.0f), true /* is the icon */); if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(0f); } } } }; }); }
From source file:org.mozilla.focus.fragment.UrlInputFragment.java
/** * Play animation between home screen and the URL input. *///ww w.ja va2 s . co m private void playHomeScreenAnimation(final boolean reverse) { int[] screenLocation = new int[2]; urlInputContainerView.getLocationOnScreen(screenLocation); int leftDelta = getArguments().getInt(ARGUMENT_X) - screenLocation[0]; int topDelta = getArguments().getInt(ARGUMENT_Y) - screenLocation[1]; float widthScale = (float) getArguments().getInt(ARGUMENT_WIDTH) / urlInputContainerView.getWidth(); float heightScale = (float) getArguments().getInt(ARGUMENT_HEIGHT) / urlInputContainerView.getHeight(); if (!reverse) { // Move all views to the position of the fake URL bar on the home screen. Hide them until // the animation starts because we need to switch between fake URL bar and the actual URL // bar once the animation starts. urlInputContainerView.setAlpha(0); urlInputContainerView.setPivotX(0); urlInputContainerView.setPivotY(0); urlInputContainerView.setScaleX(widthScale); urlInputContainerView.setScaleY(heightScale); urlInputContainerView.setTranslationX(leftDelta); urlInputContainerView.setTranslationY(topDelta); urlInputContainerView.setAnimationOffset(1.0f); toolbarBackgroundView.setAlpha(0); dismissView.setAlpha(0); } // Move the URL bar from its position on the home screen to the actual position (and scale it). urlInputContainerView.animate().setDuration(ANIMATION_DURATION).scaleX(reverse ? widthScale : 1) .scaleY(reverse ? heightScale : 1).translationX(reverse ? leftDelta : 0) .translationY(reverse ? topDelta : 0).setInterpolator(new DecelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { ViewUtils.updateAlphaIfViewExists(getActivity(), R.id.fake_urlbar, 0f); urlInputContainerView.setAlpha(1); if (reverse) { urlView.setText(""); urlView.setCursorVisible(false); urlView.clearFocus(); } } @Override public void onAnimationEnd(Animator animation) { if (reverse) { urlInputContainerView.setAlpha(0f); ViewUtils.updateAlphaIfViewExists(getActivity(), R.id.fake_urlbar, 1f); dismiss(); } else { urlView.setCursorVisible(true); } } }); final ObjectAnimator hintAnimator = ObjectAnimator.ofFloat(urlInputContainerView, "animationOffset", reverse ? 0f : 1f, reverse ? 1f : 0f); hintAnimator.setDuration(ANIMATION_DURATION); hintAnimator.start(); // Let the toolbar background come int from the top toolbarBackgroundView.animate().alpha(reverse ? 0 : 1).setDuration(ANIMATION_DURATION) .setInterpolator(new DecelerateInterpolator()); // Use an alpha animation on the transparent black background dismissView.animate().alpha(reverse ? 0 : 1).setDuration(ANIMATION_DURATION); }
From source file:com.bluros.music.nowplaying.BaseNowplayingFragment.java
public void changeDigit(TimelyView tv, int start, int end) { try {/*from w w w.j a v a 2s .c o m*/ ObjectAnimator obja = tv.animate(start, end); obja.setDuration(400); obja.start(); } catch (InvalidParameterException e) { e.printStackTrace(); } }
From source file:de.persoapp.android.activity.fragment.InitializeAppFragment.java
private void playSuccessAnimation() { ObjectAnimator animator = ObjectAnimator.ofFloat(this, "saturation", 1F); animator.setDuration(1000L);/*from w ww.jav a 2s . c o m*/ animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mImageView.animate().alpha(0).setDuration(300l).withEndAction(new Runnable() { @Override public void run() { mEventBus.post(new OnAppInitialized(true)); } }); } }); animator.start(); }
From source file:org.namelessrom.devicecontrol.modules.cpu.CpuSettingsFragment.java
private void rotateView(View v) { if (v == null) { return;/* w w w . ja va2 s.c o m*/ } v.clearAnimation(); ObjectAnimator animator = ObjectAnimator.ofFloat(v, "rotation", 0.0f, 360.0f); animator.setDuration(500); animator.setInterpolator(new AccelerateDecelerateInterpolator()); animator.start(); }
From source file:de.dmxcontrol.fragment.ActionSelectorFragment.java
public void updateStateSelected(final int state) { boolean jump = false; if (state != Integer.MIN_VALUE) { jump = Math.abs(mState - state) > 1; mState = state;/*from w w w .j a va 2 s .com*/ } if (crrActionButton != null) { crrActionButton.setSelected(false); } switch (mState) { case STATE_DEVICE_PANEL: crrActionButton = bDeviceAction; break; case STATE_INTENSITY_PANEL: crrActionButton = bIntensityAction; break; case STATE_COLOR_PANEL: crrActionButton = bColorAction; break; case STATE_PANTILT_PANEL: crrActionButton = bPanTiltAction; break; case STATE_GOBO_PANEL: crrActionButton = bGoboAction; break; case STATE_OPTIC_PANEL: crrActionButton = bOpticAction; break; case STATE_PRISM_PANEL: crrActionButton = bPrismAction; break; case STATE_RAW_PANEL: crrActionButton = bRawAction; break; case STATE_EFFECT_PANEL: crrActionButton = bEffectAction; break; case STATE_PRESET_PANEL: crrActionButton = bPresetAction; break; case STATE_PROGRAMMER_PANEL: crrActionButton = bProgrammerAction; break; default: crrActionButton = bDeviceAction; } crrActionButton.setSelected(true); final boolean fJump = jump; if (state != Integer.MIN_VALUE) { if (scrollView.getClass() == HorizontalScrollView.class) { final HorizontalScrollView scroll = ((HorizontalScrollView) scrollView); new Handler().post(new Runnable() { @Override public void run() { final float destination = ((crrActionButton.getLeft() - (scrollView.getWidth() / 2))) + (crrActionButton.getWidth() / 2); ObjectAnimator animator = ObjectAnimator.ofInt(scroll, "scrollX", (int) destination); if (!fJump) { animator.setDuration(600); } else { animator.setDuration(1200); } animator.start(); } }); } else if (scrollView.getClass() == ScrollView.class) { final ScrollView scroll = ((ScrollView) scrollView); new Handler().post(new Runnable() { @Override public void run() { final float destination = ((crrActionButton.getBottom() - (scrollView.getHeight() / 2))) - (crrActionButton.getHeight() / 2) + (getStatusBarHeight() / 2); ObjectAnimator animator = ObjectAnimator.ofInt(scroll, "scrollY", (int) destination); if (!fJump) { animator.setDuration(600); } else { animator.setDuration(1200); } animator.start(); } }); } } }
From source file:com.google.android.apps.santatracker.village.Village.java
private void showEasterEgg() { ObjectAnimator anim = ObjectAnimator.ofFloat(mImageUfo, "size", 0f, 1.0f); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(ImageWithAlphaAndSize.ANIM_DURATION); anim.start(); mImageUfo.setAlpha(ImageWithAlphaAndSize.OPAQUE); // [ANALYTICS EVENT]: Village Click AnalyticsManager.sendEvent(R.string.analytics_event_category_village, R.string.analytics_event_village_unlock_easteregg); }
From source file:com.dgnt.dominionCardPicker.view.DynamicListView.java
/** * This method determines whether the hover cell has been shifted far enough * to invoke a cell swap. If so, then the respective cell swap candidate is * determined and the data set is changed. Upon posting a notification of the * data set change, a layout is invoked to place the cells in the right place. * Using a ViewTreeObserver and a corresponding OnPreDrawListener, we can * offset the cell being swapped to where it previously was and then animate it to * its new position.// w w w. j av a 2s . co m */ private void handleCellSwitch() { final int deltaY = mLastEventY - mDownY; int deltaYTotal = mHoverCellOriginalBounds.top + mTotalOffset + deltaY; View belowView = getViewForID(mBelowItemId); View mobileView = getViewForID(mMobileItemId); View aboveView = getViewForID(mAboveItemId); boolean isBelow = (belowView != null) && (deltaYTotal > belowView.getTop()); boolean isAbove = (aboveView != null) && (deltaYTotal < aboveView.getTop()); if (isBelow || isAbove) { final long switchItemID = isBelow ? mBelowItemId : mAboveItemId; View switchView = isBelow ? belowView : aboveView; final int originalItem = getPositionForView(mobileView); if (switchView == null) { updateNeighborViewsForID(mMobileItemId); return; } swapElements(list, originalItem, getPositionForView(switchView)); ((BaseAdapter) getAdapter()).notifyDataSetChanged(); mDownY = mLastEventY; final int switchViewStartTop = switchView.getTop(); mobileView.setVisibility(View.VISIBLE); switchView.setVisibility(View.VISIBLE); updateNeighborViewsForID(mMobileItemId); final ViewTreeObserver observer = getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { public boolean onPreDraw() { observer.removeOnPreDrawListener(this); View switchView = getViewForID(switchItemID); mTotalOffset += deltaY; int switchViewNewTop = switchView.getTop(); int delta = switchViewStartTop - switchViewNewTop; switchView.setTranslationY(delta); ObjectAnimator animator = ObjectAnimator.ofFloat(switchView, View.TRANSLATION_Y, 0); animator.setDuration(MOVE_DURATION); animator.start(); return true; } }); } }
From source file:fr.tvbarthel.apps.cameracolorpicker.activities.MainActivity.java
/** * Make a subtle animation for a {@link com.melnykov.fab.FloatingActionButton} drawing attention to the button. * * @param fab the {@link com.melnykov.fab.FloatingActionButton} to animate. *///from w w w .j a va 2 s .c o m private void animateFab(final FloatingActionButton fab) { fab.postDelayed(new Runnable() { @Override public void run() { // Play a subtle animation final long duration = 450; final ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(fab, View.SCALE_X, 1f, 1.2f, 1f); scaleXAnimator.setDuration(duration); scaleXAnimator.setRepeatCount(1); final ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(fab, View.SCALE_Y, 1f, 1.2f, 1f); scaleYAnimator.setDuration(duration); scaleYAnimator.setRepeatCount(1); scaleXAnimator.start(); scaleYAnimator.start(); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(scaleXAnimator).with(scaleYAnimator); animatorSet.start(); } }, 400); }