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:
Родитель
e7a14b803f
Коммит
6a61557b24
|
@ -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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче