Permalink
Browse files

Allow setting shimmer to null

Summary: This lets callers remove the shimmer effect entirely more easily.

Reviewed By: sjkirby

Differential Revision: D10035902

fbshipit-source-id: 098c34bf7fcb106d27146d31bb5e4a5d98effed8
  • Loading branch information...
xiphirx authored and facebook-github-bot committed Sep 25, 2018
1 parent fd48e0a commit e7a2129f79a6d2c76fceddaf1a8c401e30b4f5b8
@@ -44,14 +44,13 @@ public ShimmerDrawable() {
mShimmerPaint.setAntiAlias(true);
}
public void setShimmer(Shimmer shimmer) {
if (shimmer == null) {
throw new IllegalArgumentException("Given null shimmer");
}
public void setShimmer(@Nullable Shimmer shimmer) {
mShimmer = shimmer;
mShimmerPaint.setXfermode(
new PorterDuffXfermode(
mShimmer.alphaShimmer ? PorterDuff.Mode.DST_IN : PorterDuff.Mode.SRC_IN));
if (mShimmer != null) {
mShimmerPaint.setXfermode(
new PorterDuffXfermode(
mShimmer.alphaShimmer ? PorterDuff.Mode.DST_IN : PorterDuff.Mode.SRC_IN));
}
updateShader();
updateValueAnimator();
invalidateSelf();
@@ -74,13 +74,9 @@ private void init(Context context, @Nullable AttributeSet attrs) {
}
}
public ShimmerFrameLayout setShimmer(Shimmer shimmer) {
if (shimmer == null) {
throw new IllegalArgumentException("Given null shimmer");
}
public ShimmerFrameLayout setShimmer(@Nullable Shimmer shimmer) {
mShimmerDrawable.setShimmer(shimmer);
if (shimmer.clipToChildren) {
if (shimmer != null && shimmer.clipToChildren) {
setLayerType(LAYER_TYPE_HARDWARE, mContentPaint);
} else {
setLayerType(LAYER_TYPE_NONE, null);

0 comments on commit e7a2129

Please sign in to comment.