"Android Source design mode"--builder mode

Source: Internet
Author: User

NO1:

Separates the construction of a complex object from its representation so that the same build process can create different representations

No2:

In the Android source code, the most commonly used Builder mode is alertdialog.builder

No3:

The concrete implementation of WindowManager in the Java layer is that the Setwindowmanager function of the Windowmanagerimpl,window object links the Window object to the WindowManager

Adding a view, removing the view, updating the layout of the view, and so on, gave the Windowmanagerglobal this class

The AddView method of WindowManager actually calls the AddView method in Windowmanagerglobal

Call Viewrootimpl's Setview method to display the view to the phone window

No4:

Viewrootimpl inherits from the handler class as a bridge for communication between the native layer and the Java Layer View system

NO5:

The Android framework and the Windowmanagerservice are also communicated through the binder mechanism.

NO6:

Windowmanagerservice manages not window, but view, but it manages the view that belongs to a window.

No7:

In the draw () function, you get the area you want to draw, and you decide whether to draw using the GPU. In general, CPU drawing is used, which is called the Drawsoftware function to draw.

No8:

View Tree Drawing steps :

1) Decide whether to use CPU drawing or GPU drawing

2) Get the Surface object for drawing surfaces

3) Get and lock canvas drawing objects from surface objects

4) Start the whole tree drawing process from Decorview

5) Surface object unlocks canvas and notifies Surfaceflinger to update view

No9:

Windowmanagerservice system

No10:

Advantages :

1) Good encapsulation, using builder mode allows the client to not need to know the details of the internal composition of the product

2) builders are independent and easy to expand

cons : Generates redundant builder objects and director objects, consumes memory

"Android Source design mode"--builder mode

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.