APP description
I am writing code for android EPub reader.
Book part (html) is loaded into WebView
Problem
After device rotation i am trying to scroll to last position in webview as text.
Data is loaded into webview by loadData(text, ..., ...) because I do not load webpage from URL, but from locally saved html in EPub file.
webView.loadData(text, "text/html; charset=UTF-8", null);
I found out this function is async and i have to wait until data is fully loaded and after that try to scroll.
I have tried adviced solutions such as
final int Y = savedInstanceState.getInt(CURRENT_WEBVIEW_POSITION_Y);
webView.postDelayed(new Runnable() {
    public void run() {
        if (webView.getProgress() == 100) {
            webView.postDelayed(new Runnable() {
                public void run() {
                    webView.scrollTo(0, Y);
                }
            }, 10);
        } else {
            webView.post(this);
        }
    }
}, 10);
or
final int Y = savedInstanceState.getInt(CURRENT_WEBVIEW_POSITION_Y);
while (webView.getProgress() < 100){
    Thread.sleep(50);
}
Thread.sleep(10);
webView.scrollTo(0, Y);
but they did not work.
Y position of webview is stored into and retrieved from bundle correctly.