mardi 24 janvier 2017

CheckBox appears half-checked

I have this in my fragment's onResume:

@Override
public void onResume() {
    super.onResume();
    restoreForm(mMyData)); // don't worry about this, it's not null and valid
}

Here's the implementation of restoreForm:

@Override
public void restoreForm(MyData model) {
    mCheckBoxAppl.setChecked(model.appl); // issue happens when this is true
    ...
}

Sometimes it's OK, but I can see the box being checked.
The rest of the time it's not OK, and the box stays half checked:

top checkbox is not fully checked

I have had a look at all the possible states this box can have, none of the states matches what we have here. I'm guessing that it's an animation that stopped in the middle between unchecked and checked.

If I change my onResume to this:

@Override
public void onResume() {
    super.onResume();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            restoreForm(((FormActivity) getActivity()).<T>getObject());
        }
    }, 5000);
}

Then it's 100% working as expected, but it is also 100% five seconds late.

How can I force check this box, possibly disabling the animations in the process?
Note that I don't want to disable the callbacks, because the callback behind this check box click does some useful stuff.




Aucun commentaire:

Enregistrer un commentaire