Skip to content

Commit

Permalink
Merge pull request #1323 from bemusementpark/fix-attr-ex
Browse files Browse the repository at this point in the history
Fix unresolved theme attributes exception
  • Loading branch information
bemusementpark authored Mar 26, 2024
2 parents 1f249a6 + 4e6fe1f commit f26c971
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.widget.ImageView;

import androidx.annotation.DrawableRes;
import androidx.appcompat.content.res.AppCompatResources;

import com.amulyakhare.textdrawable.TextDrawable;
import com.makeramen.roundedimageview.RoundedDrawable;
Expand All @@ -31,16 +32,18 @@ public Drawable asDrawable(Context context, int color) {
@Override
public Drawable asDrawable(Context context, int color, boolean inverted) {
Drawable background = TextDrawable.builder().buildRound(" ", inverted ? Color.WHITE : color);
RoundedDrawable foreground = (RoundedDrawable) RoundedDrawable.fromDrawable(context.getResources().getDrawable(resourceId));
RoundedDrawable foreground = (RoundedDrawable) RoundedDrawable.fromDrawable(AppCompatResources.getDrawable(context, resourceId));

foreground.setScaleType(ImageView.ScaleType.CENTER_CROP);

if (inverted) {
foreground.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
}

Drawable gradient = context.getResources().getDrawable(ThemeUtil.isDarkTheme(context) ? R.drawable.avatar_gradient_dark
: R.drawable.avatar_gradient_light);
Drawable gradient = AppCompatResources.getDrawable(
context,
ThemeUtil.isDarkTheme(context) ? R.drawable.avatar_gradient_dark : R.drawable.avatar_gradient_light
);

return new ExpandingLayerDrawable(new Drawable[] {background, foreground, gradient});
}
Expand Down

0 comments on commit f26c971

Please sign in to comment.