The Android platform does not support gif dynamic
images. In order to present dealing, countdown and other
animations, the frame by frame animation is employed. There
is evidence to indicate that a smooth dealing animation will be
presented when a series of similar images are played at a speed
of 50 frames per second. However, the main aspect of the
problem is that the generation of a frame by frame animation
needs to call the sleep() method for delaying, which will block
main UI thread. Therefore, for the sake of implementing a
custom animation without blocking the main thread, it is most
desirable to create a new thread and introduce the Handler
mechanism for each animation. The new thread sends message
used for updating the view to the main thread by the help of a
Handler object instantiated in the main thread at a speed of a
few times per second. Meanwhile, the handleMessage()
method of the Handler object is modified for receiving the
message, with the canvas redraw by calling the invalidate()
method as soon as it obtains the valid data in the message.
Eventually, the start() method is called for running the new
worker thread while the animation needs to be generated.
When we are finished with these, a fluent animation will be
presented on the canvas.