Should Kotlin Android Extensions properly work in ...
# android
n
Should Kotlin Android Extensions properly work in custom view classes? The cache methods get generated, but not used:
Copy code
class MyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0)
    : FrameLayout(context, attrs, defStyle) {

    var text: String = ""
        set(value) {
            textView.text = value
        }
}
Copy code
public final class MyView extends FrameLayout {

   @NotNull
   private String text;

   private HashMap _$_findViewCache;

   @NotNull
   public final String getText() {
      return this.text;
   }

   public final void setText(@NotNull String value) {
      Intrinsics.checkParameterIsNotNull(value, "value");
      ((TextView)this.findViewById(id.textView)).setText((CharSequence)value);
   }

   @JvmOverloads
   public MyView(@NotNull Context context, @Nullable AttributeSet attrs, int defStyle) {
      Intrinsics.checkParameterIsNotNull(context, "context");
      super(context, attrs, defStyle);
      this.text = "";
   }

   public View _$_findCachedViewById(int var1) {
      if(this._$_findViewCache == null) {
         this._$_findViewCache = new HashMap();
      }

      View var2 = (View)this._$_findViewCache.get(Integer.valueOf(var1));
      if(var2 == null) {
         var2 = this.findViewById(var1);
         this._$_findViewCache.put(Integer.valueOf(var1), var2);
      }

      return var2;
   }

   public void _$_clearFindViewByIdCache() {
      if(this._$_findViewCache != null) {
         this._$_findViewCache.clear();
      }

   }
}
👋 1