Skip to content

目标方法带有注解时导致的异常 #77

@flyisme

Description

@flyisme

使用Insert 插桩如果目标方法包含注解,会存在以下问题:

插桩后方法如下:

// 原因:旧方法只是改名了
@ReactProp(name = "selectionColor", customType = "Color")
  private void setSelectionColor$___twin___(ReactEditText view, @Nullable Integer color) {
    if (color == null) {
      view.setHighlightColor(
          DefaultStyleValuesUtil.getDefaultTextColorHighlight(view.getContext()));
    } else {
      view.setHighlightColor(color.intValue());
    } 
    setCursorColor(view, color);
  }
// 新增方法: 缺少对应的注解
public void setSelectionColor(ReactEditText paramReactEditText, Integer paramInteger) {
    ReactTextInputManager$_lancet.com_lagos_emobility_client_lancet_RnBugfix_setSelectionColor(this, paramReactEditText, paramInteger);
  }
  
  private static class ReactTextInputManager$_lancet {
    @TargetClass("com.facebook.react.views.textinput.ReactTextInputManager")
    @Insert("setSelectionColor")
    static void com_lagos_emobility_client_lancet_RnBugfix_setSelectionColor(ReactTextInputManager param1ReactTextInputManager, @Nullable ReactEditText param1ReactEditText, Integer param1Integer) {
      if (param1Integer != null) {
        GradientDrawable gradientDrawable = new GradientDrawable();
        gradientDrawable.setShape(0);
        gradientDrawable.setColor(param1Integer.intValue());
        gradientDrawable.setSize(SystemUtils.dip2px((Context)ClientApp.mAppContext, 2.0F), SystemUtils.dip2px((Context)ClientApp.mAppContext, 20.0F));
        if (Build.VERSION.SDK_INT >= 29)
          param1ReactEditText.setTextCursorDrawable((Drawable)gradientDrawable); 
      } 
      param1ReactTextInputManager.setSelectionColor$___twin___(param1ReactEditText, param1Integer);
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions