List of usage examples for android.graphics.drawable AnimatedVectorDrawable start
@Override public void start()
From source file:io.plaidapp.ui.HomeActivity.java
void revealPostingProgress() { Animator reveal = ViewAnimationUtils.createCircularReveal(fabPosting, (int) fabPosting.getPivotX(), (int) fabPosting.getPivotY(), 0f, fabPosting.getWidth() / 2).setDuration(600L); reveal.setInterpolator(AnimUtils.getFastOutLinearInInterpolator(this)); reveal.start();/* w w w . j ava 2 s . c o m*/ AnimatedVectorDrawable uploading = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading); if (uploading != null) { fabPosting.setImageDrawable(uploading); uploading.start(); } }
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 w w w . j av a 2 s . c o m 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:babbq.com.searchplace.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 . jav a 2 s . c om*/ 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:io.plaidapp.ui.HomeActivity.java
private void checkConnectivity() { final ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE); final NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo(); connected = activeNetworkInfo != null && activeNetworkInfo.isConnected(); if (!connected) { loading.setVisibility(View.GONE); if (noConnection == null) { final ViewStub stub = (ViewStub) findViewById(R.id.stub_no_connection); noConnection = (ImageView) stub.inflate(); }/* www. j ava2 s .com*/ final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_no_connection); if (noConnection != null && avd != null) { noConnection.setImageDrawable(avd); avd.start(); } connectivityManager.registerNetworkCallback( new NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET).build(), connectivityCallback); monitoringConnectivity = true; } }
From source file:com.google.android.apps.muzei.MuzeiActivity.java
private void updateUiMode() { // TODO: this should really just use fragment transactions and transitions int newUiMode = UI_MODE_INTRO; if (mWallpaperActive) { newUiMode = UI_MODE_TUTORIAL;// w w w . j a va 2 s . c o m if (mSeenTutorial) { newUiMode = UI_MODE_ART_DETAIL; } } if (mUiMode == newUiMode) { return; } // Crossfade between main containers final View oldContainerView = getMainContainerForUiMode(mUiMode); final View newContainerView = getMainContainerForUiMode(newUiMode); if (oldContainerView != null) { oldContainerView.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() { @Override public void run() { oldContainerView.setVisibility(View.GONE); } }); } if (newContainerView != null) { if (newContainerView.getAlpha() == 1) { newContainerView.setAlpha(0); } newContainerView.setVisibility(View.VISIBLE); newContainerView.animate().alpha(1).setDuration(1000).withEndAction(null); } // Special work if (newUiMode == UI_MODE_INTRO) { final View activateButton = findViewById(R.id.activate_muzei_button); activateButton.setAlpha(0); final AnimatedMuzeiLogoFragment logoFragment = (AnimatedMuzeiLogoFragment) getFragmentManager() .findFragmentById(R.id.animated_logo_fragment); logoFragment.reset(); logoFragment.setOnFillStartedCallback(new Runnable() { @Override public void run() { activateButton.animate().alpha(1f).setDuration(500); } }); mHandler.postDelayed(new Runnable() { @Override public void run() { logoFragment.start(); } }, 1000); } if (mUiMode == UI_MODE_INTRO || newUiMode == UI_MODE_INTRO) { FragmentManager fm = getSupportFragmentManager(); Fragment demoFragment = fm.findFragmentById(R.id.demo_view_container); if (newUiMode == UI_MODE_INTRO && demoFragment == null) { fm.beginTransaction() .add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, true)).commit(); } else if (newUiMode != UI_MODE_INTRO && demoFragment != null) { fm.beginTransaction().remove(demoFragment).commit(); } } if (newUiMode == UI_MODE_TUTORIAL) { float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics()); View mainTextView = findViewById(R.id.tutorial_main_text); mainTextView.setAlpha(0); mainTextView.setTranslationY(-animateDistance / 5); View subTextView = findViewById(R.id.tutorial_sub_text); subTextView.setAlpha(0); subTextView.setTranslationY(-animateDistance / 5); final View affordanceView = findViewById(R.id.tutorial_icon_affordance); affordanceView.setAlpha(0); affordanceView.setTranslationY(animateDistance); View iconTextView = findViewById(R.id.tutorial_icon_text); iconTextView.setAlpha(0); iconTextView.setTranslationY(animateDistance); AnimatorSet set = new AnimatorSet(); set.setStartDelay(500); set.setDuration(250); set.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f)); set.start(); set = new AnimatorSet(); set.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); set.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) { set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { ImageView emanateView = (ImageView) findViewById(R.id.tutorial_icon_emanate); AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources() .getDrawable(R.drawable.avd_tutorial_icon_emanate, getTheme()); emanateView.setImageDrawable(avd); avd.start(); } }); } set.start(); } mPanScaleProxyView.setVisibility(newUiMode == UI_MODE_ART_DETAIL ? View.VISIBLE : View.GONE); mUiMode = newUiMode; maybeUpdateArtDetailOpenedClosed(); }