ActivityState - Business Unit Gallery

ActivityState - Business Unit gallery
    many APK at design time, different service presentation will be processed through different traffic separating Activity to achieve the purpose; however, the overall framework of Gallery2, many operations are implemented in a Activity in, such as time shaft, big picture view, slide Sorter. I will not speak here Gallery2 motivation and benefits of doing so, the following pages will detail; there is a very difficult issue to face: so much business logic intertwined, how abstract divestiture of code, make the code clear logic, easy to maintain?
    Gallery2 designed a very critical ActivityState class, inherit different business needs it to achieve their business functions; Gallery2 inherited habit ActivityState achieve business class called XxxPage on, such as the class name of the timeline is TimeBucketPage, slide the class name is SlideShowPage, the class name to enlarge the interface is PhotoPage; various business exchange Page displays on the formation of the basic business functions in the library with an Activity; such as from the timeline click on the thumbnail to view the pictures, that is, switching from the TimeBucketPage to PhotoPage .

StateManager - service element manager
    service logic has been isolated by ActivityState, then depending on a business requirements Activity, there may be two or more subclass ActivityState different services, how to manage switching between these services? For example, click on the thumbnail to view the pictures need to enter the interface, return to the timeline in the user interface to view pictures from the press back key need timeline;
    Gallery2 introduces a different ActivityState management classes, called StateManager, it contains a ActivityState stack to manage these ActivityState different services; for example, from the timeline click on the thumbnail to view the pictures, this time PhotoPage stack, stack bottom is TimeBucketPage; press the back key to return to the user interface to view pictures timeline, this time PhotoPage the stack, the stack is TimeBucketPage; when the stack is empty, such as TimeBucketPage also popped up, then that at this time there is no need to deal with the business, the Activity can finish himself;

Guess you like

Origin blog.csdn.net/qq_42894864/article/details/102668409