List of usage examples for android.view.animation AnimationUtils loadInterpolator
public static Interpolator loadInterpolator(Context context, @AnimRes @InterpolatorRes int id) throws NotFoundException
From source file:com.heinrichreimersoftware.materialintro.app.IntroActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pageScrollInterpolator = AnimationUtils.loadInterpolator(this, android.R.interpolator.accelerate_decelerate); pageScrollDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); if (savedInstanceState != null) { if (savedInstanceState.containsKey(KEY_CURRENT_ITEM)) { position = savedInstanceState.getInt(KEY_CURRENT_ITEM, position); }/*from w w w . j a v a2 s . c om*/ if (savedInstanceState.containsKey(KEY_FULLSCREEN)) { fullscreen = savedInstanceState.getBoolean(KEY_FULLSCREEN, fullscreen); } if (savedInstanceState.containsKey(KEY_BUTTON_CTA_VISIBLE)) { buttonCtaVisible = savedInstanceState.getBoolean(KEY_BUTTON_CTA_VISIBLE, buttonCtaVisible); } } if (fullscreen) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { setSystemUiFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, true); updateFullscreen(); } else { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } } getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); setContentView(R.layout.mi_activity_intro); initViews(); }
From source file:android.support.v7.app.MediaRouteControllerDialog.java
public MediaRouteControllerDialog(Context context, int theme) { super(MediaRouterThemeHelper.createThemedContext(context, theme), theme); mContext = getContext();/*from www. j a v a 2 s .c om*/ mControllerCallback = new MediaControllerCallback(); mRouter = MediaRouter.getInstance(mContext); mCallback = new MediaRouterCallback(); mRoute = mRouter.getSelectedRoute(); setMediaSession(mRouter.getMediaSessionToken()); mVolumeGroupListPaddingTop = mContext.getResources() .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_padding_top); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); if (android.os.Build.VERSION.SDK_INT >= 21) { mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_linear_out_slow_in); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_fast_out_slow_in); } mAccelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator(); }
From source file:com.google.samples.apps.iosched.ui.SearchActivity.java
/** * On Lollipop+ perform a circular animation (a contracting circular mask) when hiding the * search panel./*from ww w.j a v a2 s . c o m*/ */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) private void doExitAnim() { final View searchPanel = findViewById(R.id.search_panel); // Center the animation on the top right of the panel i.e. near to the search button which // launched this screen. The starting radius therefore is the diagonal distance from the top // right to the bottom left int revealRadius = (int) Math .sqrt(Math.pow(searchPanel.getWidth(), 2) + Math.pow(searchPanel.getHeight(), 2)); // Animating the radius to 0 produces the contracting effect Animator shrink = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(), searchPanel.getTop(), revealRadius, 0f); shrink.setDuration(200L); shrink.setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); shrink.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchPanel.setVisibility(View.INVISIBLE); ActivityCompat.finishAfterTransition(SearchActivity.this); } }); shrink.start(); // We also animate out the translucent background at the same time. findViewById(R.id.scrim).animate().alpha(0f).setDuration(200L).setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)) .start(); }
From source file:androidx.mediarouter.app.MediaRouteControllerDialog.java
public MediaRouteControllerDialog(Context context, int theme) { super(context = MediaRouterThemeHelper.createThemedDialogContext(context, theme, true), MediaRouterThemeHelper.createThemedDialogStyle(context)); mContext = getContext();//from w ww. jav a2 s . co m mControllerCallback = new MediaControllerCallback(); mRouter = MediaRouter.getInstance(mContext); mCallback = new MediaRouterCallback(); mRoute = mRouter.getSelectedRoute(); setMediaSession(mRouter.getMediaSessionToken()); mVolumeGroupListPaddingTop = mContext.getResources() .getDimensionPixelSize(R.dimen.mr_controller_volume_group_list_padding_top); mAccessibilityManager = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); if (android.os.Build.VERSION.SDK_INT >= 21) { mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_linear_out_slow_in); mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(context, R.interpolator.mr_fast_out_slow_in); } mAccelerateDecelerateInterpolator = new AccelerateDecelerateInterpolator(); }
From source file:com.givewaygames.transition.TransitionInflater.java
private Transition loadTransition(Transition transition, AttributeSet attrs) throws Resources.NotFoundException { TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.Transition); long duration = a.getInt(R.styleable.Transition_duration, -1); if (duration >= 0) { transition.setDuration(duration); }/*w ww .j av a 2 s . c o m*/ long startDelay = a.getInt(R.styleable.Transition_startDelay, -1); if (startDelay > 0) { transition.setStartDelay(startDelay); } final int resID = a.getResourceId(R.styleable.Transition_interpolator, 0); if (resID > 0) { transition.setInterpolator(AnimationUtils.loadInterpolator(mContext, resID)); } a.recycle(); return transition; }
From source file:com.hannesdorfmann.FeedAdapter.java
private void bindDesignerNewsStory(final Story story, final DesignerNewsStoryHolder holder) { holder.title.setText(story.title);//from ww w. j a v a 2 s . c o m holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CustomTabActivityHelper.openCustomTab(host, DesignerNewsStory.getCustomTabIntent(host, story, null).build(), Uri.parse(story.url)); } }); holder.comments.setText(String.valueOf(story.comment_count)); holder.comments.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View commentsView) { final Intent intent = new Intent(); intent.setClass(host, DesignerNewsStory.class); intent.putExtra(DesignerNewsStory.EXTRA_STORY, story); final ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(host, Pair.create(holder.itemView, host.getString(R.string.transition_story_title_background)), Pair.create(holder.itemView, host.getString(R.string.transition_story_background))); host.startActivity(intent, options.toBundle()); } }); if (pocketIsInstalled) { holder.pocket.setImageAlpha(178); // grumble... no xml setter, grumble... holder.pocket.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { final ImageButton pocketButton = (ImageButton) view; // actually add to pocket PocketUtils.addToPocket(host, story.url); // setup for anim holder.itemView.setHasTransientState(true); ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(false); final int initialLeft = pocketButton.getLeft(); final int initialTop = pocketButton.getTop(); final int translatedLeft = (holder.itemView.getWidth() - pocketButton.getWidth()) / 2; final int translatedTop = initialTop - ((holder.itemView.getHeight() - pocketButton.getHeight()) / 2); final ArcMotion arc = new ArcMotion(); // animate the title & pocket icon up, scale the pocket icon up PropertyValuesHolder pvhTitleUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, -(holder.itemView.getHeight() / 5)); PropertyValuesHolder pvhTitleFade = PropertyValuesHolder.ofFloat(View.ALPHA, 0.54f); Animator titleMoveFadeOut = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleUp, pvhTitleFade); Animator pocketMoveUp = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(initialLeft, initialTop, translatedLeft, translatedTop)); PropertyValuesHolder pvhPocketScaleUpX = PropertyValuesHolder.ofFloat(View.SCALE_X, 3f); PropertyValuesHolder pvhPocketScaleUpY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 3f); Animator pocketScaleUp = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleUpX, pvhPocketScaleUpY); ObjectAnimator pocketFadeUp = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 255); AnimatorSet up = new AnimatorSet(); up.playTogether(titleMoveFadeOut, pocketMoveUp, pocketScaleUp, pocketFadeUp); up.setDuration(300); up.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); // animate everything back into place PropertyValuesHolder pvhTitleMoveUp = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, 0f); PropertyValuesHolder pvhTitleFadeUp = PropertyValuesHolder.ofFloat(View.ALPHA, 1f); Animator titleMoveFadeIn = ObjectAnimator.ofPropertyValuesHolder(holder.title, pvhTitleMoveUp, pvhTitleFadeUp); Animator pocketMoveDown = ObjectAnimator.ofFloat(pocketButton, View.TRANSLATION_X, View.TRANSLATION_Y, arc.getPath(translatedLeft, translatedTop, 0, 0)); PropertyValuesHolder pvhPocketScaleDownX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f); PropertyValuesHolder pvhPocketScaleDownY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f); Animator pvhPocketScaleDown = ObjectAnimator.ofPropertyValuesHolder(pocketButton, pvhPocketScaleDownX, pvhPocketScaleDownY); ObjectAnimator pocketFadeDown = ObjectAnimator.ofInt(pocketButton, ViewUtils.IMAGE_ALPHA, 138); AnimatorSet down = new AnimatorSet(); down.playTogether(titleMoveFadeIn, pocketMoveDown, pvhPocketScaleDown, pocketFadeDown); down.setDuration(300); down.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); down.setStartDelay(500); // play it AnimatorSet upDown = new AnimatorSet(); upDown.playSequentially(up, down); // clean up upDown.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ((ViewGroup) pocketButton.getParent().getParent()).setClipChildren(true); holder.itemView.setHasTransientState(false); } }); upDown.start(); } }); } }
From source file:us.phyxsi.gameshelf.ui.FeedAdapter.java
private void bindBoardgameHolder(final Boardgame game, final BoardgameHolder holder) { final int[] imageSize = { 400, 400 }; Glide.with(host).load("http:" + game.image).listener(new RequestListener<String, GlideDrawable>() { @Override/*from w w w . j ava 2 s. co m*/ public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { if (!game.hasFadedIn) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator 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 :( if (holder.image.getDrawable() != null) { holder.image.getDrawable().setColorFilter(new ColorMatrixColorFilter(cm)); } } }); saturation.setDuration(1000); saturation.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.setHasTransientState(false); } }); saturation.start(); game.hasFadedIn = true; } return false; } @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[holder.getAdapterPosition() % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(imageSize[0], imageSize[1]) .into(new BoardgameTarget(holder.image, false)); }
From source file:devlight.io.library.ArcProgressStackView.java
public ArcProgressStackView(final Context context, final AttributeSet attrs, final int defStyleAttr) { super(context, attrs, defStyleAttr); // Init CPSV// ww w .j ava2 s. com // Always draw setWillNotDraw(false); setLayerType(LAYER_TYPE_SOFTWARE, null); ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null); // Detect if features available mIsFeaturesAvailable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB; // Retrieve attributes from xml final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ArcProgressStackView); try { setIsAnimated(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_animated, true)); setIsShadowed(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_shadowed, true)); setIsRounded(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_rounded, false)); setIsDragged(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_dragged, false)); setIsLeveled(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_leveled, false)); setTypeface(typedArray.getString(R.styleable.ArcProgressStackView_apsv_typeface)); setTextColor(typedArray.getColor(R.styleable.ArcProgressStackView_apsv_text_color, Color.WHITE)); setShadowRadius(typedArray.getDimension(R.styleable.ArcProgressStackView_apsv_shadow_radius, DEFAULT_SHADOW_RADIUS)); setShadowDistance(typedArray.getDimension(R.styleable.ArcProgressStackView_apsv_shadow_distance, DEFAULT_SHADOW_DISTANCE)); setShadowAngle(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_shadow_angle, (int) DEFAULT_SHADOW_ANGLE)); setShadowColor( typedArray.getColor(R.styleable.ArcProgressStackView_apsv_shadow_color, DEFAULT_SHADOW_COLOR)); setAnimationDuration(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_animation_duration, DEFAULT_ANIMATION_DURATION)); setStartAngle(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_start_angle, (int) DEFAULT_START_ANGLE)); setSweepAngle(typedArray.getInteger(R.styleable.ArcProgressStackView_apsv_sweep_angle, (int) DEFAULT_SWEEP_ANGLE)); setProgressModelOffset(typedArray.getDimension(R.styleable.ArcProgressStackView_apsv_model_offset, DEFAULT_MODEL_OFFSET)); setModelBgEnabled(typedArray.getBoolean(R.styleable.ArcProgressStackView_apsv_model_bg_enabled, false)); // Set orientation final int orientationOrdinal = typedArray .getInt(R.styleable.ArcProgressStackView_apsv_indicator_orientation, 0); setIndicatorOrientation( orientationOrdinal == 0 ? IndicatorOrientation.VERTICAL : IndicatorOrientation.HORIZONTAL); // Retrieve interpolator Interpolator interpolator = null; try { final int interpolatorId = typedArray .getResourceId(R.styleable.ArcProgressStackView_apsv_interpolator, 0); interpolator = interpolatorId == 0 ? null : AnimationUtils.loadInterpolator(context, interpolatorId); } catch (Resources.NotFoundException exception) { interpolator = null; exception.printStackTrace(); } finally { setInterpolator(interpolator); } // Set animation info if is available if (mIsFeaturesAvailable) { mProgressAnimator.setFloatValues(MIN_FRACTION, MAX_FRACTION); mProgressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(final ValueAnimator animation) { mAnimatedFraction = (float) animation.getAnimatedValue(); if (mAnimatorUpdateListener != null) mAnimatorUpdateListener.onAnimationUpdate(animation); postInvalidate(); } }); } // Check whether draw width dimension or fraction if (typedArray.hasValue(R.styleable.ArcProgressStackView_apsv_draw_width)) { final TypedValue drawWidth = new TypedValue(); typedArray.getValue(R.styleable.ArcProgressStackView_apsv_draw_width, drawWidth); if (drawWidth.type == TypedValue.TYPE_DIMENSION) setDrawWidthDimension(drawWidth.getDimension(context.getResources().getDisplayMetrics())); else setDrawWidthFraction(drawWidth.getFraction(MAX_FRACTION, MAX_FRACTION)); } else setDrawWidthFraction(DEFAULT_DRAW_WIDTH_FRACTION); // Set preview models if (isInEditMode()) { String[] preview = null; try { final int previewId = typedArray .getResourceId(R.styleable.ArcProgressStackView_apsv_preview_colors, 0); preview = previewId == 0 ? null : typedArray.getResources().getStringArray(previewId); } catch (Exception exception) { preview = null; exception.printStackTrace(); } finally { if (preview == null) preview = typedArray.getResources().getStringArray(R.array.default_preview); final Random random = new Random(); for (String previewColor : preview) mModels.add( new Model("", random.nextInt((int) MAX_PROGRESS), Color.parseColor(previewColor))); measure(mSize, mSize); } // Set preview model bg color mPreviewModelBgColor = typedArray.getColor(R.styleable.ArcProgressStackView_apsv_preview_bg, Color.LTGRAY); } } finally { typedArray.recycle(); } }
From source file:com.hannesdorfmann.search.SearchActivity.java
@OnClick({ R.id.scrim, R.id.searchback }) protected void dismiss() { // translate the icon to match position in the launching activity searchBackContainer.animate().translationX(searchBackDistanceX).setDuration(600L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override//from ww w. j av a 2 s . com public void onAnimationEnd(Animator animation) { finishAfterTransition(); } }).start(); // transform from back icon to search icon AnimatedVectorDrawable backToSearch = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_back_to_search); searchBack.setImageDrawable(backToSearch); // clear the background else the touch ripple moves with the translation which looks bad searchBack.setBackground(null); backToSearch.start(); // fade out the other search chrome searchView.animate().alpha(0f).setStartDelay(0L).setDuration(120L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in)) .setListener(null).start(); searchBackground.animate().alpha(0f).setStartDelay(300L).setDuration(160L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in)) .setListener(null).start(); if (searchToolbar.getZ() != 0f) { searchToolbar.animate().z(0f).setDuration(600L) .setInterpolator( AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in)) .start(); } // if we're showing search results, circular hide them if (resultsContainer.getHeight() > 0) { Animator closeResults = ViewAnimationUtils.createCircularReveal(resultsContainer, searchIconCenterX, 0, (float) Math.hypot(searchIconCenterX, resultsContainer.getHeight()), 0f); closeResults.setDuration(500L); closeResults.setInterpolator( AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)); closeResults.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { resultsContainer.setVisibility(View.INVISIBLE); } }); closeResults.start(); } // fade out the scrim scrim.animate().alpha(0f).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_linear_in)) .setListener(null).start(); }
From source file:com.hannesdorfmann.home.HomeActivity.java
private void animateToolbar() { // this is gross but toolbar doesn't expose it's children to animate them :( View t = toolbar.getChildAt(0); if (t != null && t instanceof TextView) { TextView title = (TextView) t;// w w w . j a v a 2 s .com // fade in and space out the title. Animating the letterSpacing performs horribly so // fake it by setting the desired letterSpacing then animating the scaleX \_()_/ title.setAlpha(0f); title.setScaleX(0.8f); title.animate().alpha(1f).scaleX(1f).setStartDelay(300).setDuration(900).setInterpolator( AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); } View amv = toolbar.getChildAt(1); if (amv != null & amv instanceof ActionMenuView) { ActionMenuView actions = (ActionMenuView) amv; popAnim(actions.getChildAt(0), 500, 200); // filter popAnim(actions.getChildAt(1), 700, 200); // overflow } }