0

I'm wondering why the post() method is a specific to a View and not just a static method. It doesn't seem like the Runnable argument is closely tied to a specific view anyway.

I did find this other question which explains that (as of 4 years ago) the runnable will be run after the view has been drawn, but that doesn't quite answer my question. What event is fired after all views are fully drawn?

Community
  • 1
  • 1
Ed Lee
  • 187
  • 2
  • 13

1 Answers1

0

Because it decides which handler to post the event to based on a few different criteria. Check the code at the AOSP. If the view is attached to a window, it uses the one in the attach info. If not, it uses the ViewRoot.getRunQueue and posts it there. So there's a possibility of it posting to different handlers if, for example, you had a view in a different window like a Toast you were calling post on. Thus the need for a non-static function.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • "decides which handler to post the event to" - but the handlers are all ultimately called by the ui/main thread in a global run queue? – Ed Lee Oct 13 '15 at 10:00