Skip to content

Commit

Permalink
Fix drawable crash on API 19.
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-signal committed Oct 25, 2019
1 parent d59e4f2 commit 1ccce24
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.widget.ImageView;

import androidx.annotation.DrawableRes;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;

import android.widget.ImageView;

import com.amulyakhare.textdrawable.TextDrawable;
import com.makeramen.roundedimageview.RoundedDrawable;
Expand Down Expand Up @@ -55,7 +53,7 @@ public Drawable asSmallDrawable(Context context, int color, boolean inverted) {

private Drawable buildDrawable(Context context, int resourceId, int color, boolean inverted) {
Drawable background = TextDrawable.builder().buildRound(" ", inverted ? Color.WHITE : color);
RoundedDrawable foreground = (RoundedDrawable) RoundedDrawable.fromDrawable(ContextCompat.getDrawable(context, resourceId));
RoundedDrawable foreground = (RoundedDrawable) RoundedDrawable.fromDrawable(AppCompatResources.getDrawable(context, resourceId));

foreground.setScaleType(ImageView.ScaleType.CENTER);

Expand Down

0 comments on commit 1ccce24

Please sign in to comment.