mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Early return on tinting CursorDrawable if no color supplied
Summary: There's (potentially) a lot of expensive reflection calls here that, as best I can tell, end up being ignored if the supplied color is null. Better to early return. Changelog: [General] [Internal] Preclude reflection when setting cursor color if color is null Reviewed By: JoshuaGross Differential Revision: D20670594 fbshipit-source-id: 480a988355bbd79008002c4326d4b35035ec2a95
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e7a14b803f
commit
6a61557b24
+4
-3
@@ -435,6 +435,9 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
|
||||
@ReactProp(name = "cursorColor", customType = "Color")
|
||||
public void setCursorColor(ReactEditText view, @Nullable Integer color) {
|
||||
if (color == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
Drawable cursorDrawable = view.getTextCursorDrawable();
|
||||
@@ -467,9 +470,7 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
}
|
||||
|
||||
Drawable drawable = ContextCompat.getDrawable(view.getContext(), drawableResId);
|
||||
if (color != null) {
|
||||
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
|
||||
Drawable[] drawables = {drawable, drawable};
|
||||
|
||||
// Update the current cursor drawable with the new one.
|
||||
|
||||
Reference in New Issue
Block a user