@Test public void testInvalidateDrawable() { simpleMultiCallback.addView(view); drawable.setCallback(simpleMultiCallback); drawable.invalidateSelf(); verify(view).invalidateDrawable(drawable); }
@Override public void invalidateDrawable(@NonNull final Drawable who) { for (int i = 0; i < mCallbacks.size(); i++) { final CallbackWeakReference reference = mCallbacks.get(i); final Callback callback = reference.get(); if (callback != null) { if (mUseViewInvalidate && callback instanceof View) { ((View) callback).invalidate(); } else { callback.invalidateDrawable(who); } } else { mCallbacks.remove(reference); } } }
MultiCallback implements Callback { @Override public void invalidateDrawable(@NonNull final Drawable who) { for (int i = 0; i < mCallbacks.size(); i++) { final CallbackWeakReference reference = mCallbacks.get(i); final Callback callback = reference.get(); if (callback != null) { if (mUseViewInvalidate && callback instanceof View) { ((View) callback).invalidate(); } else { callback.invalidateDrawable(who); } } else { mCallbacks.remove(reference); } } } }
MultiCallback implements Callback { @Override public void invalidateDrawable(@NonNull final Drawable who) { for (int i = 0; i < mCallbacks.size(); i++) { final CallbackWeakReference reference = mCallbacks.get(i); final Callback callback = reference.get(); if (callback != null) { if (mUseViewInvalidate && callback instanceof View) { ((View) callback).invalidate(); } else { callback.invalidateDrawable(who); } } else { mCallbacks.remove(reference); } } } MultiCallback();  MultiCallback(final boolean useViewInvalidate); }
MultiCallback implements Callback { @Override public void invalidateDrawable(@NonNull final Drawable who) { for (int i = 0; i < mCallbacks.size(); i++) { final CallbackWeakReference reference = mCallbacks.get(i); final Callback callback = reference.get(); if (callback != null) { if (mUseViewInvalidate && callback instanceof View) { ((View) callback).invalidate(); } else { callback.invalidateDrawable(who); } } else { mCallbacks.remove(reference); } } } MultiCallback();  MultiCallback(final boolean useViewInvalidate); @Override void invalidateDrawable(@NonNull final Drawable who); @Override void scheduleDrawable(@NonNull final Drawable who, @NonNull final Runnable what, final long when); @Override void unscheduleDrawable(@NonNull final Drawable who, @NonNull final Runnable what); void addView(final Callback callback); void removeView(final Callback callback); }
MultiCallback implements Callback { @Override public void invalidateDrawable(@NonNull final Drawable who) { for (int i = 0; i < mCallbacks.size(); i++) { final CallbackWeakReference reference = mCallbacks.get(i); final Callback callback = reference.get(); if (callback != null) { if (mUseViewInvalidate && callback instanceof View) { ((View) callback).invalidate(); } else { callback.invalidateDrawable(who); } } else { mCallbacks.remove(reference); } } } MultiCallback();  MultiCallback(final boolean useViewInvalidate); @Override void invalidateDrawable(@NonNull final Drawable who); @Override void scheduleDrawable(@NonNull final Drawable who, @NonNull final Runnable what, final long when); @Override void unscheduleDrawable(@NonNull final Drawable who, @NonNull final Runnable what); void addView(final Callback callback); void removeView(final Callback callback);  }