@OnClick(R.id.image_add_remove) public void onAddRemoveImageClick() { AnimatedVectorDrawable drawable = mIsAddState ? mRemoveToAddDrawable : mAddToRemoveDrawable; mAddRemoveImage.setImageDrawable(drawable); drawable.start(); mIsAddState = !mIsAddState; }
public void morph() { AnimatedVectorDrawable prevDrawable = isShowingAndroid ? mightyMorphinAnimatedVectorDrawableReversed : mightyMorphinAnimatedVectorDrawable; if (prevDrawable.isRunning()) { prevDrawable.stop(); } AnimatedVectorDrawable currentDrawable = isShowingAndroid ? mightyMorphinAnimatedVectorDrawable : mightyMorphinAnimatedVectorDrawableReversed; animatorImageView.setImageDrawable(currentDrawable); currentDrawable.start(); isShowingAndroid = !isShowingAndroid; }
AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(activity, R.drawable.avd_spotlight_arc); avd.setColorFilter(porterDuffColorFilter); mImageView.setImageDrawable(avd); avd.start(); } else { AnimatedVectorDrawableCompat avdc =
avd.registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationEnd(Drawable drawable) { avd.start(); avd2.registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationEnd(Drawable drawable) {
@RequiresApi(api = Build.VERSION_CODES.M) private void initPuppet3() { ImageView imageView = (ImageView) findViewById(R.id.iv_puppet3); Drawable drawable = imageView.getDrawable(); if (drawable instanceof AnimatedVectorDrawable) { ((AnimatedVectorDrawable) drawable).registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationStart(Drawable drawable) { super.onAnimationStart(drawable); } @Override public void onAnimationEnd(Drawable drawable) { super.onAnimationEnd(drawable); ((AnimatedVectorDrawable) drawable).unregisterAnimationCallback(this); } }); imageView.setOnClickListener(this); } }
@Override public void onAnimationEnd(Drawable drawable) { super.onAnimationEnd(drawable); ((AnimatedVectorDrawable) drawable).unregisterAnimationCallback(this); } });
@RequiresApi(api = Build.VERSION_CODES.M) private void initPuppet3() { ImageView imageView = (ImageView) findViewById(R.id.iv_puppet3); Drawable drawable = imageView.getDrawable(); if (drawable instanceof AnimatedVectorDrawable) { ((AnimatedVectorDrawable) drawable).registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationStart(Drawable drawable) { super.onAnimationStart(drawable); } @Override public void onAnimationEnd(Drawable drawable) { super.onAnimationEnd(drawable); ((AnimatedVectorDrawable) drawable).unregisterAnimationCallback(this); } }); imageView.setOnClickListener(this); } }
@Override public void onAnimationEnd(Drawable drawable) { super.onAnimationEnd(drawable); ((AnimatedVectorDrawable) drawable).unregisterAnimationCallback(this); } });
@OnClick(R.id.image_twitter_heart) public void onTwitterHeartImageClick() { AnimatedVectorDrawable drawable = mIsTwitterState ? mHeartToTwitterDrawable : mTwitterToHeartDrawable; mTwitterHeartImage.setImageDrawable(drawable); drawable.start(); mIsTwitterState = !mIsTwitterState; }
@TargetApi(Build.VERSION_CODES.M) private void initUi() { initializeToolbar(); final AnimatedVectorDrawable avd2 = (AnimatedVectorDrawable) tvButton.getBackground(); tvButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { tvButton.setText("Loading..."); avd2.start(); } }); avd2.registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationEnd(Drawable drawable) { tvButton.setText("Try Again"); } }); }
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 = findViewById(R.id.stub_no_connection); noConnection = (ImageView) stub.inflate(); } 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; } }
avd2.registerAnimationCallback(new Animatable2.AnimationCallback() { @Override public void onAnimationEnd(Drawable drawable) {
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(); AnimatedVectorDrawable uploading = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_uploading); if (uploading != null) { fabPosting.setImageDrawable(uploading); uploading.start(); } }
@Override public void run() { animatedVectorDrawable.start(); } });
@Override public void onAnimationEnd(Drawable drawable) { avd.start(); } });
/** * Launch the animation on the AnimatedVectorDrawable displayed by the imageView3 */ private void launchAnim3() { // llScreenRecorder.startRecording(); animatedVector3.start(); }
AnimatedVectorDrawable d = (AnimatedVectorDrawable) getDrawable(R.drawable.animated_vector); // Insert your AnimatedVectorDrawable resource identifier mImageView.setImageDrawable(d); d.start();
ImageView imageView = (ImageView) findViewById(R.id.image_view); AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) getDrawable(R.drawable.animated_vector); imageView.setImageDrawable(animatedVectorDrawable); animatedVectorDrawable.start();