android.graphics.drawable.Animatable2 Java Examples

The following examples show how to use android.graphics.drawable.Animatable2. 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: AnimatedVectorDrawableCompat.java    From Bop with Apache License 2.0 5 votes vote down vote up
public static void addListener(AnimatedVectorDrawable drawable, Object callback) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (callback instanceof Animatable2.AnimationCallback) {
            drawable.registerAnimationCallback((Animatable2.AnimationCallback) callback);
        } else {
            throw new IllegalArgumentException("Callback parameter must implement " + Animatable2.AnimationCallback.class.getName());
        }
    }
}
 
Example #2
Source File: AnimatedVectorDrawableCompat.java    From Bop with Apache License 2.0 5 votes vote down vote up
public static boolean removeListener(AnimatedVectorDrawable drawable, Object callback) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (callback instanceof Animatable2.AnimationCallback) {
            return drawable.unregisterAnimationCallback((Animatable2.AnimationCallback) callback);
        } else {
            throw new IllegalArgumentException("Callback parameter must implement " + Animatable2.AnimationCallback.class.getName());
        }
    }
    return true;
}
 
Example #3
Source File: AnimatedVectorDrawableCompat.java    From Music-Player with Apache License 2.0 5 votes vote down vote up
public static void addListener(AnimatedVectorDrawable drawable, Object callback) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (callback instanceof Animatable2.AnimationCallback) {
            drawable.registerAnimationCallback((Animatable2.AnimationCallback) callback);
        } else {
            throw new IllegalArgumentException("Callback parameter must implement " + Animatable2.AnimationCallback.class.getName());
        }
    }
}
 
Example #4
Source File: AnimatedVectorDrawableCompat.java    From Music-Player with Apache License 2.0 5 votes vote down vote up
public static boolean removeListener(AnimatedVectorDrawable drawable, Object callback) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (callback instanceof Animatable2.AnimationCallback) {
            return drawable.unregisterAnimationCallback((Animatable2.AnimationCallback) callback);
        } else {
            throw new IllegalArgumentException("Callback parameter must implement " + Animatable2.AnimationCallback.class.getName());
        }
    }
    return true;
}
 
Example #5
Source File: RxAnimatable2.java    From RxAnimationBinding with Apache License 2.0 5 votes vote down vote up
@CheckResult
@NonNull
@TargetApi(Build.VERSION_CODES.M)
public static Observable<Drawable> starts(Animatable2 animatable2){
    checkNotNull(animatable2, "animatable2 == null");
    return Observable.create(new Animatable2ListenerOnSubscribe(animatable2, AnimationEvent.START));
}
 
Example #6
Source File: RxAnimatable2.java    From RxAnimationBinding with Apache License 2.0 5 votes vote down vote up
@CheckResult
@NonNull
@TargetApi(Build.VERSION_CODES.M)
public static Observable<Drawable> ends(Animatable2 animatable2){
    checkNotNull(animatable2, "animatable2 == null");
    return Observable.create(new Animatable2ListenerOnSubscribe(animatable2, AnimationEvent.END));
}
 
Example #7
Source File: CheckInDrawable.java    From cathode with Apache License 2.0 5 votes vote down vote up
public CheckInDrawable(Context context, int animatedCheckInDrawableRes,
    int animatedCancelDrawableRes, int checkInDrawableRes, int cancelDrawableRes) {
  this.context = context;

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    checkInDrawable = context.getDrawable(animatedCheckInDrawableRes);
    cancelDrawable = context.getDrawable(animatedCancelDrawableRes);

    callbacks = new Animatable2.AnimationCallback() {
      @RequiresApi(api = Build.VERSION_CODES.M) @Override
      public void onAnimationEnd(Drawable drawable) {
        ((AnimatedVectorDrawable) checkInDrawable).clearAnimationCallbacks();
        ((AnimatedVectorDrawable) checkInDrawable).reset();
        ((AnimatedVectorDrawable) cancelDrawable).clearAnimationCallbacks();
        ((AnimatedVectorDrawable) cancelDrawable).reset();

        updateWatchingDrawable(watching);
      }
    };
  } else {
    checkInDrawable =
        VectorDrawableCompat.create(context.getResources(), checkInDrawableRes, null);
    cancelDrawable = VectorDrawableCompat.create(context.getResources(), cancelDrawableRes, null);
  }

  checkInDrawable.setCallback(this);
  cancelDrawable.setCallback(this);

  currentDrawable = checkInDrawable;
}
 
Example #8
Source File: Animatable2ListenerOnSubscribe.java    From RxAnimationBinding with Apache License 2.0 4 votes vote down vote up
Animatable2ListenerOnSubscribe(Animatable2 animatable2, int eventToCallOn) {
    this.animatable2 = animatable2;
    this.eventToCallOn = eventToCallOn;
}