I am doing heavy work in a Switch onCheckedChanged(CompoundButton buttonView, boolean isChecked)
method. Namely I am doing Google Maps Cluster management (filter cluster items based on values).
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// memory heavy stuff starts happening here
}
My problem is that I want the heavy stuff to happen after the Switch has done its UI change (toggle + color change). Otherwise the UI is very laggy. Since I am dealing with Clusters I cannot do this heavy stuff on another thread because the cluster is drawing on main (UI) thread.
Question: Is there a way to dealy the onCheckedChange to be called after the Switch has done its thing on UI or a way to delay the onCheckedChange methods execution?