Skip to content

Commit

Permalink
Fixes a bug in gms
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 481179115
  • Loading branch information
sjudd authored and glide-copybara-robot committed Oct 14, 2022
1 parent 08c9f72 commit ef64c38
Showing 1 changed file with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import android.content.res.Resources;
import android.content.res.Resources.Theme;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Build.VERSION_CODES;
import androidx.annotation.DrawableRes;
import androidx.annotation.Nullable;
import androidx.appcompat.content.res.AppCompatResources;
Expand Down Expand Up @@ -67,27 +65,13 @@ private static Drawable getDrawable(

private static Drawable loadDrawableV7(
Context context, @DrawableRes int id, @Nullable Theme theme) {
Context resourceContext;
if (theme != null) {
ContextThemeWrapper contextThemeWrapper = new ContextThemeWrapper(context, theme);
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
contextThemeWrapper.applyOverrideConfiguration(theme.getResources().getConfiguration());
}
resourceContext = contextThemeWrapper;
} else {
resourceContext = context;
}
Context resourceContext = theme != null ? new ContextThemeWrapper(context, theme) : context;
return AppCompatResources.getDrawable(resourceContext, id);
}

private static Drawable loadDrawableV4(
Context context, @DrawableRes int id, @Nullable Theme theme) {
Resources resources;
if (theme != null && VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
resources = theme.getResources();
} else {
resources = context.getResources();
}
Resources resources = context.getResources();
return ResourcesCompat.getDrawable(resources, id, theme);
}
}

0 comments on commit ef64c38

Please sign in to comment.