-
-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug - view doesn't seem to redraw correctly when restored from saved state #172
Comments
May I have a little bit information about your view... |
I use it not as speedometer but as a circle gauge, so the values are way bigger than the usual defaults (that is why I suspect that the value of 100 comes from some defaults of the TubeSpeedometer or its parent). This is the code I use to bind the values to the widget via Android Binding
the values for this vehicle are mileage 38100, annual mileage (max) - 40000. The component is alright (without workaround) all the time except for the case when I minimize the app, kill it and restore. But the workaround does the job. P. S. of course I restore the values myself, so in this case we have a double job - vehicle has restored values and the Gauge has restored them as well, but the problem is that it doesn't reflect them after restore and setting them in BindingAdapter to the same values has no effect |
I found out that the min-max Values are the problem, what really happened is that speed value has been restored but min-max Values are not... |
Great, thank you. Are you sure, you have to restore anything? I think it is a responsibility of the app to restore and reset data. Even if you do - your widget is not alone in the view hierarchy, so other data still has to be saved and restored |
Literally, Android system will not restored anything you have changed at the run time, which means our responsibility to do so. That's the logic of the app life cycle. |
Yes, I know, what I mean is - I'm not sure that your widget has to store and restore data, I think that the application, that uses it, should do this. |
You are right, i should remove it in the next version. |
done c93b5e1, it's user responsibility for now. |
There seems to be an issue with redrawing correctly (at least the speed value) if restored from saved state. I'm using TubeSpeedometer but since values are restored in base class (Gauge) maybe the problem is common to all types. The symptoms are - if I minimize the app, kill it and restore, the value of TubeSpeedometer stays at 100 (why 100? default value of maxSpeed?) - inspite of correct value 38100 being assigned. After debugging I noticed that the correct value is ignored while setting (and thus animation etc.) since the old value is already correct (because it is restored by component itself). A quick workaround was to set the value twice with view.speedTo(value++) and view.speedTo(value--) - with it the TubeSpeedometer redraws correctly since value is changed.
So there must be something wrong in the redraw logic when the view is restored from saved state
The text was updated successfully, but these errors were encountered: