Page display method and device, electronic equipment and storage medium
By obtaining the layout file and generating view data in the Android operating system, and using multi-threading to asynchronously generate the view tree, the problem of slow application page display speed and poor fluency is solved, and faster page display is achieved.
Patent Information
- Application Number
- CN202310332554.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-30
- Publication Date
- 2024-10-01
AI Technical Summary
Under the Android operating system, the display speed of application pages is slow and the smoothness is poor, mainly because the layout file is converted into a view tree through a single thread, which leads to increased generation and display time.
By obtaining the layout file, generate view data and use at least two processing threads to asynchronously generate the target view tree, avoiding single-thread processing and improving the generation and display speed.
The target view tree generation speed and page display speed are improved, and the problems of slow display speed and poor fluency are solved.
Smart Images

Figure CN118733153A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, and in particular to a page display method, device, electronic device, and storage medium. Background Art
[0002] In the Android operating system, the page layout of the program page in the application (Application, APP) can be described by a layout file. In the prior art, when running the application, the layout file is usually directly converted into a view tree (ViewTree) through the interface provided by the operating system, and then the program page is rendered and displayed based on the view tree.
[0003] However, the methods for displaying program pages in the prior art have problems such as slow display speed and poor display fluency. Summary of the invention
[0004] The embodiments of the present disclosure provide a page display method, device, electronic device and storage medium to overcome the problems of slow program page display speed and poor display fluency in the prior art.
[0005] In a first aspect, an embodiment of the present disclosure provides a page display method, including:
[0006] Obtain a layout file of a target page, wherein the layout file is used to represent the page layout of the target page; obtain view data of the target page based on the layout file, wherein the view data is used to represent the view properties of the view objects in the target page; based on the view data, asynchronously generate a target view tree corresponding to the target page through at least two processing threads; and display the target page based on the target view tree.
[0007] In a second aspect, an embodiment of the present disclosure provides a page display method and device, including:
[0008] An acquisition module, used for acquiring a layout file of a target page, wherein the layout file is used for representing a page layout of the target page;
[0009] A generating module, used to obtain the view data of the target page according to the layout file, wherein the view data is used to represent the view attributes of the view object in the target page;
[0010] A processing module, configured to asynchronously generate a target view tree corresponding to the target page through at least two processing threads based on the view data;
[0011] A display module is used to display the target page based on the target view tree.
[0012] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0013] A processor, and a memory communicatively connected to the processor;
[0014] The memory stores computer-executable instructions;
[0015] The processor executes the computer-executable instructions stored in the memory to implement the page display method described in the first aspect and various possible designs of the first aspect.
[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the page display method described in the first aspect and various possible designs of the first aspect is implemented.
[0017] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the page display method described in the first aspect and various possible designs of the first aspect.
[0018] The page display method, device, electronic device and storage medium provided in this embodiment obtain the layout file of the target page, the layout file is used to represent the page layout of the target page; according to the layout file, the view data of the target page is obtained, the view data is used to represent the view attributes of the view object in the target page; based on the view data, a target view tree corresponding to the target page is asynchronously generated by at least two processing threads; and the target page is displayed based on the target view tree. By converting the layout file into view data that can be processed asynchronously by multiple threads, and then processing the view data by multiple threads, the corresponding target view tree of the target page is generated, and finally the display of the target page is realized based on the target view tree. The problem of only being able to process the layout file by a single thread due to directly calling the system interface is avoided, thereby improving the generation speed of the target view tree and the display speed of the target page. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0020] Figure 1 An application scenario diagram of the page loading method provided in the embodiment of the present disclosure;
[0021] Figure 2 Schematic diagram of the process of the page display method provided in the embodiment of the present disclosure Figure 1 ;
[0022] Figure 3 A schematic diagram of a structure of a packaged view tree provided in an embodiment of the present disclosure;
[0023] Figure 4 for Figure 2 A flowchart of a specific implementation method of step S102 in the illustrated embodiment;
[0024] Figure 5 for Figure 4 A flowchart of a specific implementation method of step S1022 in the illustrated embodiment;
[0025] Figure 6 A schematic diagram of generating a target view tree provided by an embodiment of the present disclosure;
[0026] Figure 7 Schematic diagram of the process of the page display method provided in the embodiment of the present disclosure Figure 2 ;
[0027] Figure 8 A schematic diagram of a multi-threaded view object creation method provided by an embodiment of the present disclosure;
[0028] Fig. 9 for Figure 7 A flowchart of a specific implementation method of step S203 in the illustrated embodiment;
[0029] Fig.10 for Fig. 9 A flowchart of a specific implementation method of step S2033 in the illustrated embodiment;
[0030] Fig.11 A structural block diagram of a page loading device provided by an embodiment of the present disclosure;
[0031] Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure;
[0032] Fig.13 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0034] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0035] The application scenarios of the embodiments of the present disclosure are explained below:
[0036] Figure 1 This is an application scenario diagram of the page loading method provided in the embodiment of the present disclosure. The page loading method provided in the embodiment of the present disclosure can be applied to application development testing and application running scenarios. Specifically, Figure 1 As shown, the method provided by the embodiment of the present disclosure can be applied to a target terminal device, such as a personal computer. As shown in the figure, after designing the page layout in the application (Application, APP) based on the specific needs of program development, the program developer generates a layout file (such as an extensible markup language file) representing the page layout. After that, the development terminal device compiles the layout file together with other data and files used to implement the functions of the application, generates an installation package of the application (such as a configuration file, executable file, library file, etc. of the application), and sends the installation package to the server for the target terminal device (other users) to download, install and run. In the process of the target terminal device running the application, when the page layout needs to be loaded, the layout file in the installation package is read, and the target page is loaded based on the page layout represented by the layout file to realize the display of the target page. Of course, in other possible implementations, the installation package may include a code program obtained after compiling the layout file. In another possible implementation, the above-mentioned process of generating the installation package of the target program can also be executed on the server side. After receiving the necessary input data and instructions, the server executes the above-mentioned method of generating the installation package of the application, and the other process steps are similar and will not be repeated.
[0037] In the prior art, taking the Android operating system as an example, in the process of running an application, the layout file is usually directly converted into a view tree (ViewTree) containing multiple view objects (View) through the interface provided by the operating system, such as the LayoutInflater API, and then the program page is rendered and displayed based on the view tree. However, in the above process of generating the view tree, the interface provided by the operating system parses the layout file through a single thread and generates a corresponding view tree. Therefore, when the content in the layout file is large and the number of view objects involved is large, the solution of using the interface provided by the system to generate the view tree through a single thread will increase the time consumption, thereby causing problems such as slow display speed and poor display fluency of the target page. The disclosed embodiment provides a page display method to solve the above problems.
[0038] refer to Figure 2 , Figure 2 Schematic diagram of the process of the page display method provided in the embodiment of the present disclosure Figure 1 The method of this embodiment can be applied in a terminal device. The page display method includes:
[0039] Step S101: obtaining a layout file of a target page, where the layout file is used to represent the page layout of the target page.
[0040] For applications running on the terminal device side, such as live broadcast APP, short video APP, instant messaging APP, etc., the target page refers to a specific program page in the application, such as the home page, live broadcast page, etc. The page layout of the target page is expressed through multiple view objects (View). Specifically, the view object corresponds to a visible area on the screen, which is responsible for displaying an area and responding to events in this area. Common ones include TextView, ImageView, Button, Linearlayout, RelativeLayout, etc. Furthermore, the view object has view attributes, which are used to characterize information such as the style, size, position, etc. of the view object. The specific implementation of the view data corresponds to the specific type of the view object, and will not be repeated one by one. Among them, the view data of the view object is recorded in the layout file of the target page, so that the page layout description of the target page is realized through the layout file.
[0041] Furthermore, the layout file is, for example, an Extensible Markup Language (XML) file, wherein the application includes multiple program pages for implementing different functions, each program page corresponds to a different page layout, and therefore, each program page may correspond to a layout file. Of course, in other possible implementations, the layout of all program pages in the application may be described by a layout file, and the page layouts of different program pages may be divided by the specific content format in the layout file.
[0042] Step S102: obtaining view data of the target page according to the layout file, where the view data is used to represent view properties of the view objects in the target page.
[0043] Exemplarily, after obtaining the layout file corresponding to the target page, the layout file is parsed to obtain the information contained in the layout file for representing the page layout of the target page. Exemplarily, the layout file contains the view attributes of the view object corresponding to the target page. After parsing the layout file, the view attributes of each view object are obtained. After that, the view attributes of each view object are respectively encapsulated to obtain a data set that can represent the view attributes of each view object in the target page, that is, view data. The specific data format of the video data can be multiple, such as a structure.
[0044] In one possible implementation, the view data includes an encapsulated view tree, the encapsulated view tree has the same tree structure as the target view tree, the encapsulated view tree includes at least two encapsulated view objects, and the encapsulated view objects are used to store view attributes of view objects at corresponding positions on the target view tree. Exemplarily, the encapsulated view tree is a tree structure composed of encapsulated view objects, and the tree structure corresponding to the encapsulated view tree is a one-level nested structure, that is, the outer layer (parent node) and inner layer (child node) of the encapsulated view tree have similar structures, and the encapsulated view tree can be expressed recursively. Furthermore, each tree node in the encapsulated view tree is an encapsulated view object, which is an encapsulation of the view attributes of the view object represented in the layout file, and the encapsulated view object contains the view attributes of the view object at the corresponding position. Figure 3 A schematic diagram of a structure of a packaged view tree provided in an embodiment of the present disclosure, such as Figure 3As shown, the encapsulated view tree is a tree structure with 4 nodes (Node), and each node is an encapsulated view object. As shown in the figure, the 4 encapsulated view objects are encapsulated view object Np_1, encapsulated view object Np_2, encapsulated view object Np_3 and encapsulated view object Np_4 (shown as Np_1, Np_2, Np_3 and Np_4 in the figure respectively). Among them, each encapsulated view object corresponds to a view object, and stores the view attributes of the corresponding view object. For example, as shown in the figure, encapsulated view object Np_1 corresponds to view object N_1, encapsulated view object Np_2 corresponds to view object N_2, encapsulated view object Np_3 corresponds to view object N_3, and encapsulated view object Np_4 corresponds to view object N_4; among them, view object N_1, view object N_2, view object N_3 and view object N_4 constitute the target view tree.
[0045] Furthermore, since the encapsulated view tree is generated based on the layout file, the encapsulated view tree has the same tree structure as the target view tree generated directly from the layout file (in the prior art). The steps of this embodiment are equivalent to parsing and splitting the layout file into data in a custom format, namely, view data, which contains all the information in the layout file. More specifically, the view data stores the hierarchical relationship between view objects in the form of an encapsulated view tree, and stores the view attributes corresponding to the view objects by the encapsulated view objects that constitute the encapsulated view tree, thereby achieving the representation of all the information in the layout file.
[0046] In one possible implementation, Figure 4 As shown, the specific implementation of step S102 includes:
[0047] Step S1021: Obtain a parsing tool corresponding to the layout file.
[0048] Step S1022: Based on the parsing tool, compile the layout file to obtain view data of each view object.
[0049] Exemplarily, after obtaining the layout file, the terminal device can determine the corresponding target parsing tool based on the format of the layout file and the current operating system. For example, under the Android operating system, the layout file is an extensible markup language (XML) file, and the Android compilation and packaging tool appt or appt2 can be selected as a parsing tool to compile the layout file. Among them, the specific implementation principle and use method of the Android compilation and packaging tool appt or appt2 are prior arts known to those skilled in the art and will not be repeated here.
[0050] After that, run the parsing tool to compile the layout file, generate program code, and assemble it according to a specific data format to get the above Figure 3 . For example, Figure 5 As shown, the specific implementation of step S1022 includes:
[0051] Step S1022A: Based on the parsing tool, convert the layout file into layout code.
[0052] Step S1022B: Create a mapping identifier corresponding to the layout code, where the mapping identifier is used to indicate the target page.
[0053] Step S1022C: based on the layout code and the corresponding mapping identifier, obtain the view data of the target page.
[0054] Exemplarily, based on the above introduction, for example, by compiling the layout file based on the Android compilation and packaging tool, the corresponding layout code can be obtained, wherein the layout code represents the view attributes of each view object corresponding to the target page in the form of program code (such as Java Code), and the implementation process of obtaining the layout code is not repeated. Afterwards, a corresponding mapping identifier is generated for the layout code, and the mapping identifier is used to index the layout code corresponding to the target page. Afterwards, view data is constructed based on the combination of the layout code and the corresponding mapping identifier.
[0055] Step S103: Based on the view data, a target view tree corresponding to the target page is asynchronously generated by at least two processing threads.
[0056] Exemplarily, after obtaining the view data, based on the special data structure of the view data, the view data can be processed through multi-threading. Specifically, the view data is a class, specifically a first attribute, a first method and a second method, wherein the first attribute is used to store the encapsulated view tree, the first method is used to generate the corresponding view object based on the encapsulated view tree; the second method is used to splice the view objects to generate the final target view tree. Figure 6 A schematic diagram of generating a target view tree provided by an embodiment of the present disclosure, such as Figure 6As shown, after obtaining the layout file, the layout file is converted into view data, wherein the view data includes a first attribute View_Attr, a first method create_View() and a second method build_ViewTree(). Afterwards, the terminal device calls the first method create_View() based on the view data, and creates view objects View_1, View_2 and View_3 (shown as View_1, View_2 and View_3 in the figure) through the first attribute View_Attr. Afterwards, the terminal device calls the second method build_ViewTree() to splice the view objects View_1, View_2 and View_3 to generate the target view tree.
[0057] Step S104: Display the target page based on the target view tree.
[0058] Exemplarily, after that, by rendering the target view tree created in the above steps, the content in the target page can be displayed. Among them, the specific implementation principle and method of displaying the content in the target page based on the view tree is the existing technology under the Android operating system and will not be repeated here.
[0059] In this embodiment, the layout file of the target page is obtained, and the layout file is used to represent the page layout of the target page; the view data of the target page is obtained according to the layout file, and the view data is used to represent the view attributes of the view object in the target page; based on the view data, a target view tree corresponding to the target page is asynchronously generated by at least two processing threads; and the target page is displayed based on the target view tree. By converting the layout file into view data that can be processed asynchronously by multiple threads, and then processing the view data by multiple threads, a target view tree corresponding to the target page is generated, and finally the display of the target page is realized based on the target view tree. The problem of only being able to process the layout file in a single thread due to directly calling the system interface is avoided, thereby improving the generation speed of the target view tree and the display speed of the target page.
[0060] refer to Figure 7 , Figure 7 Schematic diagram of the process of the page display method provided in the embodiment of the present disclosure Figure 2 In this embodiment Figure 2 On the basis of the illustrated embodiment, step S103 is further refined, and the page display method includes:
[0061] Step S201: Acquire a layout file of a target page, where the layout file is used to represent the page layout of the target page.
[0062] Step S202: According to the layout file, the view data of the target page is obtained, the view data includes an encapsulated view tree, the encapsulated view tree has the same tree structure as the target view tree, the encapsulated view tree includes at least two encapsulated view objects, and the encapsulated view objects are used to store view properties of view objects at corresponding positions on the target view tree.
[0063] Exemplarily, view data is data with a specific data structure, including an encapsulated view tree, which has the same tree structure as the target view tree, that is, the hierarchical relationship between each encapsulated view object in the encapsulated view tree is the same as the hierarchical relationship between each view object in the target page. The encapsulated view tree is obtained by parsing and compiling the layout file. More specifically, after parsing the layout file, the view attributes representing the view object are converted into binary data, and then packaged based on the binary data corresponding to each view object to obtain the encapsulated view object, and then the view data is obtained based on each encapsulated view object. For specific implementation methods, please refer to Figure 2 The embodiments shown are relevant and will not be described in detail here.
[0064] Step S203: asynchronously load each encapsulated view object in the encapsulated view tree through at least two processing threads, and create corresponding view objects.
[0065] Exemplarily, after the view data is obtained, the view data includes a packaged view tree composed of multiple packaged view objects, each of which is a relatively independent individual, so multi-threaded asynchronous processing can be performed to create a corresponding view object. Figure 8 A schematic diagram of a multi-threaded view object creation provided by an embodiment of the present disclosure, such as Figure 8 As shown, after obtaining the view data, the view data includes multiple encapsulated view objects, such as encapsulated view object Np_1, encapsulated view object Np_2, encapsulated view object Np_3 and encapsulated view object Np_4 shown in the figure. Then, the first method of the view data is called (for details, see Figure 2In the illustrated embodiment, the first thread creates a view object corresponding to each encapsulated view object (as described in the related introduction under step S103). This process can be implemented asynchronously through multiple threads. For example, as shown in the figure, the first thread creates a view object N_1 corresponding to the encapsulated view object Np_1, the second thread creates a view object N_2 corresponding to the encapsulated view object Np_2, and the third thread creates a view object N_3 corresponding to the encapsulated view object Np_3. After the first thread creates the view object N_1, the first thread is used to create the view object N_4 corresponding to the encapsulated view object Np_4. In the process of creating the above view objects, the first thread, the second thread and the third thread can be asynchronous. Therefore, compared with the steps of the single-thread queuing scheme for creating view objects in the prior art, the time consumption is greatly reduced, the generation process of the target view tree is improved, and the loading and display speed of the target page is improved.
[0066] For example, Fig. 9 As shown, the specific implementation of step S203 includes:
[0067] Step S2031: Determine the target number of processing threads based on the tree structure of the encapsulated view tree.
[0068] In a possible implementation, during the multi-threaded processing of the encapsulated view tree, the processing threads used can be dynamically created, specifically, the corresponding target number of processing threads is determined based on the tree structure of the encapsulated view tree. For example, the corresponding target number of processing threads can be determined based on the number of branches and nodes in the tree structure of the encapsulated view tree. In short, when the structure of the encapsulated view tree (view data) is simple and the amount of information contained is small, fewer processing threads are used for processing to improve the utilization of system resources; and when the structure of the encapsulated view tree (view data) is complex and the amount of information contained is large, more processing threads are used for processing to improve the generation speed of the target view tree.
[0069] Exemplarily, the encapsulated view object has a parent view attribute and / or a child view attribute, and the parent view attribute is used to indicate that the encapsulated view object corresponds to at least one parent encapsulated view object; the child view attribute is used to indicate that the encapsulated view object corresponds to at least one child encapsulated view object. Before step S2031, it also includes: determining the tree structure of the encapsulated view tree based on the parent view attribute and / or the child view attribute of the encapsulated view tree. The tree structure of the encapsulated view tree represents the hierarchical relationship between the encapsulated view objects in the encapsulated view tree, which can be referred to Figure 3The structural diagram of the encapsulated view tree shown is, exemplarily, similar to the encapsulated view tree, the encapsulated view objects in the encapsulated view tree are also data objects generated by a specific class, which have a calling scheme that can obtain the corresponding parent view attributes and child view attributes. Through the above-mentioned preset calling method of the encapsulated view object, the corresponding parent view attributes and child view attributes are obtained, and then the information representing the hierarchical relationship between the encapsulated view objects is obtained, that is, the tree structure of the encapsulated view tree.
[0070] Step S2032: Create a target number of processing threads.
[0071] Step S2033: Asynchronously load each encapsulated view object in the encapsulated view tree based on the target number of processing threads, and asynchronously create view objects corresponding to the encapsulated view objects.
[0072] Exemplarily, after that, based on the target number determined in the previous step, a corresponding target number of processing threads is created, and each encapsulated view object in the encapsulated view tree is asynchronously loaded based on the target number of processing threads, and a view object corresponding to the encapsulated view object is asynchronously created. The specific control method of the processing thread can be automatically completed by the operating system. Under different operating systems, the control method of the processing thread may be different, which will not be described in detail here.
[0073] Further, illustratively, the encapsulated view object has a state attribute, and the state attribute is used to indicate whether the encapsulated view object is loaded by a processing thread; the at least two processing threads include a first processing thread, such as Fig.10 As shown, the specific implementation of step S2033 includes:
[0074] Step S2033A: for the current encapsulated view object, read the state attribute of the current encapsulated view object through the first processing thread;
[0075] Step S2033B: if the state attribute of the current encapsulated view object is the first state, the current encapsulated view object is loaded by the first processing thread, and the first state indicates that the current encapsulated view object has not been loaded by any processing thread of the at least two processing threads.
[0076] Exemplarily, similar to the parent view attributes and child view attributes of the encapsulated view object, the encapsulated view object may also have a state attribute. In one possible implementation, the attribute value of the state attribute pair may be 0 or 1, wherein when the attribute value of the state attribute pair is 0, it is a first state, indicating that the encapsulated view object has not been loaded by any processing thread among the target number of processing threads; and when the attribute value of the state attribute pair is 1, it is a second state, indicating that the encapsulated view object has been loaded by any processing thread among the target number of processing threads. Specifically, the encapsulated view tree includes multiple encapsulated view objects. In the process of recursively encapsulating each encapsulated view object in the view tree, multiple processing threads are used for asynchronous processing. When the first processing thread processes the current encapsulated view object (for example, the encapsulated view object identified as Np_1 in the view tree), the first processing thread first obtains the state attribute of the current encapsulated view object and makes a judgment. If the state attribute of the current encapsulated view object is the first state, it means that the current encapsulated view object has not been processed by other processing threads, and the first processing thread loads the current encapsulated view object; if the state attribute of the current encapsulated view object is the second state, it means that the current encapsulated view object has not been processed by other processing threads, and the first processing thread ends the processing of the current encapsulated view object and jumps to the next encapsulated view object for processing; thereby avoiding repeated processing of encapsulated view objects in the case of multi-threaded asynchronous processing, resulting in generation errors of the target view tree.
[0077] Step S204: After all the encapsulated view objects in the encapsulated view tree are loaded, based on the tree structure of the encapsulated view tree, the view objects corresponding to each encapsulated view object are spliced into a target view tree.
[0078] Furthermore, after all the encapsulated view objects in the encapsulated view tree are fully loaded through multiple asynchronous processing threads, they are spliced based on the tree structure of the encapsulated view tree to obtain the target view tree, wherein the tree structure of the encapsulated view tree is information generated by the layout file, which can be preset in the encapsulated view tree or in other attributes of the view data. The specific implementation is not given here. In a possible implementation method, the view data has a preset second calling method. Through the second calling method, the tree structure of the encapsulated view tree can be obtained, and the view objects corresponding to each encapsulated view object can be spliced into the target view tree based on the tree structure of the encapsulated view tree. For specific implementation methods, please refer to Figure 2 The relevant introduction under step S103 in the illustrated embodiment.
[0079] Step S205: Display the target page based on the target view tree.
[0080] Afterwards, the terminal device renders based on the target view tree to display the target page. In this embodiment, the layout file is converted into view data instead of a view tree. The encapsulated view object of the encapsulated view tree in the view data contains the view attributes of each view object used to create the target view tree, thereby separating the creation of the view object from the creation of the view tree, and then using multiple threads to create the view object, and then splicing it into the target view tree, thereby improving the overall loading speed of the target page.
[0081] In this embodiment, the specific implementation of step S201, step S202 and step S205 is the same as above. Figure 2 Step S101, step S102 and step S104 in the embodiment shown are consistent. For detailed discussion, please refer to Figure 2 The discussion under the corresponding steps in the illustrated embodiment will not be repeated here.
[0082] Corresponding to the page loading method of the above embodiment, Fig.11 This is a structural block diagram of a page loading device provided by an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown.
[0083] Reference Fig.11 , the page loading device 3 comprises:
[0084] An acquisition module 31 is used to acquire a layout file of a target page, where the layout file is used to represent the page layout of the target page;
[0085] A generating module 32, used to obtain view data of a target page according to the layout file, where the view data is used to represent view properties of a view object in the target page;
[0086] A processing module 33, configured to asynchronously generate a target view tree corresponding to a target page through at least two processing threads based on the view data;
[0087] The display module 34 is used to display the target page based on the target view tree.
[0088] In one embodiment of the present disclosure, view data includes an encapsulated view tree, which has the same tree structure as the target view tree. The encapsulated view tree includes at least two encapsulated view objects, which are used to store view properties of view objects at corresponding positions on the target view tree.
[0089] In one embodiment of the present disclosure, when the processing module 33 asynchronously generates a target view tree corresponding to a target page based on view data through at least two processing threads, it is specifically used to: asynchronously load each encapsulated view object in the encapsulated view tree through at least two processing threads, and create corresponding view objects; after all the encapsulated view objects in the encapsulated view tree are loaded, based on the tree structure of the encapsulated view tree, splice the view objects corresponding to each encapsulated view object into a target view tree.
[0090] In one embodiment of the present disclosure, when the processing module 33 asynchronously loads each encapsulated view object in the encapsulated view tree through at least two processing threads and creates corresponding view objects, it is specifically used to: determine the target number of processing threads based on the tree structure of the encapsulated view tree; create the target number of processing threads; asynchronously load each encapsulated view object in the encapsulated view tree based on the target number of processing threads, and asynchronously create view objects corresponding to the encapsulated view objects.
[0091] In one embodiment of the present disclosure, the encapsulated view object has a parent view attribute and / or a child view attribute, and the parent view attribute is used to characterize that the encapsulated view object corresponds to at least one parent encapsulated view object; the child view attribute is used to characterize that the encapsulated view object corresponds to at least one child encapsulated view object; the processing module 33 is also used to: determine the tree structure of the encapsulated view tree based on the parent view attribute and / or child view attribute of the encapsulated view tree.
[0092] In one embodiment of the present disclosure, the encapsulated view object has a state attribute, and the state attribute is used to indicate whether the encapsulated view object is loaded by a processing thread; at least two processing threads include a first processing thread, and when the processing module 33 asynchronously loads each encapsulated view object in the encapsulated view tree through at least two processing threads, it is specifically used to: for the current encapsulated view object, read the state attribute of the current encapsulated view object through the first processing thread; if the state attribute of the current encapsulated view object is a first state, load the current encapsulated view object through the first processing thread, and the first state indicates that the current encapsulated view object has not been loaded by any of the at least two processing threads.
[0093] In one embodiment of the present disclosure, the layout file is an extensible markup language file. When the generation module 32 obtains the view data of the target page according to the layout file, it is specifically used to: obtain the parsing tool corresponding to the layout file; and compile the layout file based on the parsing tool to obtain the view data of the target page.
[0094] In one embodiment of the present disclosure, when the generation module 32 compiles the layout file based on the parsing tool to obtain the view data of the target page, it is specifically used to: convert the layout file into a layout code based on the parsing tool; establish a mapping identifier corresponding to the layout code, the mapping identifier is used to indicate the target page; based on the layout code and the corresponding mapping identifier, obtain the view data of the target page.
[0095] The acquisition module 31, generation module 32, processing module 33 and display module 34 are connected in sequence. The page display method device 3 provided in this embodiment can implement the technical solution of the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated in this embodiment.
[0096] Fig.12 A schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure is shown in FIG. Fig.12 As shown, the electronic device 4 includes:
[0097] A processor 41, and a memory 42 communicatively connected to the processor 41;
[0098] The memory 42 stores computer executable instructions;
[0099] The processor 41 executes the computer execution instructions stored in the memory 42 to implement the following Figure 2-Figure 10 The page display method in the illustrated embodiment.
[0100] Optionally, the processor 41 and the memory 42 are connected via a bus 43 .
[0101] For related instructions, please refer to Figure 2-Figure 10 The relevant descriptions and effects corresponding to the steps in the corresponding embodiments can be understood, and no further elaboration is made here.
[0102] The present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions, which are used to implement the present invention when executed by a processor. Figure 2-Figure 10 The page display method provided by any one of the corresponding embodiments.
[0103] The present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements Figure 2-Figure 10 The page display method in the illustrated embodiment.
[0104] refer to Fig.13, which shows a schematic diagram of the structure of an electronic device 900 suitable for implementing the embodiment of the present disclosure, and the electronic device 900 may be a terminal device or a server. The terminal device may include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (PDAs), tablet computers (Portable Android Devices, PADs), portable multimedia players (PMPs), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig.13 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0105] like Fig.13 As shown, the electronic device 900 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 to a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the electronic device 900 are also stored. The processing device 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0106] Typically, the following devices may be connected to the I / O interface 905: input devices 906 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 907 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 908 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 909. The communication device 909 may allow the electronic device 900 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.13 The electronic device 900 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0107] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by the processing device 901, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0108] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0109] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0110] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device executes the method shown in the above embodiment.
[0111] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0112] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0113] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0114] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0115] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0116] In a first aspect, according to one or more embodiments of the present disclosure, a page display method is provided, comprising:
[0117] Obtain a layout file of a target page, wherein the layout file is used to represent the page layout of the target page; obtain view data of the target page based on the layout file, wherein the view data is used to represent the view properties of the view objects in the target page; based on the view data, asynchronously generate a target view tree corresponding to the target page through at least two processing threads; and display the target page based on the target view tree.
[0118] According to one or more embodiments of the present disclosure, view data includes an encapsulated view tree, which has the same tree structure as a target view tree, and the encapsulated view tree includes at least two encapsulated view objects, which are used to store view properties of view objects at corresponding positions on the target view tree.
[0119] According to one or more embodiments of the present disclosure, the target view tree corresponding to the target page is asynchronously generated based on the view data through at least two processing threads, including: asynchronously loading each encapsulated view object in the encapsulated view tree through at least two processing threads, and creating corresponding view objects; after all the encapsulated view objects in the encapsulated view tree are loaded, based on the tree structure of the encapsulated view tree, splicing the view objects corresponding to each encapsulated view object into a target view tree.
[0120] According to one or more embodiments of the present disclosure, asynchronously loading each encapsulated view object in the encapsulated view tree and creating corresponding view objects through at least two processing threads includes: determining a target number of the processing threads based on the tree structure of the encapsulated view tree; creating the target number of processing threads; asynchronously loading each encapsulated view object in the encapsulated view tree based on the target number of processing threads, and asynchronously creating view objects corresponding to the encapsulated view objects.
[0121] According to one or more embodiments of the present disclosure, the encapsulated view object has a parent view attribute and / or a child view attribute, and the parent view attribute is used to characterize that the encapsulated view object corresponds to at least one parent encapsulated view object; the child view attribute is used to characterize that the encapsulated view object corresponds to at least one child encapsulated view object; the method also includes: determining the tree structure of the encapsulated view tree based on the parent view attribute and / or child view attribute of the encapsulated view tree.
[0122] According to one or more embodiments of the present disclosure, the encapsulated view object has a state attribute, and the state attribute is used to characterize whether the encapsulated view object is loaded by a processing thread; the at least two processing threads include a first processing thread, and the asynchronous loading of each encapsulated view object in the encapsulated view tree through at least two processing threads includes: for the current encapsulated view object, reading the state attribute of the current encapsulated view object through the first processing thread; if the state attribute of the current encapsulated view object is a first state, loading the current encapsulated view object through the first processing thread, and the first state characterizes that the current encapsulated view object has not been loaded by any processing thread of the at least two processing threads.
[0123] According to one or more embodiments of the present disclosure, the layout file is an extensible markup language file, and obtaining the view data of the target page based on the layout file includes: obtaining a parsing tool corresponding to the layout file; and compiling the layout file based on the parsing tool to obtain the view data of the target page.
[0124] According to one or more embodiments of the present disclosure, the layout file is compiled based on the parsing tool to obtain the view data of the target page, including: converting the layout file into a layout code based on the parsing tool; establishing a mapping identifier corresponding to the layout code, wherein the mapping identifier is used to indicate the target page; and obtaining the view data of the target page based on the layout code and the corresponding mapping identifier.
[0125] In a second aspect, according to one or more embodiments of the present disclosure, a page display device is provided, including:
[0126] An acquisition module, used for acquiring a layout file of a target page, wherein the layout file is used for representing a page layout of the target page;
[0127] A generating module, used to obtain the view data of the target page according to the layout file, wherein the view data is used to represent the view attributes of the view object in the target page;
[0128] A processing module, configured to asynchronously generate a target view tree corresponding to the target page through at least two processing threads based on the view data;
[0129] A display module is used to display the target page based on the target view tree.
[0130] According to one or more embodiments of the present disclosure, view data includes an encapsulated view tree, which has the same tree structure as a target view tree, and the encapsulated view tree includes at least two encapsulated view objects, which are used to store view properties of view objects at corresponding positions on the target view tree.
[0131] According to one or more embodiments of the present disclosure, when the processing module asynchronously generates a target view tree corresponding to the target page based on the view data through at least two processing threads, it is specifically used to: asynchronously load each encapsulated view object in the encapsulated view tree through at least two processing threads, and create corresponding view objects; after all the encapsulated view objects in the encapsulated view tree are loaded, based on the tree structure of the encapsulated view tree, splice the view objects corresponding to each of the encapsulated view objects into a target view tree.
[0132] According to one or more embodiments of the present disclosure, when the processing module asynchronously loads each encapsulated view object in the encapsulated view tree through at least two processing threads and creates corresponding view objects, it is specifically used to: determine the target number of the processing threads based on the tree structure of the encapsulated view tree; create the target number of processing threads; asynchronously load each encapsulated view object in the encapsulated view tree based on the target number of processing threads, and asynchronously create view objects corresponding to the encapsulated view objects.
[0133] According to one or more embodiments of the present disclosure, the encapsulated view object has a parent view attribute and / or a child view attribute, and the parent view attribute is used to characterize that the encapsulated view object corresponds to at least one parent encapsulated view object; the child view attribute is used to characterize that the encapsulated view object corresponds to at least one child encapsulated view object; the processing module is also used to: determine the tree structure of the encapsulated view tree based on the parent view attribute and / or child view attribute of the encapsulated view tree.
[0134] According to one or more embodiments of the present disclosure, the encapsulated view object has a state attribute, and the state attribute is used to characterize whether the encapsulated view object is loaded by a processing thread; at least two processing threads include a first processing thread, and when the processing module asynchronously loads each encapsulated view object in the encapsulated view tree through at least two processing threads, it is specifically used to: for the current encapsulated view object, read the state attribute of the current encapsulated view object through the first processing thread; if the state attribute of the current encapsulated view object is a first state, load the current encapsulated view object through the first processing thread, and the first state characterizes that the current encapsulated view object has not been loaded by any processing thread of the at least two processing threads.
[0135] According to one or more embodiments of the present disclosure, the layout file is an extensible markup language file, and when the generation module obtains the view data of the target page according to the layout file, it is specifically used to: obtain a parsing tool corresponding to the layout file; and compile the layout file based on the parsing tool to obtain the view data of the target page.
[0136] According to one or more embodiments of the present disclosure, when the generation module compiles the layout file based on the parsing tool to obtain the view data of the target page, it is specifically used to: convert the layout file into a layout code based on the parsing tool; establish a mapping identifier corresponding to the layout code, wherein the mapping identifier is used to indicate the target page; and obtain the view data of the target page based on the layout code and the corresponding mapping identifier.
[0137] In a third aspect, according to one or more embodiments of the present disclosure, there is provided an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0138] The memory stores computer-executable instructions;
[0139] The processor executes the computer-executable instructions stored in the memory to implement the page display method described in the first aspect and various possible designs of the first aspect.
[0140] In a fourth aspect, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer execution instructions. When a processor executes the computer execution instructions, the page display method described in the first aspect and various possible designs of the first aspect is implemented.
[0141] In a fifth aspect, an embodiment of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the page display method described in the first aspect and various possible designs of the first aspect.
[0142] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0143] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0144] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A page display method, characterized in that: include: Obtaining a layout file of a target page, wherein the layout file is used to represent a page layout of the target page; Obtaining view data of the target page according to the layout file, wherein the view data is used to represent view properties of a view object in the target page; Based on the view data, asynchronously generate a target view tree corresponding to the target page through at least two processing threads; The target page is displayed based on the target view tree.
2. The method according to claim 1, characterized in that The view data includes an encapsulated view tree, which has the same tree structure as the target view tree. The encapsulated view tree includes at least two encapsulated view objects, and the encapsulated view objects are used to store view properties of view objects at corresponding positions on the target view tree.
3. The method according to claim 2, characterized in that The step of asynchronously generating a target view tree corresponding to the target page based on the view data by at least two processing threads includes: Asynchronously loading each encapsulated view object in the encapsulated view tree through at least two processing threads, and creating a corresponding view object; After all the encapsulated view objects in the encapsulated view tree are loaded, based on the tree structure of the encapsulated view tree, the view objects corresponding to the encapsulated view objects are spliced into a target view tree.
4. The method according to claim 3, characterized in that The step of asynchronously loading each encapsulated view object in the encapsulated view tree through at least two processing threads and creating a corresponding view object includes: Determining a target number of processing threads based on the tree structure of the encapsulated view tree; Creating the target number of processing threads; The target number of processing threads asynchronously loads each encapsulated view object in the encapsulated view tree, and asynchronously creates view objects corresponding to the encapsulated view objects.
5. The method according to claim 4, characterized in that The encapsulated view object has a parent view attribute and / or a child view attribute, and the parent view attribute is used to indicate that the encapsulated view object corresponds to at least one parent encapsulated view object; The sub-view attribute is used to indicate that the encapsulated view object corresponds to at least one sub-encapsulated view object; The method further comprises: Based on the parent view attributes and / or child view attributes of the encapsulated view tree, the tree structure of the encapsulated view tree is determined.
6. The method according to claim 3, characterized in that The encapsulated view object has a state attribute, and the state attribute is used to indicate whether the encapsulated view object is loaded by a processing thread; the at least two processing threads include a first processing thread, and the asynchronous loading of each encapsulated view object in the encapsulated view tree by the at least two processing threads includes: For the current encapsulated view object, reading the state attribute of the current encapsulated view object through the first processing thread; If the state attribute of the current encapsulated view object is a first state, the current encapsulated view object is loaded through the first processing thread, and the first state indicates that the current encapsulated view object has not been loaded by any processing thread of the at least two processing threads.
7. The method according to claim 1, characterized in that The layout file is an extensible markup language file, and obtaining the view data of the target page according to the layout file includes: Obtaining a parsing tool corresponding to the layout file; Based on the parsing tool, the layout file is compiled to obtain the view data of the target page.
8. The method according to claim 7, characterized in that The step of compiling the layout file based on the parsing tool to obtain the view data of the target page includes: Based on the parsing tool, convert the layout file into layout code; Establishing a mapping identifier corresponding to the layout code, wherein the mapping identifier is used to indicate the target page; Based on the layout code and the corresponding mapping identifier, the view data of the target page is obtained.
9. A page display method and device, characterized in that: include: An acquisition module, used for acquiring a layout file of a target page, wherein the layout file is used for representing a page layout of the target page; A generating module, used to obtain the view data of the target page according to the layout file, wherein the view data is used to represent the view attributes of the view object in the target page; A processing module, configured to asynchronously generate a target view tree corresponding to the target page through at least two processing threads based on the view data; A display module is used to display the target page based on the target view tree.
10. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the page display method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the page display method according to any one of claims 1 to 8 is implemented.
12. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the page display method according to any one of claims 1 to 8.
