8
8
import android .support .annotation .Nullable ;
9
9
import android .support .v4 .content .res .ResourcesCompat ;
10
10
import android .support .v7 .content .res .AppCompatResources ;
11
+ import android .support .v7 .view .ContextThemeWrapper ;
11
12
12
13
/**
13
14
* Handles decoding Drawables with the v7 support library if present and falling back to the v4
@@ -38,7 +39,7 @@ public static Drawable getDrawable(Context context, @DrawableRes int id, @Nullab
38
39
// Race conditions may cause us to attempt to load using v7 more than once. That's ok since
39
40
// this check is a modest optimization and the output will be correct anyway.
40
41
if (shouldCallAppCompatResources ) {
41
- return loadDrawableV7 (context , id );
42
+ return loadDrawableV7 (context , id , theme );
42
43
}
43
44
} catch (NoClassDefFoundError error ) {
44
45
shouldCallAppCompatResources = false ;
@@ -50,8 +51,10 @@ public static Drawable getDrawable(Context context, @DrawableRes int id, @Nullab
50
51
return loadDrawableV4 (context , id , theme != null ? theme : context .getTheme ());
51
52
}
52
53
53
- private static Drawable loadDrawableV7 (Context context , @ DrawableRes int id ) {
54
- return AppCompatResources .getDrawable (context , id );
54
+ private static Drawable loadDrawableV7 (Context context , @ DrawableRes int id ,
55
+ @ Nullable Theme theme ) {
56
+ Context resourceContext = theme != null ? new ContextThemeWrapper (context , theme ) : context ;
57
+ return AppCompatResources .getDrawable (resourceContext , id );
55
58
}
56
59
57
60
private static Drawable loadDrawableV4 (
0 commit comments