Improve error message when bundled resource could not found. (#328)

A team member of mine spend a couple of hours debugging this error:
Couldn't find com.facebook.react.uimanager.annotations.ReactProp.source.

There was no clear indicator of what the underlaying problem was. As it turns out the error was caused by missing assets. To make sure other developers don't waste the same amount of time as we did, we improved the error message.
This commit is contained in:
Patrick Kempff 2018-11-06 07:16:31 +01:00 committed by Dylan Vann
parent f8606a1f2e
commit 7859d5b6d9

View File

@ -1,7 +1,9 @@
package com.dylanvann.fastimage;
import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;
import android.text.TextUtils;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.load.model.Headers;
@ -37,7 +39,6 @@ public class FastImageSource extends ImageSource {
this(context, source, null);
}
public FastImageSource(Context context, String source, @Nullable Headers headers) {
this(context, source, 0.0d, 0.0d, headers);
}
@ -47,6 +48,10 @@ public class FastImageSource extends ImageSource {
mHeaders = headers == null ? Headers.DEFAULT : headers;
mUri = super.getUri();
if (isResource() && TextUtils.isEmpty(mUri.toString())) {
throw new Resources.NotFoundException("Local Resource Not Found. Resource: '" + getSource() + "'.");
}
if (isLocalResourceUri(mUri)) {
// Convert res:/ scheme to android.resource:// so
// glide can understand the uri.