Reputation: 336
I'm working on an app that downloads information from my server after an NFC card has been detected.
When a card is detected, I start - an Asynctask to download some data from my server - an animation of a popup appearing on the screen
After both the asynctask and the animation are done, I want to start a method that displays the downloaded data in the popup.
What is the correct way to trigger this new method? It can only start when both conditions are met.
Upvotes: 0
Views: 76
Reputation: 157457
you Animation
object has the method setAnimationLister
. It takes as parameter a Class Object that implements the interface Animation.AnimationListener
. This interface requires three methods to be implemented:
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
The onAnimationEnd
is triggered when the animation ends. If I have not misunderstood you, this is what you need
EDIT:
you could have two booleans value, boolean animationFinished = false, downloadFinished = false
; When onPostExecute
is called put downloadFinished
to true and call yourMethod
.
When onAnimationEnd
is triggered animationFinished = true
and call yourMethod
. yourMethod
should start like:
if (!animationFinished || !downloadFinished)
return;
Upvotes: 0
Reputation: 11
In the async task you use to download data add the onPostExecute method to remove the animation popup and show the downloaded data as well like this :
protected void onPostExecute(Long result) {
//put code to disable animation popup
//code for displaying downloaded data popup
}
For more info check out http://developer.android.com/reference/android/os/AsyncTask.html
Upvotes: 1