Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText Binding is broken after MvvmCross update from 4.2.3 to 4.4.0 with Linker enabled

My MvvmCross Android app which was working before now is broken because of MvvmCross update from 4.2.3 to 4.4.0

<EditText
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   local:MvxBind="Text Login" />

public string Login
{
    get { return _login; }
    set { SetProperty(ref _login, value); }
}

LinkerPleaseInclude if of course there:

public void Include(EditText text)
        {
            text.Enabled = !text.Enabled;
            text.TextChanged += (sender, args) => text.Text = "" + text.Text;
            text.Hint = "" + text.Hint;
            text.Click += (s, e) => text.Visibility = text.Visibility - 1;
        }

        public void Include(TextView text)
        {
            text.TextChanged += (sender, args) => text.Text = "" + text.Text;
            text.Hint = "" + text.Hint;
            text.Click += (s, e) => text.Text = text.Text + "";
        }

Linker "SDK Only" enabled. For disabled linker it works fine. Other bindings works fine as well (button clicks, visibilities, etc).

How to tell linker to handle this properly? What could be wrong here?

like image 551
Alexey Strakh Avatar asked Nov 04 '16 22:11

Alexey Strakh


1 Answers

The binding target for EditText and TextView uses the AfterTextChanged event, which probably gets linked away. Add that to your Include methods instead of TextChanged and it should work:

public void Include(TextView text)
{
    text.AfterTextChanged += (sender, args) => text.Text = "" + text.Text;
    text.Hint = "" + text.Hint;
    text.Click += (s, e) => text.Text = text.Text + "";
}

I don't think you need a separate method for EditText as EditText inherits from TextView.

like image 73
Cheesebaron Avatar answered Oct 26 '22 20:10

Cheesebaron