From a7351b0ecf6656ad937fbc52fe9e90d3b289c265 Mon Sep 17 00:00:00 2001 From: bromano Date: Fri, 26 Apr 2024 17:34:32 -0700 Subject: [PATCH] Avoid referencing resource names within Resource Loader --- .../java/com/bumptech/glide/load/model/ResourceLoader.java | 4 +--- .../com/bumptech/glide/load/model/ResourceLoaderTest.java | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java b/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java index 1175315a84..ad48104ba6 100644 --- a/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java +++ b/library/src/main/java/com/bumptech/glide/load/model/ResourceLoader.java @@ -52,9 +52,7 @@ private Uri getResourceUri(Integer model) { + "://" + resources.getResourcePackageName(model) + '/' - + resources.getResourceTypeName(model) - + '/' - + resources.getResourceEntryName(model)); + + model); } catch (Resources.NotFoundException e) { if (Log.isLoggable(TAG, Log.WARN)) { Log.w(TAG, "Received invalid resource id: " + model, e); diff --git a/library/test/src/test/java/com/bumptech/glide/load/model/ResourceLoaderTest.java b/library/test/src/test/java/com/bumptech/glide/load/model/ResourceLoaderTest.java index 1bda30e238..708dba9d2f 100644 --- a/library/test/src/test/java/com/bumptech/glide/load/model/ResourceLoaderTest.java +++ b/library/test/src/test/java/com/bumptech/glide/load/model/ResourceLoaderTest.java @@ -49,7 +49,7 @@ public void setUp() { @Test public void testCanHandleId() { int id = android.R.drawable.star_off; - Uri contentUri = Uri.parse("android.resource://android/drawable/star_off"); + Uri contentUri = Uri.parse("android.resource://android/" + String.valueOf(id)); when(uriLoader.buildLoadData(eq(contentUri), anyInt(), anyInt(), any(Options.class))) .thenReturn(new ModelLoader.LoadData<>(key, fetcher));