/**
 * Copyright (c) 2015-present, Facebook, Inc.
 * All rights reserved.
 *
 * This source code is licensed under the BSD-style license found in the
 * LICENSE file in the root directory of this source tree. An additional grant
 * of patent rights can be found in the PATENTS file in the same directory.
 */

package com.facebook.react.flat;

import javax.annotation.Nullable;

import android.content.Context;
import android.content.res.Resources;
import android.net.Uri;

import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;

/* package */ class ImageRequestHelper {

  /* package */ static @Nullable ImageRequest createImageRequest(
      Context context,
      @Nullable String source) {
    if (source == null) {
      return null;
    }

    final ImageRequestBuilder imageRequestBuilder;
    if (isNetworkResource(source)) {
      imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(source));
    } else {
      Resources resources = context.getResources();
      int resId = resources.getIdentifier(
          source,
          "drawable",
          context.getPackageName());
      imageRequestBuilder = ImageRequestBuilder.newBuilderWithResourceId(resId);
    }

    return imageRequestBuilder.build();
  }

  private static boolean isNetworkResource(String source) {
    return source.startsWith("http://") || source.startsWith("https://");
  }
}

@@ -864,23 +864,19 @@
   if (is
-Network
+Uri
 Resource
@@ -1325,15 +1325,11 @@
 n is
-Network
+Uri
 Reso
@@ -1360,16 +1360,22 @@
   return
+%0A     
  source.
@@ -1398,16 +1398,22 @@
 ://%22) %7C%7C
+%0A     
  source.
@@ -1434,16 +1434,52 @@
 tps://%22)
+ %7C%7C%0A      source.startsWith(%22data:%22)
 ;%0A  %7D%0A%7D%0A

Add support for data: Uri scheme to RCTImageView (e.g. base64-encoded images)