package com.mapbox.rctmgl.components.styles.sources;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Movie;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Handler;
import android.util.Log;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.mapbox.mapboxsdk.geometry.LatLngQuad;
import com.mapbox.mapboxsdk.style.sources.ImageSource;
import com.mapbox.rctmgl.utils.BitmapUtils;
import com.mapbox.services.commons.geojson.Feature;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Map;

/**
 * Created by nickitaliano on 11/29/17.
 */

public class RCTMGLImageSource extends RCTSource<ImageSource> {
    public static final String LOG_TAG = RCTMGLImageSource.class.getSimpleName();

    private URL mURL;
    private LatLngQuad mCoordQuad;

    public RCTMGLImageSource(Context context) {
        super(context);
    }

    @Override
    public ImageSource makeSource() {
        return new ImageSource(mID, mCoordQuad, mURL);
    }

    @Override
    public void onPress(Feature feature) {
        // ignore, we cannot query raster layers
    }

    public void setURL(String url) {
        try {
            mURL = new URL(url);

            if (mSource != null) {
                mSource.setUrl(mURL);
            }
        } catch (MalformedURLException e) {
            Log.w(LOG_TAG, e.getLocalizedMessage());
        }
    }

    public void setCoordinates(LatLngQuad coordQuad) {
        mCoordQuad = coordQuad;
    }
}

@@ -340,16 +340,86 @@
 Fresco;%0A
+import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;%0A
 import c
@@ -935,16 +935,45 @@
 L mURL;%0A
+    private int mResourceId;%0A
     priv
@@ -1127,24 +1127,138 @@
 eSource() %7B%0A
+        if (this.mURL == null) %7B%0A            return new ImageSource(mID, mCoordQuad, this.mResourceId);%0A        %7D%0A
         retu
@@ -1471,16 +1471,360 @@
   try %7B%0A
+            Uri uri = Uri.parse(url);%0A%0A            if (uri.getScheme() == null) %7B%0A                this.mResourceId = ResourceDrawableIdHelper.getInstance().getResourceDrawableId(this.getContext(), url);%0A%0A                if (mSource != null) %7B%0A                    mSource.setImage(this.mResourceId);%0A                %7D%0A%0A            %7D else %7B%0A%0A    
         
@@ -1853,32 +1853,36 @@
 );%0A%0A            
+   
+ 
 if (mSource != n
@@ -1896,32 +1896,36 @@
                 
+    
 mSource.setUrl(m
@@ -1926,24 +1926,42 @@
 tUrl(mURL);%0A
+                %7D%0A
             
@@ -1954,32 +1954,33 @@
 %7D%0A            %7D%0A
+%0A
         %7D catch 
@@ -2069,32 +2069,33 @@
        %7D%0A    %7D%0A%0A
+%0A
     public void 

Update RCTMGLImageSource.java