List of usage examples for android.graphics.drawable AnimatedVectorDrawable start
@Override public void start()
From source file:net.simno.klingar.ui.adapter.PlayingViewHolder.java
@Override void bindModel(@NonNull Track track) { super.bindModel(track); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(itemView.getContext(), R.drawable.equalizer);//www. j a va2s. c om avd.registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationEnd(Drawable drawable) { avd.start(); } }); avd.start(); title.setCompoundDrawablesWithIntrinsicBounds(avd, null, null, null); } }
From source file:com.google.android.apps.muzei.TutorialFragment.java
@Override public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) { view.findViewById(R.id.tutorial_icon_affordance).setOnClickListener(new View.OnClickListener() { @Override// w w w . j a va 2s. c o m public void onClick(View view) { FirebaseAnalytics.getInstance(getContext()).logEvent(FirebaseAnalytics.Event.TUTORIAL_COMPLETE, null); final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); sp.edit().putBoolean(PREF_SEEN_TUTORIAL, true).apply(); } }); if (savedInstanceState == null) { float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); View mainTextView = view.findViewById(R.id.tutorial_main_text); mainTextView.setAlpha(0); mainTextView.setTranslationY(-animateDistance / 5); View subTextView = view.findViewById(R.id.tutorial_sub_text); subTextView.setAlpha(0); subTextView.setTranslationY(-animateDistance / 5); final View affordanceView = view.findViewById(R.id.tutorial_icon_affordance); affordanceView.setAlpha(0); affordanceView.setTranslationY(animateDistance); View iconTextView = view.findViewById(R.id.tutorial_icon_text); iconTextView.setAlpha(0); iconTextView.setTranslationY(animateDistance); mAnimator = new AnimatorSet(); mAnimator.setStartDelay(500); mAnimator.setDuration(250); mAnimator.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f)); mAnimator.start(); mAnimator = new AnimatorSet(); mAnimator.setStartDelay(2000); // Bug in older versions where set.setInterpolator didn't work Interpolator interpolator = new OvershootInterpolator(); ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0); ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0); ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0); ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0); a1.setInterpolator(interpolator); a2.setInterpolator(interpolator); a3.setInterpolator(interpolator); a4.setInterpolator(interpolator); mAnimator.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f), ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (isAdded()) { ImageView emanateView = (ImageView) view.findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getContext().getTheme()); emanateView.setImageDrawable(avd); avd.start(); } } }); } mAnimator.start(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ImageView emanateView = (ImageView) view.findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getContext().getTheme()); emanateView.setImageDrawable(avd); avd.start(); } }
From source file:io.plaidapp.ui.PlayerSheet.java
private void showClose() { if (dismissState == DISMISS_CLOSE) return;// w w w . jav a 2 s . co m dismissState = DISMISS_CLOSE; final AnimatedVectorDrawable downToClose = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_down_to_close); close.setImageDrawable(downToClose); downToClose.start(); }
From source file:io.plaidapp.ui.PlayerSheet.java
private void showDown() { if (dismissState == DISMISS_DOWN) return;/*from w w w . java2 s .c o m*/ dismissState = DISMISS_DOWN; final AnimatedVectorDrawable closeToDown = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_close_to_down); close.setImageDrawable(closeToDown); closeToDown.start(); }
From source file:com.joaquimley.faboptions.FabOptions.java
private void close() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.faboptions_ic_close_animatable, null); mFab.setImageDrawable(drawable); drawable.start(); } else {/*from w ww . ja v a 2 s. c om*/ mFab.setImageResource(R.drawable.faboptions_ic_overflow); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionManager.beginDelayedTransition(this, new CloseMorphTransition(mButtonContainer)); // } else { // closeCompatAnimation(); } animateButtons(false); animateBackground(false); mIsOpen = false; }
From source file:com.joaquimley.faboptions.FabOptions.java
private void open() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.faboptions_ic_menu_animatable, null); mFab.setImageDrawable(drawable); drawable.start(); } else {/* w w w . j a v a 2s . com*/ mFab.setImageResource(R.drawable.faboptions_ic_close); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionManager.beginDelayedTransition(this, new OpenMorphTransition(mButtonContainer)); } animateBackground(true); animateButtons(true); // } else { // openCompatAnimation(); // } mIsOpen = true; }
From source file:us.phyxsi.gameshelf.ui.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_search); ButterKnife.bind(this); setupSearchView();//w ww.j a v a2 s. c o m auto = TransitionInflater.from(this).inflateTransition(R.transition.auto); dataManager = new SearchDataManager(this) { @Override public void onDataLoaded(List<? extends Boardgame> data) { if (data != null && data.size() > 0) { if (results.getVisibility() != View.VISIBLE) { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); results.setVisibility(View.VISIBLE); } adapter.addAndResort(data); } else { TransitionManager.beginDelayedTransition(container, auto); progress.setVisibility(View.GONE); setNoResultsVisibility(View.VISIBLE); } } }; adapter = new FeedAdapter(this, SearchActivity.this, dataManager, columns); results.setAdapter(adapter); GridLayoutManager layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); results.setLayoutManager(layoutManager); results.setHasFixedSize(true); // extract the search icon's location passed from the launching activity, minus 4dp to // compensate for different paddings in the views searchBackDistanceX = getIntent().getIntExtra(EXTRA_MENU_LEFT, 0) - (int) TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); searchIconCenterX = getIntent().getIntExtra(EXTRA_MENU_CENTER_X, 0); // translate icon to match the launching screen then animate back into position searchBackContainer.setTranslationX(searchBackDistanceX); searchBackContainer.animate().translationX(0f).setDuration(650L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.fast_out_slow_in)); // transform from search icon to back icon AnimatedVectorDrawable searchToBack = (AnimatedVectorDrawable) ContextCompat.getDrawable(this, R.drawable.avd_search_to_back); searchBack.setImageDrawable(searchToBack); searchToBack.start(); // for some reason the animation doesn't always finish (leaving a part arrow!?) so after // the animation set a static drawable. Also animation callbacks weren't added until API23 // so using post delayed :( // TODO fix properly!! searchBack.postDelayed(new Runnable() { @Override public void run() { searchBack.setImageDrawable( ContextCompat.getDrawable(SearchActivity.this, R.drawable.ic_arrow_back_padded)); } }, 600L); // fade in the other search chrome searchBackground.animate().alpha(1f).setDuration(300L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)); searchView.animate().alpha(1f).setStartDelay(400L).setDuration(400L) .setInterpolator(AnimationUtils.loadInterpolator(this, android.R.interpolator.linear_out_slow_in)) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { searchView.requestFocus(); ImeUtils.showIme(searchView); } }); // animate in a scrim over the content behind scrim.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { scrim.getViewTreeObserver().removeOnPreDrawListener(this); AnimatorSet showScrim = new AnimatorSet(); showScrim.playTogether( ViewAnimationUtils.createCircularReveal(scrim, searchIconCenterX, searchBackground.getBottom(), 0, (float) Math.hypot(searchBackDistanceX, scrim.getHeight() - searchBackground.getBottom())), ObjectAnimator.ofArgb(scrim, ViewUtils.BACKGROUND_COLOR, Color.TRANSPARENT, ContextCompat.getColor(SearchActivity.this, R.color.scrim))); showScrim.setDuration(400L); showScrim.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.linear_out_slow_in)); showScrim.start(); return false; } }); onNewIntent(getIntent()); }
From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java
private void startOpenAnimations() { // Icon//from w w w . ja va 2 s . co m // Animated Icons AnimatedVectorDrawable menuIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), R.drawable.ic_menu_animated); mFabView.setImageDrawable(menuIcon); menuIcon.start(); // Reveal int centerX = mFabRect.centerX(); int centerY = mFabRect.centerY(); float startRadius = getMinRadius(); float endRadius = getMaxRadius(); Animator reveal = ViewAnimationUtils.createCircularReveal(mNavigationView, centerX, centerY, startRadius, endRadius); // Fade in mNavigationMenuView.setAlpha(0); Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 0, 1); // Animations AnimatorSet set = new AnimatorSet(); set.playSequentially(reveal, fade); set.start(); }
From source file:com.andremion.floatingnavigationview.FloatingNavigationView.java
private void startCloseAnimations() { // Icon// w w w. j av a 2 s. c o m AnimatedVectorDrawable closeIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), R.drawable.ic_close_animated); mFabView.setImageDrawable(closeIcon); closeIcon.start(); // Unreveal int centerX = mFabRect.centerX(); int centerY = mFabRect.centerY(); float startRadius = getMaxRadius(); float endRadius = getMinRadius(); Animator reveal = ViewAnimationUtils.createCircularReveal(mNavigationView, centerX, centerY, startRadius, endRadius); reveal.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { detachNavigationView(); } }); // Fade out Animator fade = ObjectAnimator.ofFloat(mNavigationMenuView, View.ALPHA, 1, 0); // Animations AnimatorSet set = new AnimatorSet(); set.playTogether(fade, reveal); set.start(); }
From source file:com.hannesdorfmann.search.SearchActivity.java
@Override public void showError(@NotNull Throwable t) { castedViewState().setShowError(t); if (!isRestoringViewState()) { TransitionManager.beginDelayedTransition(container, auto); }// w ww. j a va2 s .c om progress.setVisibility(View.GONE); results.setVisibility(View.GONE); fab.setVisibility(View.GONE); errorView.setVisibility(View.VISIBLE); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) errorView.getDrawable(); avd.start(); }