Skip to content

Commit

Permalink
fix(android): Check proxy on TiDrawableReference fromUrl (#12541)
Browse files Browse the repository at this point in the history
- Fix crash when loading images from url
- if proxy is null but url is not, resolve url

Fixes TIMOB-28385
  • Loading branch information
LalitaGertrudis authored and sgtcoolguy committed Mar 12, 2021
1 parent 35604ee commit f093c15
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.TiBlob;
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.TiDimension;
import org.appcelerator.titanium.TiFileProxy;
import org.appcelerator.titanium.io.TiBaseFile;
Expand Down Expand Up @@ -157,10 +158,17 @@ public static TiDrawableReference fromBlob(Activity activity, TiBlob blob)
*/
public static TiDrawableReference fromUrl(KrollProxy proxy, String url)
{
Activity activity = TiApplication.getAppCurrentActivity();
// Attempt to fetch an activity from the given proxy.
if (proxy != null) {
activity = proxy.getActivity();
}

if (url == null || url.length() == 0 || url.trim().length() == 0) {
return new TiDrawableReference(proxy.getActivity(), DrawableReferenceType.NULL);
return new TiDrawableReference(activity, DrawableReferenceType.NULL);
}
return fromUrl(proxy.getActivity(), proxy.resolveUrl(null, url));

return fromUrl(activity, TiUrl.resolve(TiC.URL_APP_PREFIX, url, null));
}

/**
Expand Down

0 comments on commit f093c15

Please sign in to comment.