I would like to show a retry button when my application cannot load a page. As far as I understand, whenever this happens, the onReceiveError()
method on WebViewClient
is called.
I have a piece of code that does an animation. It makes a button visible and animates the y
property of it until it reaches the middle of the screen. However, I would like to be able to fire this piece of code in the onReceiveError()
method, and animate the button down and make it invisible when onPageFinished()
happens.
My problem is not with the animation bit of the code. My problem is in where to put it. I can't put the animation code inside the WebViewClient
since as I said above, I have to reach through the WebView
to its parent activity, and animate a Button
defined on that activity. This violates every object-oriented best practice I'm aware of, so I have a bad feeling about it. However, I don't know where else I can put it. I'm looking for a best practice defined by the community on code like this, where a dependency of a view (i.e. WebViewClient
) needs to change something on an activity.
I'm new to Android development, so please be gentle.