Context.getDrawable(): use the current theme

This commit is contained in:
Julian Winkler
2025-06-02 20:09:05 +02:00
parent 12d25c162f
commit 55fc7eb4f9
2 changed files with 6 additions and 6 deletions

View File

@@ -637,7 +637,7 @@ public class Context extends Object {
} }
public final Drawable getDrawable(int resId) { public final Drawable getDrawable(int resId) {
return getResources().getDrawable(resId); return getResources().getDrawable(resId, getTheme());
} }
public boolean isRestricted() { return false; } public boolean isRestricted() { return false; }

View File

@@ -710,6 +710,10 @@ public class Resources {
* @return Drawable An object that can be used to draw this resource. * @return Drawable An object that can be used to draw this resource.
*/ */
public Drawable getDrawable(int id) throws NotFoundException { public Drawable getDrawable(int id) throws NotFoundException {
return getDrawable(id, null);
}
public Drawable getDrawable(int id, Theme theme) throws NotFoundException {
TypedValue value; TypedValue value;
synchronized (mAccessLock) { synchronized (mAccessLock) {
value = mTmpValue; value = mTmpValue;
@@ -722,7 +726,7 @@ public class Resources {
} }
Drawable res = null; Drawable res = null;
try { try {
res = loadDrawable(value, id); res = loadDrawable(value, id, theme);
} catch (NotFoundException e) { e.printStackTrace(); } } catch (NotFoundException e) { e.printStackTrace(); }
synchronized (mAccessLock) { synchronized (mAccessLock) {
if (mTmpValue == null) { if (mTmpValue == null) {
@@ -732,10 +736,6 @@ public class Resources {
return res; return res;
} }
public Drawable getDrawable(int id, Theme theme) throws NotFoundException {
return getDrawable(id);
}
/** /**
* Return a drawable object associated with a particular resource ID for the * Return a drawable object associated with a particular resource ID for the
* given screen density in DPI. This will set the drawable's density to be * given screen density in DPI. This will set the drawable's density to be