How to determine LAST PictureListener.onNewPicture() call?
On one hand, WebViewClient.onPageFinished()
is a great way to tell when a web page finished loading (as in HttpGet) but it will not tell me when the web page has finished rendering.
On the other hand, there is PictureListener.onNewPicture()
which notifies me whenever the page has been (re)rendered.
This is great for most cases, but for pages which are heavily Javascript-rendered (like YouTube, for example), I need to be able to know when the last such render (for that page) occurred.
Something like PictureListener.onNewPictureFinished()
.
Such function doesn't exist, of course, in PictureListener, so I am now wondering whether it is possible t开发者_运维技巧o come up with similar functionality or workaround?
Any ideas how to determine last PictureListener.onNewPicture()
call?
(one idea that I have is to set a timer that will decide that "if within X seconds no onNewPicture() has been called, then the previous one must have been the last". This is an extremely inaccurate & fuzzy approach, which is guaranteed to fail in many scenarios).
I had the same question in a bit different situation.
API doesn't provide callback for the last onNewPicture, because
WebView itself doesn't know current picture is last or not.
Your workaround with some optimization is enough good...
If you have a chance to change html, you can include js-callback through JavaScript Interface.
For example, it will be called when video will finish.
精彩评论