Java Code Examples for android.animation.ObjectAnimator#ofInt()
The following examples show how to use
android.animation.ObjectAnimator#ofInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationUtility.java From iBeebo with GNU General Public License v3.0 | 6 votes |
public static void translateFragmentY(UserInfoFragment fragment, int from, int to, Animator.AnimatorListener animatorListener) { final View fragmentView = fragment.getView(); if (fragmentView == null) { return; } View view = fragment.header; FragmentViewYWrapper wrapper = new FragmentViewYWrapper(fragmentView); ObjectAnimator objectAnimator = ObjectAnimator.ofInt(wrapper, "change", from, to); objectAnimator.setDuration(300); objectAnimator.setInterpolator(new DecelerateInterpolator()); if (animatorListener != null) { objectAnimator.addListener(new LayerEnablingAnimatorListener(view, animatorListener)); } objectAnimator.start(); }
Example 2
Source File: ChangeScroll.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
@Override public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) { if (startValues == null || endValues == null) { return null; } final View view = endValues.view; int startX = (Integer) startValues.values.get(PROPNAME_SCROLL_X); int endX = (Integer) endValues.values.get(PROPNAME_SCROLL_X); int startY = (Integer) startValues.values.get(PROPNAME_SCROLL_Y); int endY = (Integer) endValues.values.get(PROPNAME_SCROLL_Y); Animator scrollXAnimator = null; Animator scrollYAnimator = null; if (startX != endX) { view.setScrollX(startX); scrollXAnimator = ObjectAnimator.ofInt(view, "scrollX", startX, endX); } if (startY != endY) { view.setScrollY(startY); scrollYAnimator = ObjectAnimator.ofInt(view, "scrollY", startY, endY); } return TransitionUtils.mergeAnimators(scrollXAnimator, scrollYAnimator); }
Example 3
Source File: VoIPActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void showRetry() { if (retryAnim != null) retryAnim.cancel(); endBtn.setEnabled(false); retrying = true; cancelBtn.setVisibility(View.VISIBLE); cancelBtn.setAlpha(0); AnimatorSet set = new AnimatorSet(); ObjectAnimator colorAnim; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); } else { colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d); colorAnim.setEvaluator(new ArgbEvaluator()); } set.playTogether( ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0, 1), ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0, content.getWidth() / 2 - AndroidUtilities.dp(52) - endBtn.getWidth() / 2), colorAnim, ObjectAnimator.ofFloat(endBtnIcon, View.ROTATION, 0, -135)//, //ObjectAnimator.ofFloat(spkToggle, View.ALPHA, 0), //ObjectAnimator.ofFloat(micToggle, View.ALPHA, 0), //ObjectAnimator.ofFloat(chatBtn, View.ALPHA, 0) ); set.setStartDelay(200); set.setDuration(300); set.setInterpolator(CubicBezierInterpolator.DEFAULT); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //bottomButtons.setVisibility(View.GONE); retryAnim = null; endBtn.setEnabled(true); } }); retryAnim = set; set.start(); }
Example 4
Source File: BaseActivityWithPopWindow.java From Android_framework with BSD 2-Clause "Simplified" License | 5 votes |
/** * 执行反向动画将其隐藏 */ private void doReverseAnimation(){ if (Build.VERSION.SDK_INT < 11) { sv_bottom_content.setVisibility(View.GONE); ll_full_screen.setVisibility(View.GONE); }else{ //如果弹出动画还在执行,则直接将弹出动画的值置为最终值,代表该动画结束,接着直接进行收进动画 popAnimation.end(); //避免用户连续快速点击造成短时间内执行两次收进动画,此处进行判断 if (reverseAnimation != null && reverseAnimation.isRunning()){ return; } if (reverseAnimation == null) { reverseAnimation = ObjectAnimator.ofInt(sv_bottom_content, "bottomMargin", 0, -scrollViewMeasureHeight); reverseAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int value = (Integer) animation.getAnimatedValue(); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) sv_bottom_content.getLayoutParams(); params.bottomMargin = value; sv_bottom_content.setLayoutParams(params); ((View) (sv_bottom_content.getParent())).invalidate(); if (value <= -scrollViewMeasureHeight){ sv_bottom_content.setVisibility(View.GONE); } ll_full_screen.setAlpha((float) (((scrollViewMeasureHeight + value) * 1.0) / (scrollViewMeasureHeight * 1.0))); if (ll_full_screen.getAlpha()<=0){ ll_full_screen.setVisibility(View.GONE); } } }); reverseAnimation.setDuration(500); } reverseAnimation.start(); } }
Example 5
Source File: ViewUtil.java From Music-Player with GNU General Public License v3.0 | 5 votes |
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) { ObjectAnimator animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor); } else { animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor); animator.setEvaluator(new ArgbEvaluator()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f)); } animator.setDuration(MUSIC_ANIM_TIME); return animator; }
Example 6
Source File: MaterialRippleLayout.java From material-ripple with Apache License 2.0 | 5 votes |
private void startRipple(final Runnable animationEndRunnable) { if (eventCancelled) return; float endRadius = getEndRadius(); cancelAnimations(); rippleAnimator = new AnimatorSet(); rippleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!ripplePersistent) { setRadius(0); setRippleAlpha(rippleAlpha); } if (animationEndRunnable != null && rippleDelayClick) { animationEndRunnable.run(); } childView.setPressed(false); } }); ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius); ripple.setDuration(rippleDuration); ripple.setInterpolator(new DecelerateInterpolator()); ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0); fade.setDuration(rippleFadeDuration); fade.setInterpolator(new AccelerateInterpolator()); fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY); if (ripplePersistent) { rippleAnimator.play(ripple); } else if (getRadius() > endRadius) { fade.setStartDelay(0); rippleAnimator.play(fade); } else { rippleAnimator.playTogether(ripple, fade); } rippleAnimator.start(); }
Example 7
Source File: PaymentRequestUI.java From delion with Apache License 2.0 | 5 votes |
@Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { mRequestView.removeOnLayoutChangeListener(this); Animator scrimFader = ObjectAnimator.ofInt(mFullContainer.getBackground(), AnimatorProperties.DRAWABLE_ALPHA_PROPERTY, 0, 127); Animator alphaAnimator = ObjectAnimator.ofFloat(mFullContainer, View.ALPHA, 0f, 1f); AnimatorSet alphaSet = new AnimatorSet(); alphaSet.playTogether(scrimFader, alphaAnimator); alphaSet.setDuration(DIALOG_ENTER_ANIMATION_MS); alphaSet.setInterpolator(new LinearOutSlowInInterpolator()); alphaSet.start(); }
Example 8
Source File: MainActivity.java From APKMirror with GNU General Public License v2.0 | 5 votes |
@Override public void onProgressChanged(WebView view, int progress) { //update the progressbar value ObjectAnimator animation = ObjectAnimator.ofInt(progressBar, "progress", progress); animation.setDuration(100); // 0.5 second animation.setInterpolator(new DecelerateInterpolator()); animation.start(); }
Example 9
Source File: FullPlaybackControlsFragment.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
@Override public void onUpdateProgressViews(int progress, int total) { progressSlider.setMax(total); ObjectAnimator animator = ObjectAnimator.ofInt(progressSlider, "progress", progress); animator.setDuration(1500); animator.setInterpolator(new LinearInterpolator()); animator.start(); mPlayerSongCurrentProgress.setText(MusicUtil.getReadableDurationString(progress)); mSongTotalTime.setText(MusicUtil.getReadableDurationString(total)); }
Example 10
Source File: VoIPActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@SuppressLint("ObjectAnimatorBinding") private ObjectAnimator createAlphaAnimator(Object target, int startVal, int endVal, int startDelay, int duration) { ObjectAnimator a = ObjectAnimator.ofInt(target, "alpha", startVal, endVal); a.setDuration(duration); a.setStartDelay(startDelay); a.setInterpolator(CubicBezierInterpolator.DEFAULT); return a; }
Example 11
Source File: AnimationUtility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void translateFragmentX(Fragment fragment, int from, int to) { final View fragmentView = fragment.getView(); if (fragmentView == null) { return; } FragmentViewXWrapper wrapper = new FragmentViewXWrapper(fragmentView); ObjectAnimator objectAnimator = ObjectAnimator.ofInt(wrapper, "change", from, to); objectAnimator.setDuration(300); objectAnimator.setInterpolator(new DecelerateInterpolator()); objectAnimator.start(); }
Example 12
Source File: TextColorAnimExpectation.java From ExpectAnim with Apache License 2.0 | 5 votes |
@Override public Animator getAnimator(View viewToMove) { if (viewToMove instanceof TextView) { final ObjectAnimator objectAnimator = ObjectAnimator.ofInt(viewToMove, "textColor", ((TextView) viewToMove).getCurrentTextColor(), textColor); objectAnimator.setEvaluator(new ArgbEvaluator()); return objectAnimator; } else { return null; } }
Example 13
Source File: AnimationBuilder.java From ViewAnimator with Apache License 2.0 | 5 votes |
public AnimationBuilder textColor(int... colors) { for (View view : views) { if (view instanceof TextView) { TextView textView = (TextView) view; ObjectAnimator objectAnimator = ObjectAnimator.ofInt(textView, "textColor", colors); objectAnimator.setEvaluator(new ArgbEvaluator()); this.animatorList.add(objectAnimator); } } return this; }
Example 14
Source File: DoubleWavesShaderView.java From WavesView with MIT License | 5 votes |
public void startWaveAnim() { if (animator != null) animator.end(); animator = ObjectAnimator.ofInt(this, "wavePos", 0, 1920); animator.setInterpolator(new LinearInterpolator()); animator.setDuration(durMillis); animator.setRepeatMode(ValueAnimator.RESTART); animator.setRepeatCount(ValueAnimator.INFINITE); animator.start(); }
Example 15
Source File: RippleLayout.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
private void startRipple(final Runnable animationEndRunnable) { if (eventCancelled) return; float endRadius = getEndRadius(); cancelAnimations(); rippleAnimator = new AnimatorSet(); rippleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!ripplePersistent) { setRadius(0); setRippleAlpha(rippleAlpha); } if (animationEndRunnable != null && rippleDelayClick) { animationEndRunnable.run(); } childView.setPressed(false); } }); ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius); ripple.setDuration(rippleDuration); ripple.setInterpolator(new DecelerateInterpolator()); ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0); fade.setDuration(rippleFadeDuration); fade.setInterpolator(new AccelerateInterpolator()); fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY); if (ripplePersistent) { rippleAnimator.play(ripple); } else if (getRadius() > endRadius) { fade.setStartDelay(0); rippleAnimator.play(fade); } else { rippleAnimator.playTogether(ripple, fade); } rippleAnimator.start(); }
Example 16
Source File: MaterialRippleLayout.java From KickAssSlidingMenu with Apache License 2.0 | 5 votes |
@TargetApi(14) private void startRipple(final Runnable animationEndRunnable) { if (eventCancelled) return; float endRadius = getEndRadius(); cancelAnimations(); rippleAnimator = new AnimatorSet(); rippleAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!ripplePersistent) { setRadius(0); setRippleAlpha(rippleAlpha); } if (animationEndRunnable != null && rippleDelayClick) { animationEndRunnable.run(); } childView.setPressed(false); } }); ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty(), radius, endRadius); ripple.setDuration(rippleDuration); ripple.setInterpolator(new DecelerateInterpolator()); ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty(), rippleAlpha, 0); fade.setDuration(rippleFadeDuration); fade.setInterpolator(new AccelerateInterpolator()); fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY); if (ripplePersistent) { rippleAnimator.play(ripple); } else if (getRadius() > endRadius) { fade.setStartDelay(0); rippleAnimator.play(fade); } else { rippleAnimator.playTogether(ripple, fade); } rippleAnimator.start(); }
Example 17
Source File: ViewUtil.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) { ObjectAnimator animator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor); } else { animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor); animator.setEvaluator(new ArgbEvaluator()); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f)); } animator.setDuration(PHONOGRAPH_ANIM_TIME); return animator; }
Example 18
Source File: AnimationSVGImageViewSampleActivity.java From SVG-Android with Apache License 2.0 | 4 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animation_svg_imageview_sample); setTitle(getIntent().getStringExtra("title")); final SVGImageView imageView1 = (SVGImageView) findViewById(R.id.animation_svgimageview_image1); ObjectAnimator animatorRotation = ObjectAnimator.ofFloat(imageView1, "svgRotation", 0, 360); animatorRotation.setDuration(2000); animatorRotation.setRepeatCount(ValueAnimator.INFINITE); animatorRotation.setInterpolator(new LinearInterpolator()); animatorRotation.start(); SVGImageView imageView2 = (SVGImageView) findViewById(R.id.animation_svgimageview_image2); ObjectAnimator animatorAlpha = ObjectAnimator.ofFloat(imageView2, "svgAlpha", 0, 1); animatorAlpha.setDuration(4000); animatorAlpha.setRepeatCount(ValueAnimator.INFINITE); animatorAlpha.setRepeatMode(ValueAnimator.REVERSE); animatorAlpha.setInterpolator(new LinearInterpolator()); animatorAlpha.start(); final SVGImageView imageView3 = (SVGImageView) findViewById(R.id.animation_svgimageview_image3); ObjectAnimator animatorWidth = ObjectAnimator.ofInt(imageView3, "svgWidth", 50, 150); animatorWidth.setDuration(2000); animatorWidth.setInterpolator(new LinearInterpolator()); animatorWidth.setRepeatCount(ValueAnimator.INFINITE); animatorWidth.setRepeatMode(ValueAnimator.REVERSE); animatorWidth.start(); animatorWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // There is a bug in ImageView(ImageButton), in this case, we must call requestLayout() here. imageView3.requestLayout(); } }); SVGImageView imageView4 = (SVGImageView) findViewById(R.id.animation_svgimageview_image4); ObjectAnimator animatorColor = ObjectAnimator.ofInt(imageView4, "svgColor", Color.BLACK, Color.BLUE); animatorColor.setDuration(2000); animatorColor.setRepeatCount(ValueAnimator.INFINITE); animatorColor.setRepeatMode(ValueAnimator.REVERSE); animatorColor.setInterpolator(new LinearInterpolator()); animatorColor.start(); }
Example 19
Source File: MainActivity.java From trekarta with GNU General Public License v3.0 | 4 votes |
@Override public void onFeatureDetails(long id, boolean fromList) { Bundle args = new Bundle(3); //args.putBoolean(AmenityInformation.ARG_DETAILS, fromList); if (fromList || mLocationState != LocationState.DISABLED) { if (mLocationState != LocationState.DISABLED && mLocationService != null) { Location location = mLocationService.getLocation(); args.putDouble(AmenityInformation.ARG_LATITUDE, location.getLatitude()); args.putDouble(AmenityInformation.ARG_LONGITUDE, location.getLongitude()); } else { MapPosition position = mMap.getMapPosition(); args.putDouble(AmenityInformation.ARG_LATITUDE, position.getLatitude()); args.putDouble(AmenityInformation.ARG_LONGITUDE, position.getLongitude()); } } Fragment fragment = mFragmentManager.findFragmentByTag("waypointInformation"); if (fragment != null) { mFragmentManager.popBackStack("waypointInformation", FragmentManager.POP_BACK_STACK_INCLUSIVE); } fragment = mFragmentManager.findFragmentByTag("amenityInformation"); if (fragment == null) { fragment = Fragment.instantiate(this, AmenityInformation.class.getName(), args); Slide slide = new Slide(Gravity.BOTTOM); // Required to sync with FloatingActionButton slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime)); fragment.setEnterTransition(slide); FragmentTransaction ft = mFragmentManager.beginTransaction(); ft.replace(R.id.bottomSheetPanel, fragment, "amenityInformation"); ft.addToBackStack("amenityInformation"); ft.commit(); updateMapViewArea(); } ((AmenityInformation) fragment).setPreferredLanguage(Configuration.getLanguage()); ((AmenityInformation) fragment).setAmenity(id); mViews.extendPanel.setForeground(getDrawable(R.drawable.dim)); mViews.extendPanel.getForeground().setAlpha(0); ObjectAnimator anim = ObjectAnimator.ofInt(mViews.extendPanel.getForeground(), "alpha", 0, 255); anim.setDuration(500); anim.start(); }
Example 20
Source File: AnimatorUtils.java From NBAPlus with Apache License 2.0 | 3 votes |
/** * 移动ScrollView的x轴 * * @param view 要移动的ScrollView * @param toX 要移动到的X轴坐标 * @param time 动画持续时间 * @param delayTime 延迟开始动画的时间 * @param isStart 是否开始动画 * @return */ public static Animator moveScrollViewToX(View view, int toX, int time, int delayTime, boolean isStart) { ObjectAnimator objectAnimator = ObjectAnimator.ofInt(view, "scrollX", new int[]{toX}); objectAnimator.setDuration(time); objectAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); objectAnimator.setStartDelay(delayTime); if (isStart) objectAnimator.start(); return objectAnimator; }