CN106126260A - A kind of delayed data loading method and device - Google Patents
A kind of delayed data loading method and device Download PDFInfo
- Publication number
- CN106126260A CN106126260A CN201610513519.9A CN201610513519A CN106126260A CN 106126260 A CN106126260 A CN 106126260A CN 201610513519 A CN201610513519 A CN 201610513519A CN 106126260 A CN106126260 A CN 106126260A
- Authority
- CN
- China
- Prior art keywords
- message
- data loading
- last
- placement
- message queue
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Telephone Function (AREA)
Abstract
The invention discloses a kind of delayed data loading method and device, wherein, the method includes: being placed into the last of View message queue by placing message, described placement message includes data loading messages;Perform described placement message, so that described data loading messages is placed into the last of main thread message queue.Compared with prior art, data loading messages is placed into the last of main thread message queue by above-mentioned steps by the application, and other message comprised in main thread message queue include View initial message, thus, after the View initial message that can comprise in main thread has performed, data loading messages is performed again after i.e. corresponding A pp interface has started, load the required data loaded in this App interface, thus avoid data and load the impact that App interface is started, improve the toggle speed at App interface.
Description
Technical field
The present invention relates to start-up technique field, APP interface, more particularly, it relates to a kind of delayed data loading method and dress
Put.
Background technology
The startup of Android App and the startup at interface, typically can be along with the initialization of View and the acquisition of data.
But, when the data volume involved by interface is relatively large for App, interface spends during starting
Time is the most long, and this time will be embodied directly on the toggle speed at interface, causes the toggle speed at interface relatively
Slowly.
Therefore, if prior art existing the data volume involved by App interface cause the startup speed at this interface compared with conference
Spend slower problem.
Summary of the invention
It is an object of the invention to provide a kind of delayed data loading method and device, to solve present in prior art such as
Really the data volume involved by App interface causes the slower problem of the toggle speed at this interface compared with conference.
To achieve these goals, the present invention provides following technical scheme:
A kind of delayed data loading method, including:
Being placed into the last of View message queue by placing message, described placement message includes data loading messages;
Perform described placement message, so that described data loading messages is placed into the last of main thread message queue.
Preferably, it is placed into the last of View message queue by placing message, including:
Described placement message is placed into the last of View message queue by the Post () method utilizing DecorView.
Preferably, perform described placement message, including:
Described placement message is performed in perform Traversals () method.
Preferably, described data loading messages is placed into main thread message queue last after, also include:
Place after described data loading messages and preset call back function.
A kind of data delay charger, including:
First placement module, for being placed into the last of View message queue by placing message, described placement message comprises
There is data loading messages;
Perform module, be used for performing described placement message, described data loading messages to be placed into main thread message team
Arrange is last.
Preferably, described first placement module includes:
Placement unit, for utilizing the Post () method of DecorView that described placement message is placed into View message team
Arrange is last.
Preferably, described execution module includes:
Performance element, for performing described placement message in perform Traversals () method.
Preferably, also include:
Second placement module, presets call back function for placing after described data loading messages.
A kind of delayed data loading method of present invention offer and device, wherein, the method includes: will place message and place
Last to View message queue, described placement message includes data loading messages;Perform described placement message, with by described
Data loading messages is placed into the last of main thread message queue.Compared with prior art, passing through above-mentioned steps in the application will
Data loading messages is placed into the last of main thread message queue, and other message comprised in main thread message queue include
View initial message, thus, it is possible to after the View initial message comprised in main thread has performed, i.e. corresponding A pp circle
Face performs data loading messages after having started again, loads the required data loaded in this App interface, thus avoids data and load
The impact starting App interface, improves the toggle speed at App interface.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
In having technology to describe, the required accompanying drawing used is briefly described, it should be apparent that, the accompanying drawing in describing below is only this
Inventive embodiment, for those of ordinary skill in the art, on the premise of not paying creative work, it is also possible to according to
The accompanying drawing provided obtains other accompanying drawing.
The flow chart of a kind of delayed data loading method that Fig. 1 provides for the embodiment of the present invention;
The boundary having in Android develops in a kind of delayed data loading method that Fig. 2 provides for the embodiment of the present invention
Face renders readjustment schematic diagram;
The structural representation of a kind of data delay charger that Fig. 3 provides for the embodiment of the present invention.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Describe, it is clear that described embodiment is only a part of embodiment of the present invention rather than whole embodiments wholely.Based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under not making creative work premise
Embodiment, broadly falls into the scope of protection of the invention.
Refer to Fig. 1, it illustrates the flow chart of a kind of delayed data loading method that the embodiment of the present invention provides, permissible
Comprise the following steps:
S11: be placed into the last of View message queue by placing message, places message and includes data loading messages.
It should be noted that the message comprised in View message queue is in the start-up course of App interface involved
View initial message and data loading messages, wherein, View initial message is and realizes View by performing these message
Initialization, and then display App interface, and data loading messages is the acquisition realizing data by performing this message, for App
Use.
The generally message in View message queue need to be sent in main thread message queue, so that main thread is to relevant
Message performs.By the placement comprising data loading messages message is placed into the last of View message queue, it is possible to protect
Demonstrate,prove this placement message to be finally performed, namely make the data loading messages comprised in placement message be placed to main thread message
Queue last.
S12: perform to place message, so that data loading messages is placed into the last of main thread message queue.
Placement message is and data loading messages is placed into the message that main thread message queue is last, therefore, performs to put
Put the process of message to be data loading messages is put into the process that main thread message queue is last.Thereby, it is possible to make data
Loading messages performs after other message have all performed again, namely has performed at View initial message and completed interface
Startup after perform again, thus strictly distinguished interface render the loading with data, refined the life cycle at interface, it is to avoid
Interface is rendered and to impact by the loading of data.
Compared with prior art, data loading messages is placed into main thread message queue by above-mentioned steps by the application
Last, and other message comprised in main thread message queue include View initial message, thus, it is possible in main thread
After the View initial message comprised has performed, after i.e. corresponding A pp interface has started, perform data loading messages again, load
The required data loaded in this App interface, thus avoid data and load the impact that App interface is started, improve App interface
Toggle speed.
It should be noted that need from data base or configuration file for data or be the App obtained from network
Interface, the above-mentioned steps that the present invention provides is actually the suitable data load(ing) point of searching, to reach first to render interface, reloads
The purpose of data.
Specifically, in Android develops, there is interface as shown in Figure 2 and render readjustment, including onCreate () side
Method, onResume () method etc..At these in the readjustment of the life cycle of interface element, it is possible to achieve the loading of data, enter
And realize the initialization of interface and data, complete the startup at interface.But, onCreate () method carries out the loading of data
Or the startup of asynchronous thread all needs to consume CPU time, and the code that these part data load can't affect boundary
Rendering of face, but occur in during interface renders together with but initializing with View, and then it is white to cause interface to start the time
White increase.
Inventor finds, there is also some sides not being declared out after the method calls such as onCreate () method
Method is used as the process (i.e. other funs in figure) that interface renders, it is thereby possible to select right in method in this section
Data load and carry out relevant setting.
Before the onCreate () method call of Activity, attach () method can be called, in attach () method
A PhoneWindow can be created the when of calling, this PhoneWindow has individual DecorView, this DecorView
Being a View of all Activity bottoms, class is FrameLayout, and it has all characteristics of View, and can be
OnCreate () method is initialised.
The onCreate () method of Activity has done a lot of initialized operation, including PhoneWindow/
DecorView/StartingView/setContentView etc., but to be really set to show then Resume () when,
But these are transparent to developer, specifically can see the handleResumeActivity () side of ActivityThread
Method, the other funs that the method is contained in Fig. 2, adjusts back it except calling the onResume () of Activity in this method
Outward, ViewRootImpl/ThreadedRenderer etc. also it is initialized.Wherein, ViewRootImpl upon initialization,
DecorView is set to the value of the root object of oneself, therefore show that above described DecorView is the interface bottom
The conclusion of View.
Owing to View can maintain the message queue oneself sent rendering when, i.e. View message queue, but
It is that this message queue is eventually performed acquired in the Looper of main thread and at main thread, so, if data are added
Carrying message and be placed into after View rendered, that just can wait View to render and perform this message afterwards.And DecorView is
The View of the interface bottom, therefore, it can that the placement message including data loading messages is placed into DecorView corresponding
View message queue last.
Wherein it is possible to be placed into the last of View message queue by the post () method of DecorView by placing message,
I.e. itself is preferably placed into the last of View message queue by placing message, may include that the Post utilizing DecorView
() method is placed into the last of View message queue by placing message.The post () method of DecorView can call self
The Handler.post () method of one variables A ttachInfo, and AttachInfo is in ViewRootImpl, namely
HandleResumeActivity () method is carried out initialized, and the Looper of its Handler object is main thread
Looper.Accordingly, because in onCreate () method, DecorView is initialized, but AttachInfo is also the most initial
Change, so can directly skip AttachInfo placing by the post () method of DecorView in onCreate () method
Message is placed into the last of the View message queue of DecorView.
In a kind of delayed data loading method that the embodiment of the present invention provides, perform to place message, may include that
Perform Traversals () method performs place message.
Message in View message queue can be held in the performTraversals () method of ViewRootImpl
OK, wherein, performTraversals () method is responsible for the drafting of each frame of View in fact, so having only at this
Data loading messages is placed into the last of main thread message queue by the execution of method, after i.e. having performed the method, performs number again
According to loading messages, so that it may ensure to have rendered at View to perform data loading messages afterwards.
It should be noted that when ViewRootImpl performs performTraversals () method for the first time, can perform
The initialization logic of Egl, then can re-execute performTraversals () method, therefore, eventually in second time
Data loading messages is performed after calling the method;That is, in order to data loading messages will not be performed for the first time
Consumed after performTraversals () method, this message can be again added in View message queue, pass through
Pack the shell of one layer of Runnable again, reach after second time performs performTraversal () method, to perform data loading and disappear
Breath.
In a kind of delayed data loading method that the embodiment of the present invention provides, data loading messages is placed into main thread and disappears
Breath queue last after, it is also possible to including:
Place after data loading messages and preset call back function.
It should be noted that this default call back function can be an interface of definition, this interface has one and adds
The method carrying data, then realizes this interface loading data in the Activity need delay loading, finally adds in data
Carry in message and call this function.Can also be a self-defining function of the Activity needing delay loading equally,
As long as calling this function in data loading messages.
Because this function has carried out in above-described embodiment the packaging of twice message dilivery, and this process is to fix not
Become, so after plus this invoked procedure (i.e. plus presetting call back function), developer has only to focus on this letter
How loading data in number, and need not rewrite and understand this process, improve the work efficiency of developer.
Corresponding with above-described embodiment, the embodiment of the present invention additionally provides a kind of data delay charger, such as Fig. 3 institute
Show, may include that
First placement module 11, for being placed into the last of View message queue by placing message, places message and includes
Data loading messages;
Perform module 12, be used for performing placing message, data loading messages is placed into main thread message queue
After.
In a kind of data delay charger that the embodiment of the present invention provides, the first placement module may include that
Placement unit, for utilizing the Post () method of DecorView to be placed into View message queue by placing message
Finally.
In a kind of data delay charger that the embodiment of the present invention provides, perform module and may include that
Performance element, for performing placement message in perform Traversals () method.
In a kind of data delay charger that the embodiment of the present invention provides, it is also possible to including:
Second placement module, presets call back function for placing after data loading messages.
It should be noted that the explanation of relevant portion please in a kind of data delay charger of embodiment of the present invention offer
See the detailed description of corresponding part in a kind of delayed data loading method that the embodiment of the present invention provides, do not repeat them here.
Described above to the disclosed embodiments, makes those skilled in the art be capable of or uses the present invention.To this
The multiple amendment of a little embodiments will be apparent from for a person skilled in the art, and generic principles defined herein can
With without departing from the spirit or scope of the present invention, realize in other embodiments.Therefore, the present invention will not be limited
It is formed on the embodiments shown herein, and is to fit to consistent with principles disclosed herein and features of novelty the widest
Scope.
Claims (8)
1. a delayed data loading method, it is characterised in that including:
Being placed into the last of View message queue by placing message, described placement message includes data loading messages;
Perform described placement message, so that described data loading messages is placed into the last of main thread message queue.
Method the most according to claim 1, it is characterised in that be placed into the last of View message queue by placing message,
Including:
Described placement message is placed into the last of View message queue by the Post () method utilizing DecorView.
Method the most according to claim 2, it is characterised in that perform described placement message, including:
Described placement message is performed in perform Traversals () method.
4. according to the method described in any one of claims 1 to 3, it is characterised in that described data loading messages is placed into master
Thread message queue last after, also include:
Place after described data loading messages and preset call back function.
5. a data delay charger, it is characterised in that including:
First placement module, for being placed into the last of View message queue by placing message, described placement message includes number
According to loading messages;
Perform module, be used for performing described placement message, so that described data loading messages is placed into main thread message queue
Finally.
Device the most according to claim 5, it is characterised in that described first placement module includes:
Placement unit, for utilizing the Post () method of DecorView that described placement message is placed into View message queue
Finally.
Device the most according to claim 6, it is characterised in that described execution module includes:
Performance element, for performing described placement message in perform Traversals () method.
8. according to the device described in any one of claim 5 to 7, it is characterised in that also include:
Second placement module, presets call back function for placing after described data loading messages.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610513519.9A CN106126260A (en) | 2016-07-01 | 2016-07-01 | A kind of delayed data loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610513519.9A CN106126260A (en) | 2016-07-01 | 2016-07-01 | A kind of delayed data loading method and device |
Publications (1)
Publication Number | Publication Date |
---|---|
CN106126260A true CN106126260A (en) | 2016-11-16 |
Family
ID=57468139
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610513519.9A Pending CN106126260A (en) | 2016-07-01 | 2016-07-01 | A kind of delayed data loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106126260A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108694066A (en) * | 2018-05-09 | 2018-10-23 | 北京酷我科技有限公司 | A kind of method that tableView delays refresh |
CN109117203A (en) * | 2018-07-13 | 2019-01-01 | 广州小鹏汽车科技有限公司 | A kind of Android APP starting velocity optimization method and system |
CN109359256A (en) * | 2018-09-29 | 2019-02-19 | 北京城市网邻信息技术有限公司 | Page loading method, device, equipment and storage medium |
CN110020275A (en) * | 2017-08-22 | 2019-07-16 | 武汉斗鱼网络科技有限公司 | Present panel loading method and system in a kind of live streaming |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104090787A (en) * | 2014-06-25 | 2014-10-08 | 可牛网络技术(北京)有限公司 | Starting method and starting device for home page of application software |
US20140380313A1 (en) * | 2013-06-04 | 2014-12-25 | Tencent Technology (Shenzhen) Company Limited | Method and device for loading android virtual machine application |
-
2016
- 2016-07-01 CN CN201610513519.9A patent/CN106126260A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140380313A1 (en) * | 2013-06-04 | 2014-12-25 | Tencent Technology (Shenzhen) Company Limited | Method and device for loading android virtual machine application |
CN104090787A (en) * | 2014-06-25 | 2014-10-08 | 可牛网络技术(北京)有限公司 | Starting method and starting device for home page of application software |
Non-Patent Citations (3)
Title |
---|
GRACKER: "《简书:https://www.jianshu.com/p/45fab958e1d1》", 19 March 2016 * |
ZRZ05: "《csdn:https://blog.csdn.net/square_l/article/details/17681885》", 30 December 2013 * |
程序园网: "《程序园网:http://www.phperz.com/article/16/0115/183402.html,以及其他公开的网站》", 15 January 2016 * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110020275A (en) * | 2017-08-22 | 2019-07-16 | 武汉斗鱼网络科技有限公司 | Present panel loading method and system in a kind of live streaming |
CN108694066A (en) * | 2018-05-09 | 2018-10-23 | 北京酷我科技有限公司 | A kind of method that tableView delays refresh |
CN108694066B (en) * | 2018-05-09 | 2021-04-27 | 北京酷我科技有限公司 | TableView delayed refreshing method |
CN109117203A (en) * | 2018-07-13 | 2019-01-01 | 广州小鹏汽车科技有限公司 | A kind of Android APP starting velocity optimization method and system |
CN109359256A (en) * | 2018-09-29 | 2019-02-19 | 北京城市网邻信息技术有限公司 | Page loading method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106126260A (en) | A kind of delayed data loading method and device | |
US8468514B2 (en) | System and method for updating unified extensible firmware interface setting information | |
CN110502340A (en) | A kind of resource dynamic regulation method, device, equipment and storage medium | |
CN102880477B (en) | A kind of method realizing computer starting and computer | |
CN104239131B (en) | A kind of method and device for closing application program | |
CN104572054B (en) | A kind of capacity calling method and equipment | |
CN109582385A (en) | Application program launching method and device, storage medium and electronic equipment | |
CN111767090A (en) | Method and device for starting small program, electronic equipment and storage medium | |
CN106775699A (en) | The method that UI is updated in asynchronous thread | |
CN108809683A (en) | Dispose the method and device of cloud application system | |
CN106502962A (en) | The method of the operation of control process device core in electronic installation and electronic installation | |
WO2019136837A1 (en) | Intelligent load system, method and device, and storage medium | |
CN113961346A (en) | Data cache management and scheduling method and device, electronic equipment and storage medium | |
TW201826102A (en) | Execution of multiple applications on a device | |
CN104573110B (en) | The Dynamic Display method and device of figure in a kind of browser | |
CN110175101A (en) | A kind of exception catching method, apparatus and terminal | |
CN113268286A (en) | Application starting method and device, projection equipment and storage medium | |
CN112835639B (en) | Hook realization method, device, equipment, medium and product | |
CN113805954B (en) | Screen saver display method, electronic device and computer storage medium | |
CN106775879B (en) | VR application installation-free method and system based on android system client | |
CN106874020A (en) | Start the method and device of plug-in unit | |
CN107025126B (en) | Resource scheduling method, NFVO and system | |
CN110045997B (en) | Object initialization method, device, equipment and storage medium of basic function module | |
CN104392408A (en) | Image display system and method | |
CN110895473A (en) | Self-starting keep-alive system and method based on android mobile device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20161116 |
|
RJ01 | Rejection of invention patent application after publication |