Promote ResourceDrawableIdHelper to new module

Summary:
Found a couple of places where we were copy-pasting the logic `ResourceDrawableIdHelper` had. This class was only available on the image module and it had package visibility. I moved it to its own module so that we can easily use it from others.

This diff is pretty simillar to 54ed44628d but it fixes a bug due to which we had to revert it.

Reviewed By: andreicoman11

Differential Revision: D3499062

fbshipit-source-id: f912f57e5ac21a9f30fe42067c784f49fa46ed48
This commit is contained in:
Felix Oghina
2016-07-01 04:20:35 -07:00
committed by Facebook Github Bot 5
parent 508cc06565
commit 010e1977a8
10 changed files with 60 additions and 21 deletions

View File

@@ -12,6 +12,7 @@ android_library(
react_native_target('java/com/facebook/react/modules/core:core'),
react_native_target('java/com/facebook/react/uimanager/annotations:annotations'),
react_native_target('java/com/facebook/react/uimanager:uimanager'),
react_native_target('java/com/facebook/react/views/imagehelper:imagehelper'),
react_native_target('java/com/facebook/react/views/text:text'),
react_native_target('java/com/facebook/react/views/view:view'),
],

View File

@@ -43,6 +43,7 @@ import com.facebook.react.uimanager.ViewDefaults;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper;
import com.facebook.react.views.text.DefaultStyleValuesUtil;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.TextInlineImageSpan;
@@ -66,7 +67,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
private static final String KEYBOARD_TYPE_PHONE_PAD = "phone-pad";
private static final InputFilter[] EMPTY_FILTERS = new InputFilter[0];
private static final int UNSET = -1;
@Override
public String getName() {
return REACT_CLASS;
@@ -325,8 +326,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
@ReactProp(name = "inlineImageLeft")
public void setInlineImageLeft(ReactEditText view, @Nullable String resource) {
// TODO: t11992069 fix this after `ResourceDrawableIdHelper` gets fixed
int id = 0;//ResourceDrawableIdHelper.getInstance().getResourceDrawableId(view.getContext(), resource);
int id = ResourceDrawableIdHelper.getInstance().getResourceDrawableId(view.getContext(), resource);
view.setCompoundDrawablesWithIntrinsicBounds(id, 0, 0, 0);
}