You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The update() method on a view may be called a lot, including circumstances when the state of the view is already fine. Try to avoid UI mutations or expensive calls like revalidate() unless required.
E.g. In DishAddOnView.java's update method we have:
@Override
public void update() {
if (isSelected){
getStyle().setBgTransparency(255);
}else{
getStyle().setBgTransparency(0);
}
revalidate();
}
I would guard against both the setBgTransparency() calls and the revalidate, as follows:
@Override
public void update() {
int bgTransparency = getStyle().getBgTransparency();
if (isSelected && bgTransparency != 255){
getStyle().setBgTransparency(255);
revalidateWithAnimationSafety();
}else if (!isSelected && bgTransparency != 0){
getStyle().setBgTransparency(0);
revalidateWithAnimationSafety();
}
}
Note: Also prefer revalidateWithAnimationSafety() to revalidate() in almost all cases. The only exception is when you are calling revalidate() to update layout and you need to access the updated layout coordinates immediately. The difference is that, if there is an animation in progress, revalidate() may cause it to be janky as it will interrupt the transitions.
The text was updated successfully, but these errors were encountered:
The
update()
method on a view may be called a lot, including circumstances when the state of the view is already fine. Try to avoid UI mutations or expensive calls likerevalidate()
unless required.E.g. In DishAddOnView.java's update method we have:
I would guard against both the setBgTransparency() calls and the revalidate, as follows:
Note: Also prefer
revalidateWithAnimationSafety()
torevalidate()
in almost all cases. The only exception is when you are callingrevalidate()
to update layout and you need to access the updated layout coordinates immediately. The difference is that, if there is an animation in progress,revalidate()
may cause it to be janky as it will interrupt the transitions.The text was updated successfully, but these errors were encountered: