Remove ImageRequestHelper for Nodes

Summary:
Use ImageRequestBuilder directly in Nodes, just like we do for
non-Nodes.

Reviewed By: sriramramani

Differential Revision:
D3660610
Ninja: Sandcastle is broken. 25 denizens of the Facebook republic are affected by this unrelated issue today.
This commit is contained in:
Ahmed El-Helw 2016-08-03 13:38:00 -07:00
parent 7cc4e0364a
commit 0c9afec7dc
4 changed files with 11 additions and 64 deletions

View File

@ -25,6 +25,7 @@ import com.facebook.drawee.drawable.ScalingUtils.ScaleType;
import com.facebook.drawee.generic.GenericDraweeHierarchy;
import com.facebook.drawee.generic.RoundingParams;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
@ -253,15 +254,11 @@ import com.facebook.react.views.imagehelper.MultiSourceHelper.MultiSourceResult;
mRequestHelper = null;
return;
}
ImageRequest imageRequest = ImageRequestHelper.createImageRequest(
Assertions.assertNotNull(mContext),
source.getSource());
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(source.getUri()).build();
ImageRequest cachedImageRequest = null;
if (cachedSource != null) {
cachedImageRequest = ImageRequestHelper.createImageRequest(
Assertions.assumeNotNull(mContext),
cachedSource.getSource());
cachedImageRequest = ImageRequestBuilder.newBuilderWithSource(cachedSource.getUri()).build();
}
mRequestHelper = new
DraweeRequestHelper(Assertions.assertNotNull(imageRequest), cachedImageRequest, this);

View File

@ -27,6 +27,7 @@ import android.graphics.Shader;
import com.facebook.drawee.drawable.ScalingUtils.ScaleType;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
@ -240,9 +241,7 @@ import com.facebook.react.views.imagehelper.MultiSourceHelper.MultiSourceResult;
mRequestHelper = null;
return;
}
ImageRequest imageRequest = ImageRequestHelper.createImageRequest(
Assertions.assertNotNull(mContext),
source.getSource());
ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(source.getUri()).build();
// DrawImageWithPipeline does now support displaying low res cache images before request
mRequestHelper = new PipelineRequestHelper(Assertions.assertNotNull(imageRequest));

View File

@ -1,53 +0,0 @@
/**
* 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 (isUriResource(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 isUriResource(String source) {
return
source.startsWith("http://") ||
source.startsWith("https://") ||
source.startsWith("data:") ||
source.startsWith("file:///") ||
source.startsWith("content://");
}
}

View File

@ -14,8 +14,10 @@ import javax.annotation.Nullable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.views.imagehelper.ImageSource;
/**
* RCTTextInlineImage
@ -73,8 +75,10 @@ import com.facebook.react.uimanager.annotations.ReactProp;
public void setSource(@Nullable ReadableArray sources) {
final String source =
(sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri");
getMutableSpan().setImageRequest(
ImageRequestHelper.createImageRequest(getThemedContext(), source));
final ImageSource imageSource = source == null ? null :
new ImageSource(getThemedContext(), source);
getMutableSpan().setImageRequest(imageSource == null ? null :
ImageRequestBuilder.newBuilderWithSource(imageSource.getUri()).build());
}
private InlineImageSpanWithPipeline getMutableSpan() {