@OnClick(R.id.image_add_remove) public void onAddRemoveImageClick() { AnimatedVectorDrawable drawable = mIsAddState ? mRemoveToAddDrawable : mAddToRemoveDrawable; mAddRemoveImage.setImageDrawable(drawable); drawable.start(); mIsAddState = !mIsAddState; }
@OnClick(R.id.image_twitter_heart) public void onTwitterHeartImageClick() { AnimatedVectorDrawable drawable = mIsTwitterState ? mHeartToTwitterDrawable : mTwitterToHeartDrawable; mTwitterHeartImage.setImageDrawable(drawable); drawable.start(); mIsTwitterState = !mIsTwitterState; }
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; } }
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 onAnimationEnd(Drawable drawable) { avd.start(); } });
@Override public void run() { animatedVectorDrawable.start(); } });
/** * Launch the animation on the AnimatedVectorDrawable displayed by the imageView3 */ private void launchAnim3() { // llScreenRecorder.startRecording(); animatedVector3.start(); }
ImageView imageView = (ImageView) findViewById(R.id.image_view); AnimatedVectorDrawable animatedVectorDrawable = (AnimatedVectorDrawable) getDrawable(R.drawable.animated_vector); imageView.setImageDrawable(animatedVectorDrawable); animatedVectorDrawable.start();
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void anim3(View view) { ImageView imageView = (ImageView) view; AnimatedVectorDrawable tickToCross = (AnimatedVectorDrawable) getDrawable(R.drawable.fivestat_anim); imageView.setImageDrawable(tickToCross); if (tickToCross != null) { tickToCross.start(); } } }
@Override public void onClick(View v) { if (v.getId() == R.id.image_logo) { AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) getDrawable(R.drawable.avd); mLogoImage.setImageDrawable(drawable); drawable.start(); } } }
void setAnimated(boolean animated) { AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) imageView.getDrawable(); if (drawable == null) { return; } if (animated) { drawable.start(); } else { drawable.stop(); } } }
avd.setColorFilter(porterDuffColorFilter); mImageView.setImageDrawable(avd); avd.start(); } else { AnimatedVectorDrawableCompat avdc =
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private void startVectorAnimation(boolean isOpened) { int iconId = isOpened ? R.drawable.ic_menu_animated : R.drawable.ic_close_animated; AnimatedVectorDrawable menuIcon = (AnimatedVectorDrawable) ContextCompat.getDrawable(getContext(), iconId); setImageDrawable(menuIcon); menuIcon.start(); }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void anim2(View view) { ImageView imageView = (ImageView) view; AnimatedVectorDrawable tickToCross = (AnimatedVectorDrawable) getDrawable(R.drawable.heart_full_anim); AnimatedVectorDrawable crossToTick = (AnimatedVectorDrawable) getDrawable(R.drawable.heart_empty_anim); AnimatedVectorDrawable animDrawable = isTick2 ? crossToTick: tickToCross; imageView.setImageDrawable(animDrawable); if (animDrawable != null) { animDrawable.start(); } isTick2 = !isTick2; }
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public void anim1(View view) { ImageView imageView = (ImageView) view; AnimatedVectorDrawable tickToCross = (AnimatedVectorDrawable) getDrawable(R.drawable.path_tick2cross_anim); AnimatedVectorDrawable crossToTick = (AnimatedVectorDrawable) getDrawable(R.drawable.path_cross2tick_anim); AnimatedVectorDrawable animDrawable = isTick1 ? crossToTick: tickToCross; imageView.setImageDrawable(animDrawable); if (animDrawable != null) { animDrawable.start(); } isTick1 = !isTick1; }
@SuppressLint("NewApi") public void animatePencil(View view) { Drawable d = mBinding.icon.getDrawable(); if (Build.VERSION.SDK_INT >= 21 && d instanceof AnimatedVectorDrawable) { ((AnimatedVectorDrawable) d).start(); } else if (d instanceof AnimatedVectorDrawableCompat) { ((AnimatedVectorDrawableCompat) d).start(); } }
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; }
@SuppressWarnings("ConstantConditions") private void playAnimation(ImageView imageView, int res) { final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ResourceUtils.getInstance(getContext()).getDrawable(res); imageView.setImageDrawable(avd); //avd.forceAnimationOnUI(); avd.start(); // TODO: Figure out how to user an AVD animation callback instead, which doesn't // seem to be working right now... postDelayed(mAnimationDone, ANIMATION_DURATION); }
public void setExpanded(boolean expanded) { if (expanded == mExpanded) return; mExpanded = expanded; final int res = getDrawableResourceId(!mExpanded); // workaround to reset drawable //noinspection ConstantConditions final AnimatedVectorDrawable avd = (AnimatedVectorDrawable) mRes .getDrawable(res).getConstantState().newDrawable(); setImageDrawable(avd); avd.start(); setContentDescription(getContentDescription(expanded)); }