Android Open source framework: nineoldandroid

Source: Internet
Author: User

In previous versions of android3.0, to implement animations, it was common to use the Nineoldandroid Open source framework, after which you could use the animation API provided by Android directly.

After a closer look at this open-source framework, you can see that there is a difference between this framework and the system's animation implementation. Major but not just a few points:

1. Calculate the flow of each frame animation: Animationhandler,nineoldandroid is inherited from the handler, in the message queue constantly processing the data of each frame animation, and the system is implemented runnable interface, processing in the thread

1 //nineoldandroid2 Private Static classAnimationhandlerextendshandler{3          Public voidHandlermessage () {4         ....5 sendemptymessagedelayed (...);6         }7 8 9 //Android SystemTen protected Static classAnimationhandlerImplementsRunnable { One         //The per-thread list of all active animations A         /**@hide*/ -         protected FinalArraylist<valueanimator> manimations =NewArraylist<valueanimator>(); -  the         //used in Doanimationframe () to avoid concurrent modifications of manimations -         Private FinalArraylist<valueanimator> mtmpanimations =NewArraylist<valueanimator>(); -  -         //The per-thread set of animations to being started on the next animation frame +         /**@hide*/ -         protected FinalArraylist<valueanimator> mpendinganimations =NewArraylist<valueanimator>(); +  A         /** at * Internal Per-thread collections used to avoid set collisions as animations start and end - * While being processed. - * @hide -          */ -         protected FinalArraylist<valueanimator> mdelayedanims =NewArraylist<valueanimator>(); -         Private FinalArraylist<valueanimator> mendinganims =NewArraylist<valueanimator>(); in         Private FinalArraylist<valueanimator> mreadyanims =NewArraylist<valueanimator>(); -  to         Private Finalchoreographer Mchoreographer; +         ..... -}
View Code

2. Choreographer: Unlike the open source framework, the Android system also introduces the choreographer (choreographer), which coordinates animation time, drawing, and so on. The main thing is that the vsync is provided in the choreographer: Vertical interrupt.

Choreographer coordinates each frame of time, using a callback function to execute the Runnable.run. Can make the animation display smoother, no animation lag, picture tearing and other conditions. Some of the more specific knowledge about VSync can be Baidu.

Android Open source framework: nineoldandroid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.