I have helper methods that set the visibility of certain View
s depending on the state variables that are passed into the methods. Sometimes, these methods will get called many times and the View
s visibility will not change. So I found myself starting to check the visibility of each View
before setting it with the thinking, "No point in changing a View's visibility to the same visibility and causing a refresh for no reason".
if (myView.getVisibility() != View.VISIBLE) {
myView.setVisibility(View.VISIBLE);
}
etc...
However, now I'm wondering if the implementation of setVisibility
already takes this into account, and checks if you are setting the same visibility to what the View
already has, and doesn't needlessly refresh the View
(what my code is trying to do).
So does anyone know if my "optimization" is actually improving any performance, or is the API already a step ahead of me?