Error when attempting to use the data binding provided context variable with BaseObservable

I don't know whether this is a bug or intended behavior, but I observed this behavior myself, so you're not crazy.

A workaround is to create a method that is NOT marked @Bindable in your User -- the one that requires the Context. This method won't be subject to the JavaBeans naming conventions.

Important: In order to make sure it's updated appropriately, it should take as inputs any @Bindable fields that might change.

User.java

public class User extends BaseObservable {
    private String name;

    public User(String name) {
        this.name = name;
    }

    @Bindable
    public String getName() {
        return this.name;
    }

    public CharSequence getStyledName(Context ctx, String name) {
        // construct styled name here
    }
}

and in your layout:

<TextView
        android:id="@+id/main_textview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="@{user.getStyledName(context, user.name)}" />