Java Code Examples for android.support.graphics.drawable.AnimatedVectorDrawableCompat#create()
The following examples show how to use
android.support.graphics.drawable.AnimatedVectorDrawableCompat#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FingerprintIconView.java From BiometricPromptCompat with Apache License 2.0 | 6 votes |
public void setState(State state, boolean animate) { if (state == this.state) return; @DrawableRes int resId = getDrawable(this.state, state, animate); if (resId == 0) { setImageDrawable(null); } else { Drawable icon = null; if (animate) { icon = AnimatedVectorDrawableCompat.create(getContext(), resId); } if (icon == null) { icon = VectorDrawableCompat.create(getResources(), resId, getContext().getTheme()); } setImageDrawable(icon); if (icon instanceof Animatable) { ((Animatable) icon).start(); } } this.state = state; }
Example 2
Source File: AnimationHelper.java From ListItemView with Apache License 2.0 | 6 votes |
public void toggleCheckBoxMenu(ListItemView listItemView, boolean toggle) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = listItemView.isChecked() ? AnimatedVectorDrawableCompat .create(mContext, R.drawable.avd_checkbox_checked_to_unchecked) : AnimatedVectorDrawableCompat .create(mContext, R.drawable.avd_checkbox_unchecked_to_checked); ImageView imageView = (ImageView) listItemView.findMenuItem(R.id.action_checkable).getActionView(); imageView.setImageDrawable(drawable); ((Animatable) drawable).start(); } if (toggle) { listItemView.toggle(); } }
Example 3
Source File: MainActivity.java From journaldev with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); FloatingActionButton fabSync = findViewById(R.id.fabSync); FloatingActionButton fabTickCross = findViewById(R.id.fabTickCross); tickToCross = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_tick2cross); crossToTick = (AnimatedVectorDrawable) getDrawable(R.drawable.avd_cross2tick); ImageView imgSettings = findViewById(R.id.imgSettings); ImageView imgJD = findViewById(R.id.imgJD); imgSettings.setOnClickListener(this); imgJD.setOnClickListener(this); AnimatedVectorDrawableCompat animatedVectorDrawableCompat = AnimatedVectorDrawableCompat.create(this, R.drawable.avd_sync); fabSync.setImageDrawable(animatedVectorDrawableCompat); fabSync.setOnClickListener(this); fabTickCross.setOnClickListener(this); }
Example 4
Source File: MorphView.java From MorphView with Apache License 2.0 | 5 votes |
private void init(Context context, AttributeSet attrs) { if (isInEditMode()) { setImageResource(android.R.drawable.ic_media_play); return; } TypedArray a = context.getTheme().obtainStyledAttributes( attrs, R.styleable.MorphView, 0, 0); @DrawableRes int avdFromRes; @DrawableRes int avdToRes; try { avdFromRes = a.getResourceId(R.styleable.MorphView_avdFirst, -1); avdToRes = a.getResourceId(R.styleable.MorphView_avdSecond, -1); } finally { a.recycle(); } showingAvdFirst = true; avdFirstToSecond = AnimatedVectorDrawableCompat.create(getContext(), avdFromRes); avdSecondToFirst = AnimatedVectorDrawableCompat.create(getContext(), avdToRes); if (avdSecondToFirst == null || avdFirstToSecond == null) { throw new RuntimeException("Drawable is not a valid AnimatedVectorDrawable"); } else { setImageDrawable(avdFirstToSecond); } }
Example 5
Source File: AnimationHelper.java From ListItemView with Apache License 2.0 | 5 votes |
public void setRadioButtonState(ListItemView listItemView, boolean checked) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && listItemView.isChecked() != checked) { Drawable drawable = checked ? AnimatedVectorDrawableCompat .create(mContext, R.drawable.avd_radiobutton_unchecked_to_checked) : AnimatedVectorDrawableCompat .create(mContext, R.drawable.avd_radiobutton_checked_to_unchecked); listItemView.setIconDrawable(drawable); ((Animatable) drawable).start(); } listItemView.setChecked(checked); }
Example 6
Source File: AnimationHelper.java From ListItemView with Apache License 2.0 | 5 votes |
public void toggleCheckBox(ListItemView listItemView, boolean toggle) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = listItemView.isChecked() ? AnimatedVectorDrawableCompat .create(mContext, R.drawable.avd_checkbox_checked_to_unchecked) : AnimatedVectorDrawableCompat .create(mContext, R.drawable.avd_checkbox_unchecked_to_checked); listItemView.setIconDrawable(drawable); ((Animatable) drawable).start(); } if (toggle) { listItemView.toggle(); } }
Example 7
Source File: FavoriteToSendMorphView.java From MorphView with Apache License 2.0 | 4 votes |
private void init() { showingFavorite = true; favoriteToSend = AnimatedVectorDrawableCompat.create(getContext(), R.drawable.avd_favorite_to_send); sendToFavorite = AnimatedVectorDrawableCompat.create(getContext(), R.drawable.avd_send_to_favorite); setImageDrawable(favoriteToSend); }
Example 8
Source File: CustomAnimatedDrawable.java From RoundButton with MIT License | 4 votes |
@Override public void setupAnimations() { animateDrawable = AnimatedVectorDrawableCompat.create(view.getContext(), resource); DrawableCompat.setTint(animateDrawable, color); animateDrawable.setBounds(bounds); }
Example 9
Source File: AnimationHelper.java From RecordView with Apache License 2.0 | 4 votes |
public AnimationHelper(Context context, ImageView basketImg, ImageView smallBlinkingMic) { this.context = context; this.smallBlinkingMic = smallBlinkingMic; this.basketImg = basketImg; animatedVectorDrawable = AnimatedVectorDrawableCompat.create(context, R.drawable.recv_basket_animated); }
Example 10
Source File: SpotlightView.java From Spotlight with Apache License 2.0 | 4 votes |
/** * Add arc above/below the circular target overlay. */ private void addArcAnimation(final Activity activity) { AppCompatImageView mImageView = new AppCompatImageView(activity); mImageView.setImageResource(R.drawable.ic_spotlight_arc); LayoutParams params = new LayoutParams(2 * (circleShape.getRadius() + extraPaddingForArc), 2 * (circleShape.getRadius() + extraPaddingForArc)); if (targetView.getPoint().y > getHeight() / 2) {//bottom if (targetView.getPoint().x > getWidth() / 2) {//Right params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.RIGHT | Gravity.BOTTOM; } else { params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.LEFT | Gravity.BOTTOM; } } else {//up mImageView.setRotation(180); //Reverse the view if (targetView.getPoint().x > getWidth() / 2) {//Right params.rightMargin = getWidth() - targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.RIGHT | Gravity.BOTTOM; } else { params.leftMargin = targetView.getPoint().x - circleShape.getRadius() - extraPaddingForArc; params.bottomMargin = getHeight() - targetView.getPoint().y - circleShape.getRadius() - extraPaddingForArc; params.gravity = Gravity.LEFT | Gravity.BOTTOM; } } mImageView.postInvalidate(); mImageView.setLayoutParams(params); addView(mImageView); PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(lineAndArcColor, PorterDuff.Mode.SRC_ATOP); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { AnimatedVectorDrawable avd = (AnimatedVectorDrawable) ContextCompat.getDrawable(activity, R.drawable.avd_spotlight_arc); avd.setColorFilter(porterDuffColorFilter); mImageView.setImageDrawable(avd); avd.start(); } else { AnimatedVectorDrawableCompat avdc = AnimatedVectorDrawableCompat.create(activity, R.drawable.avd_spotlight_arc); avdc.setColorFilter(porterDuffColorFilter); mImageView.setImageDrawable(avdc); avdc.start(); } new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { @Override public void run() { addPathAnimation(activity); } }, 400); }
Example 11
Source File: StepTab.java From android-material-stepper with Apache License 2.0 | 2 votes |
/** * Inflates an animated vector drawable. * * @param animatedVectorDrawableResId resource ID for the animated vector * @return animated vector drawable */ public Drawable createAnimatedVectorDrawable(@DrawableRes int animatedVectorDrawableResId) { return AnimatedVectorDrawableCompat.create(getContext(), animatedVectorDrawableResId); }