mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-10 18:05:26 +08:00
Reverted commit D3494715
Reviewed By: donyu Differential Revision: D3494715 fbshipit-source-id: a96e12ddbf266804b1bb8ec169d3c01e8a029eb7
This commit is contained in:
committed by
Facebook Github Bot 5
parent
73bea8f7e6
commit
cbd8214b43
@@ -7,7 +7,6 @@ import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
@@ -19,6 +18,7 @@ public class ResourceDrawableIdHelper {
|
||||
|
||||
private Map<String, Integer> mResourceDrawableIdMap;
|
||||
|
||||
private static final String LOCAL_RESOURCE_SCHEME = "res";
|
||||
private static ResourceDrawableIdHelper sResourceDrawableIdHelper;
|
||||
|
||||
private ResourceDrawableIdHelper() {
|
||||
@@ -45,9 +45,9 @@ public class ResourceDrawableIdHelper {
|
||||
return mResourceDrawableIdMap.get(name);
|
||||
}
|
||||
int id = context.getResources().getIdentifier(
|
||||
name,
|
||||
"drawable",
|
||||
context.getPackageName());
|
||||
name,
|
||||
"drawable",
|
||||
context.getPackageName());
|
||||
mResourceDrawableIdMap.put(name, id);
|
||||
return id;
|
||||
}
|
||||
@@ -58,16 +58,10 @@ public class ResourceDrawableIdHelper {
|
||||
}
|
||||
|
||||
public Uri getResourceDrawableUri(Context context, @Nullable String name) {
|
||||
if (name == null || name.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int resId = ResourceDrawableIdHelper.getInstance().getResourceDrawableId(context, name);
|
||||
|
||||
return new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(context.getPackageName())
|
||||
.path(String.valueOf(resId))
|
||||
.build();
|
||||
int resId = getResourceDrawableId(context, name);
|
||||
return resId > 0 ? new Uri.Builder()
|
||||
.scheme(LOCAL_RESOURCE_SCHEME)
|
||||
.path(String.valueOf(resId))
|
||||
.build() : Uri.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user