Skip to content

Commit

Permalink
Fix dynamic rounding
Browse files Browse the repository at this point in the history
  • Loading branch information
IanChilds authored and tyronen committed Jun 4, 2015
1 parent ea38fa4 commit 9a44845
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void draw(Canvas canvas) {

private final Resources mResources;

private Drawable mTopLevelDrawable;
private final SettableDrawable mTopLevelDrawable;
private final FadeDrawable mFadeDrawable;
private final SettableDrawable mActualImageSettableDrawable;

Expand Down Expand Up @@ -283,7 +283,7 @@ public void draw(Canvas canvas) {
root = maybeWrapWithRoundedOverlayColor(mRoundingParams, root);

// top-level drawable
mTopLevelDrawable = root;
mTopLevelDrawable = new SettableDrawable(root);
mTopLevelDrawable.mutate();

resetFade();
Expand Down Expand Up @@ -644,21 +644,23 @@ public void setRoundingParams(RoundingParams roundingParams) {
}

private void updateOverlayColorRounding() {
Drawable topDrawableChild = mTopLevelDrawable.getCurrent();
if (mRoundingParams != null &&
mRoundingParams.getRoundingMethod() == RoundingParams.RoundingMethod.OVERLAY_COLOR) {
// Overlay rounding requested - either update the overlay params or add a new top-level
// Overlay rounding requested - either update the overlay params or add a new
// drawable that will do the requested rounding.
if (mTopLevelDrawable instanceof RoundedCornersDrawable) {
RoundedCornersDrawable roundedCornersDrawable = (RoundedCornersDrawable) mTopLevelDrawable;
if (topDrawableChild instanceof RoundedCornersDrawable) {
RoundedCornersDrawable roundedCornersDrawable = (RoundedCornersDrawable) topDrawableChild;
applyRoundingParams(roundedCornersDrawable, mRoundingParams);
roundedCornersDrawable.setOverlayColor(mRoundingParams.getOverlayColor());
} else {
mTopLevelDrawable = maybeWrapWithRoundedOverlayColor(mRoundingParams, mTopLevelDrawable);
mTopLevelDrawable.setCurrent(
maybeWrapWithRoundedOverlayColor(mRoundingParams, topDrawableChild));
}
} else if (mTopLevelDrawable instanceof RoundedCornersDrawable) {
// Overlay rounding no longer required so remove top-level drawable that was doing the
} else if (topDrawableChild instanceof RoundedCornersDrawable) {
// Overlay rounding no longer required so remove drawable that was doing the
// rounding.
mTopLevelDrawable = mTopLevelDrawable.getCurrent();
mTopLevelDrawable.setCurrent(topDrawableChild.getCurrent());
}
}

Expand Down
Loading

0 comments on commit 9a44845

Please sign in to comment.