Page loading method and device, electronic equipment and storage medium
By obtaining the attribute information and constructor of the target page, the target view object is constructed, which solves the problem of time-consuming page loading and poor compatibility under the Android operating system, and achieves efficient and compatible page loading.
Patent Information
- Application Number
- CN202310324095.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-29
- Publication Date
- 2024-10-01
AI Technical Summary
Under the Android operating system, there are problems such as poor compatibility and low operating efficiency due to time-consuming problems caused by loading layout files when loading application pages.
By obtaining the attribute information of the target page, obtain the target constructor with attribute parameters, build the target view object, and display the page based on the object, realize automatic adaptation, avoid manual adaptation, and improve loading efficiency and compatibility.
The loading efficiency and compatibility of the target page are improved, the usage cost is reduced, and the problems of poor compatibility and low operating efficiency in the existing technology are solved.
Smart Images

Figure CN118733133A_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 loading method, device, electronic device, and storage medium. Background Art
[0002] Under the Android operating system, the page layout in an application (Application, APP) can be described by a layout file. Therefore, before displaying a page in an application, the terminal device needs to first load the layout file, and then determine the view (View) in the page based on the layout information in the layout file, so as to display the page.
[0003] However, the process of loading the layout file is time-consuming and affects the page display speed. In order to solve the time-consuming problem caused by loading the layout file, the layout file is translated into program code in advance and compiled into the application. When the application is running, the target page is displayed by loading the program code corresponding to the target page, thereby improving the page display speed.
[0004] However, in the prior art, after the layout file is translated into the program code of the target page in advance, there are problems of poor compatibility and low operating efficiency during the process of loading the target page. Summary of the invention
[0005] The embodiments of the present disclosure provide a page loading method, device, electronic device and storage medium to overcome the problems of poor compatibility and low operating efficiency in loading a target page in the prior art.
[0006] In a first aspect, an embodiment of the present disclosure provides a page loading method, including:
[0007] Acquire attribute information of a target page, wherein the attribute information represents a page layout of the target page; obtain a corresponding target constructor according to the attribute information, wherein the target constructor has attribute parameters for receiving the attribute information; construct a target view object according to the target constructor and the attribute information, and display the target page based on the target view object.
[0008] In a second aspect, an embodiment of the present disclosure provides a page loading device, including:
[0009] An acquisition module, used to acquire attribute information of a target page, wherein the attribute information represents a page layout of the target page;
[0010] A processing module, used for obtaining a corresponding target constructor according to the attribute information, wherein the target constructor has an attribute parameter for receiving the attribute information;
[0011] The display module is used to construct a target view object according to the target constructor and the attribute information, and display the target page based on the target view object.
[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 loading method as 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 loading 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 loading method described in the first aspect and various possible designs of the first aspect.
[0018] The page loading method, device, electronic device and storage medium provided in this embodiment obtain the attribute information of the target page, wherein the attribute information represents the page layout of the target page; obtain the corresponding target constructor according to the attribute information, wherein the target constructor has attribute parameters for receiving the attribute information; construct a target view object according to the target constructor and the attribute information, and display the target page based on the target view object. Since in the process of loading the target page, the target view object is constructed using the target constructor with attribute parameters, and the page is loaded based on the target view object, so as to realize the display of the target page, the page layout of the target page can be automatically adapted through the attribute parameters of the target constructor, without the need for manual adaptation in advance, thereby improving the loading efficiency and compatibility of the target view object and reducing the use cost. 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 page loading method provided in the embodiment of the present disclosure Figure 1 ;
[0022] Figure 3 A schematic diagram of a process for generating attribute information of a target page provided by an embodiment of the present disclosure;
[0023] Figure 4 Schematic diagram of the page loading method provided in the embodiment of the present disclosure Figure 2 ;
[0024] Figure 5 A schematic diagram of a process based on generating a layout data object provided by an embodiment of the present disclosure;
[0025] Figure 6 for Figure 4 A flowchart of a specific implementation method of step S202 in the illustrated embodiment;
[0026] Figure 7 A schematic diagram of generating a sub-layout data object provided by this embodiment;
[0027] Figure 8 for Figure 4 A flowchart of another specific implementation of step S202 in the illustrated embodiment;
[0028] Fig. 9 A schematic diagram of another method for generating a sub-layout data object provided by this embodiment;
[0029] Fig.10 for Figure 4 A flowchart of a specific implementation method of step S203 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 in 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, and then parses the layout file through the development terminal device, and compiles it together with other data and files used to implement the functions of the application, generates the program code of the application (such as including the installation file, executable file, dynamic link library, etc. of the application), and then sends the program code of the application to the server for the target terminal device (other users) to download and run. In the process of the target terminal device running the application, when the page layout needs to be loaded, the attribute information of the page layout representing the target page in the program code can be directly obtained, and the view is loaded based on the attribute information, without the need to obtain the layout information by reading the layout file, thereby achieving the purpose of improving the page loading speed. Of course, in other possible implementations, the above-mentioned process of generating the program code 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 program 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, the above-mentioned solution of converting the layout file into program code (i.e., Java Code) and compiling and packaging it to generate a program file can solve the problem of time-consuming page loading caused by loading layout files. However, this solution will have compatibility issues. This is because: in the prior art, after the target terminal device determines the target page to be displayed by running the program code, it first creates a view (View) object in the target page, and then sets the properties of the view object. At the same time, when constructing the view object, a constructor with only one parameter is used. This implementation method requires the properties of the view object to be pre-adapted in order to parse out the information used to describe the view style and position. The properties of the view object are personalized information that the user needs to set, and they need to be manually adapted before setting. If they are not adapted, they cannot be parsed. Even the properties of the view objects provided by the system are very large in number, making it difficult to achieve global adaptation. As for the customized view objects, they can only be adapted based on secondary development, which leads to compatibility issues.
[0038] The embodiment of the present disclosure provides a page loading method to solve the above-mentioned problem.
[0039] refer to Figure 2 , Figure 2 Schematic diagram of the page loading method provided in the embodiment of the present disclosure Figure 1 The method of this embodiment can be applied to a terminal device, a server, or other electronic devices capable of implementing similar functions. The page loading method includes:
[0040] Step S101: Acquire attribute information of a target page, where the attribute information represents the page layout of the target page.
[0041] For example, the target program refers to a specific application program, such as a live broadcast APP, a short video APP, an instant messaging APP, etc., and the target page refers to a specific page in the target program, such as the home page, the live broadcast page, etc. Among them, the attribute information of the target page represents the page layout of the target page. The attribute information is determined by the layout file, compiled, and pre-stored in the application program in the form of program code. The specific implementation process can be seen in Figure 1 The schematic diagram of the application scenario shown is not described here. Further, the layout file is, for example, an Extensible Markup Language (XML) file, wherein the target program includes multiple pages for implementing different functions, each page corresponding to a different page layout, and therefore, exemplarily, each page in the target program has corresponding attribute information.
[0042] Furthermore, the target page of the target program contains a view object. A 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. The specific definition of the view object can be recorded in the layout file to achieve the description of the page layout.
[0043] Furthermore, in the application scenario of testing the target program, the step of obtaining the attribute information of the target page and the step of generating the attribute information of the target page can be performed on the same device (eg Figure 1 That is, before step S101, it also includes the step of compiling the target program according to the layout file to generate a corresponding program code containing the attribute information of the target page. Figure 3 A schematic diagram of a process for generating attribute information of a target page provided by an embodiment of the present disclosure, such as Figure 3 As shown, before step S101, it also includes:
[0044] Step S1001: Obtain the layout file corresponding to the target page.
[0045] Step S1002: compile the layout file based on a preset parsing tool to obtain attribute information of the target page.
[0046] Exemplarily, first, according to the specific content in the layout file, the corresponding parsing tool is obtained. In a possible implementation, according to the layout file being an XML file, according to the size of the XML file, or the number of View definitions contained in the XML and the complexity of the information, the corresponding parsing tool is selected to match the volume of the parsing tool with the volume of the XML file, so as to avoid loading a complex parsing tool to compile a simple layout file, thereby improving the compilation efficiency and reducing the time consumed by the compilation. In another possible implementation, the layout file is parsed using a preset parsing tool, wherein, exemplarily, the parsing tool is an Android compilation and packaging tool (Android Asset Packaging Tool, aapt). More specifically, the Android compilation and packaging tool includes aapt and aapt2. Through the Android compilation and packaging tool, it is possible to parse resources, index resources, and compile resources into data in a binary format optimized for the Android platform, that is, during the compilation period for the layout file, the resources in the layout file are parsed and converted into a data structure more suitable for the Android platform to read and each resource is indexed, so as to ensure that the resources in the layout file can be obtained and parsed as quickly as possible during runtime. Therefore, by compiling the layout file through the parsing tool, the attribute information in the binary format can be obtained. Among them, the Android compilation and packaging tools aapt and aapt2 are existing technologies known to those skilled in the art and will not be described in detail here.
[0047] Step S102: Obtain a corresponding target constructor according to the attribute information, wherein the target constructor has an attribute parameter for receiving the attribute information.
[0048] Exemplarily, the target constructor refers to a constructor for constructing a view object in a target page. For example, the target constructor is a constructor of a view object, and the attribute parameters of the target constructor are custom attributes. The constructor of a view object in the Android operating system includes at least two implementations, corresponding to two different construction methods. These include a constructor containing only one parameter and a constructor containing two parameters. More specifically, a constructor containing one parameter is illustrated as:
[0049] View(context);
[0050] The constructor with two parameters is as follows:
[0051] View(context,AttributeSet);
[0052] Among them, the first constructor contains one parameter, which is a solution in the prior art. It is used when creating a view object through Java code, and the attributes of the view object need to be adapted in advance. The second constructor contains two parameters, which can create a view object through the information in the layout file. Among them, context is a page parameter used to indicate the target page, and AttributeSet is an attribute parameter used to receive attribute information. That is, the target constructor obtains the information (attribute information) representing the page layout through AttributeSet, and creates the corresponding view object based on the information representing the page layout, thereby realizing the mapping and conversion from the layout file to the view object.
[0053] Furthermore, after the attribute information is obtained, since the attribute information is obtained based on the layout file, it is determined that the corresponding target constructor is a constructor including two parameters: a page parameter (context) and an attribute parameter (AttributeSet).
[0054] Step S103: construct a target view object according to the target constructor and attribute information, and display the target page based on the target view object.
[0055] Exemplarily, after determining the target constructor, the attribute information is used as input information and input into the target constructor, that is, the attribute information is received through the attribute parameters, the target constructor is called, the corresponding construction method is executed, and the corresponding target view object is generated in the memory. The target view object is one or more views (View) that meet the requirements of the page layout represented by the attribute information, that is, the view tree (ViewTree). Furthermore, by rendering the view through the view tree created in the above steps, the content display in the target page can be realized. Among them, the specific implementation principle and method of displaying the content in the target page based on the view tree is a prior art under the Android operating system and will not be repeated here.
[0056] In this embodiment, the target page's attribute information is obtained, and the attribute information represents the page layout of the target page; the corresponding target constructor is obtained according to the attribute information, wherein the target constructor has attribute parameters for receiving the attribute information; the target view object is constructed according to the target constructor and the attribute information, and the target page is displayed based on the target view object. Since in the process of loading the target page, the target view object is constructed using the target constructor having attribute parameters, and the page is loaded based on the target view object, the display of the target page is realized, and the page layout of the target page can be automatically adapted through the attribute parameters of the target constructor, without the need for manual adaptation in advance, thereby improving the loading efficiency and compatibility of the target view object and reducing the use cost.
[0057] refer to Figure 4 , Figure 4 Schematic diagram of the page loading method provided in the embodiment of the present disclosure Figure 2 .
[0058] This embodiment Figure 2 Based on the illustrated embodiment, step S102 is further refined, and the method includes:
[0059] Step S200: Acquire attribute information of a target page, where the attribute information represents the page layout of the target page.
[0060] Step S201: According to the attribute information, a corresponding target constructor is obtained, where the target constructor includes attribute parameters, and the target constructor has attribute parameters for receiving the attribute information.
[0061] Step S202: creating a layout data object having a first data format according to the attribute information, wherein the layout data object is used to represent the overall layout of each view object in the target page.
[0062] For example, in Figure 2 In the illustrated embodiment, the specific implementation of the attribute information of the target page has been introduced, which will not be repeated here. After obtaining the attribute information, the corresponding target constructor with attribute parameters is selected, where the target constructor is, for example: Vew(para_1, para_2), where para_1 is a page parameter indicating the target page, and para_2 is an attribute parameter for receiving the attribute information. More specifically, in the Android operating system, in the constructor for View, para_1 is context, and para_2 is AttributeSet.
[0063] Further, a layout data object is created based on the attribute information, wherein, exemplarily, the layout data object is obtained based on the XMLBlock class. More specifically, the layout data object is an instantiation object of XMLBlock, for example, Xmlblock. The first data format is the data format possessed by the XMLBlock class. The layout data object is used to characterize the overall layout of each view object in the target page, which is equivalent to a container for loading attribute information, but has a specific first data format. With the help of the layout data object, the format conversion of attribute information generated by XML to attribute parameters is realized. Among them, XMLBlock (eXtensible Markup Language Block) is a modular tool for editing XML files. XMLBlock can help developers separate different elements in XML files for detailed editing and management. Its specific implementation principle and usage method are prior art and will not be repeated here.
[0064] Figure 5 A schematic diagram of a process for generating a layout data object based on attribute information provided by an embodiment of the present disclosure, such as Figure 5 As shown, the layout file in XML format is compiled and processed by using the Android compilation and packaging tool appt or appt2 (shown as appt in the figure), and binary data, i.e., attribute information, is obtained. After that, the terminal device executing the method of this embodiment packages the binary attribute information to obtain attribute information based on the layout data object XmlBlock (creates a layout data object), i.e., binary data (layout data object) packaged with XmlBlock. The binary data packaged with XmlBlock can represent the overall layout of each view object in the target page.
[0065] Furthermore, in actual application, the attribute information represents the overall layout of each view object in the target page, that is, the target page usually includes multiple view objects. At this time, in order to represent the characteristics of each view object in the target page, the attribute information needs to store the view information corresponding to each view object, wherein the view information is information representing the specific style, position, and attributes of the view object. For example, if the target page includes 8 view objects, the attribute information corresponding to the target page needs to store the view information corresponding to each of the 8 view objects respectively. In order to increase the loading speed of each view object in the subsequent target page, in this embodiment, the view information of different view objects in the attribute information is independently stored in the process of generating the layout data object, thereby increasing the speed of loading and displaying each view object in the subsequent target page.
[0066] Specifically, in a possible implementation, Figure 6 As shown, a possible implementation of step S202 includes:
[0067] Step S2021: split the attribute information to obtain at least two sub-attribute information, where the sub-attribute information represents the attribute of a view object in the target page.
[0068] Step S2022: compile each sub-attribute information to generate a corresponding sub-layout data object.
[0069] Step S2023: Obtain a layout data object according to the sub-layout data object.
[0070] Exemplarily, after obtaining the attribute information in binary data format, based on a specific data segmentation rule, the attribute information is segmented into sub-attribute information of a fraction equal to the number of view objects, and the sub-attribute information represents the attribute of a view object in the target page, that is, one sub-attribute information stores the view information corresponding to one view object. Afterwards, each pair of sub-attribute information is compiled and packaged to generate a corresponding sub-layout data object, wherein the sub-layout data object is also a data object implemented based on the XMLBlock class, and can have the same data structure as the above-mentioned layout data object, but has a smaller data volume. Afterwards, a collection of multiple sub-layout data objects is determined as a layout data object.
[0071] For example, Figure 7 A schematic diagram of generating a sub-layout data object provided by this embodiment, such as Figure 7 As shown, after obtaining the attribute information Info in binary data format according to the layout file, the attribute information Info is split into multiple sub-attribute information, such as the sub-attribute information Info_1, sub-attribute information Info_2 and sub-attribute information Info_3 shown in the figure, wherein each sub-attribute information corresponds to a view object, for example, the view object corresponding to the sub-attribute information Info_1 is TextView (text box), the view object corresponding to the sub-attribute information Info_2 is LinearLayout (linear layout), and the view object corresponding to the sub-attribute information Info_3 is Button (button). Afterwards, each sub-attribute information is packaged and edited respectively to generate the corresponding sub-layout data objects based on XmlBlock, which are sub-layout data object XB_1, sub-layout data object XB_2 and sub-layout data object XB_3. Among them, the sub-layout data object XB_1 is loaded with the view information corresponding to TextView; the sub-layout data object XB_2 is loaded with the view information corresponding to LinearLayout; and the sub-layout data object XB_3 is loaded with the view information corresponding to Button. Afterwards, a collection of the sub-layout data object XB_1, the sub-layout data object XB_2, and the sub-layout data object XB_3 is taken as a layout data object.
[0072] In another possible implementation, Figure 8 As shown, another possible implementation of step S202 includes:
[0073] Step S2024: compile the attribute information to generate a corresponding overall layout data object.
[0074] Step S2025: split the overall layout object to obtain at least two sub-layout data objects.
[0075] Step S2026: Obtain a layout data object according to the sub-layout data object.
[0076] For example, in another possible implementation, the attribute information is first compiled to generate an overall layout data object corresponding to the attribute information. The overall layout data object is also implemented based on XmlBlock. The overall layout data object contains view information of each view object represented by the attribute information. Afterwards, based on the preset parsing rules, the overall layout data object is split to obtain sub-layout data objects corresponding to each view object. Each sub-layout data object has the same data structure as the layout data object, but has a smaller data volume. Figure 5 The sub-layout data objects in the illustrated embodiment are the same and will not be described in detail here. Afterwards, a layout data object is obtained according to the set of sub-layout data objects.
[0077] For example, for example, Fig. 9 Another schematic diagram of generating a sub-layout data object provided by this embodiment is as follows: Fig. 9 As shown, after obtaining the attribute information Info in binary data format according to the XML file, the attribute information Info is directly compiled and packaged to generate the overall layout data object XBlock corresponding to the attribute information Info. The overall layout data object XBlock is implemented based on XmlBlock and has a first data format. The overall layout data object XBlock contains the complete information in the attribute information Info, which is equivalent to the format conversion of the attribute information Info. Afterwards, the layout data object XBlock is split into multiple layout data objects, namely, the layout data object XB_1, the sub-layout data object XB_2 and the sub-layout data object XB_3, wherein, exemplarily, the sub-layout data object XB_1 is loaded with the view information corresponding to the TextView; the sub-layout data object XB_2 is loaded with the view information corresponding to the LinearLayout; and the sub-layout data object XB_3 is loaded with the view information corresponding to the Button. Afterwards, the collection of the sub-layout data object XB_1, the sub-layout data object XB_2 and the sub-layout data object XB_3 is used as the layout data object. Among them, the specific method of splitting the overall layout object can be implemented through ResXMLTree, wherein, specifically, ResXMLTree is an object of the C++ layer (ResXMLTree object), and the ResXMLTree is created by calling the corresponding constructor. The splitting of the overall layout object based on the XmlBlock structure is implemented through ResXMLTree, and the specific implementation method will not be repeated here.
[0078] In the steps of this embodiment, the overall layout data object is generated by directly compiling and packaging the attribute information, and then the overall layout data object is differentiated to obtain multiple sub-layout data objects, thereby constituting a layout data object, thereby avoiding the problem of generating an intermediate layout (i.e., sub-attribute information) in the intermediate process, thereby improving the speed of generating layout data objects, and ultimately achieving the purpose of increasing the target page loading speed.
[0079] Step S203: Obtaining attribute parameters of the target constructor according to the layout data object.
[0080] Step S204: construct a target view object according to the attribute parameters corresponding to the target constructor and the target composition function, and display the target page based on the target view object.
[0081] Exemplarily, it can be seen from the previous steps that the obtained layout data object is composed of multiple sub-data objects, each of which stores the view information of a view object. The layout data object with this data structure (i.e., the first data structure) is used as the attribute parameter AttributeSet of the target constructor, which can realize the call of the target constructor, so that the data in the layout data object (the view information of each view object) is loaded into the target constructor, and then the corresponding multiple target view objects, i.e., ViewTree, are constructed. After that, the content corresponding to the target view object can be rendered in the target page based on ViewTree, and the specific rendering process will not be repeated.
[0082] In one possible implementation, Fig.10 As shown, the specific implementation of step S203 includes:
[0083] Step S2031: Based on the layout data object, a corresponding parser is created, where the parser is used to convert the layout file into a structured data structure.
[0084] Step S2032: Construct the attribute parameters of the target constructor through the parser.
[0085] Exemplarily, based on the above introduction to the layout data object, after creating a layout data object with a first data format, the layout data object is an object based on XmlBlock, and the parser construction method of XmlBlock is called to create the corresponding parser. Specifically, for example, the parser XmlBlock.Parser can be obtained through the newParser() method of XmlBlock. More specifically, XmlBlock.Parser is a declarative XML parser that can help developers convert complex XML documents into structured data structures. It is a general parser that can automatically identify various XML elements, such as elements, attributes, text nodes, etc., and convert them into readable strings or meaningful data objects. It can also support multiple XML types, such as XHTML and Atom recommended by W3C, and other third-party formats. XmlBlock.Parser also supports multiple languages, including Java, C# and JavaScript, as well as various platforms, including Android, iOS and Windows. The specific principle of XmlBlock.Parser is a prior art and will not be further described here.
[0086] Furthermore, after obtaining the parser, the attribute parameter AttributeSet of the target constructor is constructed through the parser XmlBlock.Parser. Specifically, in this embodiment, the attribute parameter is constructed through the parser. This is because: in order to obtain the attributes of the target view object View, it is necessary to call Context#obtainStyledAttributes. This method will eventually call the method ResourcesImpl#obtainStyledAttributes in the process of calling step by step. In the specific implementation of ResourcesImpl#obtainStyledAttributes, there is a forced type conversion, which converts AttributeSet into XmlBlock.Parser, that is, the attribute parameter AttributeSet has an implementation based on XmlBlock.Parser. Therefore, in this embodiment, the parser XmlBlock.Parser is used to construct the attribute parameter AttributeSet of the target constructor, so that the obtained attribute parameter AttributeSet can meet the calling conditions of the target constructor, and then successfully generate the target view object.
[0087] In this embodiment, step S200 and step S201 are consistent with step S101 and step S102 in the above embodiment. For detailed discussion, please refer to Figure 2The discussion of step S101 and step S102 in the illustrated embodiment will not be repeated here.
[0088] 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.
[0089] Reference Fig.11 , the page loading device 3 comprises:
[0090] An acquisition module 31 is used to acquire attribute information of a target page, where the attribute information represents a page layout of the target page;
[0091] The processing module 32 is used to obtain a corresponding target constructor according to the attribute information, wherein the target constructor has an attribute parameter for receiving the attribute information;
[0092] The display module 33 is used to construct a target view object according to the target constructor and attribute information, and display the target page based on the target view object.
[0093] In one embodiment of the present disclosure, the attribute parameter is a custom attribute AttributeSet.
[0094] In one embodiment of the present disclosure, the processing module 32 is further used to: create a layout data object having a first data format according to the attribute information, the layout data object being used to characterize the overall layout of each view object in the target page; obtain the attribute parameters of the target constructor according to the layout data object; the display module 33 is specifically used to: construct a target view object according to the target constructor and the attribute parameters of the target constructor.
[0095] In one embodiment of the present disclosure, when the processing module 32 obtains the attribute parameters of the target constructor according to the layout data object, it is specifically used to: create a corresponding parser based on the layout data object, the parser is used to convert the layout file into a structured data structure; and construct the attribute parameters of the target constructor through the parser.
[0096] In one embodiment of the present disclosure, when the processing module 32 creates a layout data object having a first data format based on the attribute information, it is specifically used to: split the attribute information to obtain at least two sub-attribute information, where the sub-attribute information represents the attributes of a view object in the target page; compile each sub-attribute information to generate a corresponding sub-layout data object; and obtain a layout data object based on the sub-layout data object.
[0097] In one embodiment of the present disclosure, when the processing module 32 creates a layout data object having a first data format based on the attribute information, it is specifically used to: compile the attribute information to generate a corresponding overall layout data object; split the overall layout object to obtain at least two sub-layout data objects; and obtain a layout data object based on the sub-layout data objects.
[0098] In one embodiment of the present disclosure, the target constructor further has a page parameter, and the page parameter is used to indicate the target page.
[0099] In one embodiment of the present disclosure, before obtaining the attribute information of the target page, the acquisition module is also used to: obtain the layout file corresponding to the target page; based on a preset parsing tool, compile the layout file to obtain the attribute information of the target page; wherein the parsing tool is the Android compilation and packaging tool aapt.
[0100] The acquisition module 31, the processing module 32 and the display module 33 are connected in sequence. The page loading 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.
[0101] 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:
[0102] A processor 41, and a memory 42 communicatively connected to the processor 41;
[0103] The memory 42 stores computer executable instructions;
[0104] The processor 41 executes the computer execution instructions stored in the memory 42 to implement the following Figure 2-Figure 10 The page loading method in the illustrated embodiment.
[0105] Optionally, the processor 41 and the memory 42 are connected via a bus 43 .
[0106] 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.
[0107] 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 loading method provided in any one of the corresponding embodiments.
[0108] 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 loading method in the illustrated embodiment.
[0109] 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.
[0110] 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.
[0111] 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.
[0112] 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 contains 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.
[0113] 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.
[0114] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0115] 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.
[0116] 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).
[0117] 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.
[0118] 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".
[0119] 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.
[0120] 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.
[0121] In a first aspect, according to one or more embodiments of the present disclosure, a page loading method is provided, comprising:
[0122] Acquire attribute information of a target page, wherein the attribute information represents a page layout of the target page; obtain a corresponding target constructor according to the attribute information, wherein the target constructor has attribute parameters for receiving the attribute information; construct a target view object according to the target constructor and the attribute information, and display the target page based on the target view object.
[0123] According to one or more embodiments of the present disclosure, the target constructor is a constructor of a view object, and the attribute parameters of the target constructor are custom attributes.
[0124] According to one or more embodiments of the present disclosure, the method further includes: creating a layout data object having a first data format according to the attribute information, the layout data object being used to characterize the overall layout of each view object in the target page; obtaining attribute parameters of a target constructor according to the layout data object; and constructing a target view object according to the target constructor and the attribute information, comprising: constructing a target view object according to the target constructor and the attribute parameters of the target constructor.
[0125] According to one or more embodiments of the present disclosure, obtaining the property parameters of the target constructor according to the layout data object includes: creating a corresponding parser based on the layout data object, the parser being used to convert the layout file into a structured data structure; and constructing the property parameters of the target constructor through the parser.
[0126] According to one or more embodiments of the present disclosure, creating a layout data object having a first data format based on the attribute information includes: splitting the attribute information to obtain at least two sub-attribute information, wherein the sub-attribute information represents an attribute of a view object within the target page; compiling each of the sub-attribute information to generate a corresponding sub-layout data object; and obtaining the layout data object based on the sub-layout data objects.
[0127] According to one or more embodiments of the present disclosure, creating a layout data object having a first data format according to the attribute information includes: compiling the attribute information to generate a corresponding overall layout data object; splitting the overall layout object to obtain at least two sub-layout data objects; and obtaining the layout data object according to the sub-layout data objects.
[0128] According to one or more embodiments of the present disclosure, the target constructor further has a page parameter, and the page parameter is used to indicate the target page.
[0129] According to one or more embodiments of the present disclosure, before obtaining the attribute information of the target page, the method further includes: obtaining a layout file corresponding to the target page; compiling the layout file based on a preset parsing tool to obtain the attribute information of the target page; wherein the parsing tool is an Android compilation and packaging tool aapt.
[0130] In a second aspect, according to one or more embodiments of the present disclosure, a page loading device is provided, comprising:
[0131] An acquisition module, used to acquire attribute information of a target page, wherein the attribute information represents a page layout of the target page;
[0132] A processing module, used for obtaining a corresponding target constructor according to the attribute information, wherein the target constructor has an attribute parameter for receiving the attribute information;
[0133] The display module is used to construct a target view object according to the target constructor and the attribute information, and display the target page based on the target view object.
[0134] According to one or more embodiments of the present disclosure, the target constructor is a constructor of a view object, and the attribute parameters of the target constructor are custom attributes.
[0135] According to one or more embodiments of the present disclosure, the processing module is further used to: create a layout data object having a first data format according to the attribute information, wherein the layout data object is used to characterize the overall layout of each view object in the target page; obtain attribute parameters of a target constructor according to the layout data object; and the display module is specifically used to: construct a target view object according to the target constructor and the attribute parameters of the target constructor.
[0136] According to one or more embodiments of the present disclosure, when the processing module obtains the property parameters of the target constructor according to the layout data object, it is specifically used to: create a corresponding parser based on the layout data object, and the parser is used to convert the layout file into a structured data structure; and construct the property parameters of the target constructor through the parser.
[0137] According to one or more embodiments of the present disclosure, when the processing module creates a layout data object having a first data format according to the attribute information, it is specifically used to: split the attribute information to obtain at least two sub-attribute information, wherein the sub-attribute information represents an attribute of a view object within the target page; compile each of the sub-attribute information to generate a corresponding sub-layout data object; and obtain the layout data object according to the sub-layout data objects.
[0138] According to one or more embodiments of the present disclosure, when the processing module creates a layout data object having a first data format according to the attribute information, it is specifically used to: compile the attribute information to generate a corresponding overall layout data object; split the overall layout object to obtain at least two sub-layout data objects; and obtain the layout data object according to the sub-layout data objects.
[0139] According to one or more embodiments of the present disclosure, the target constructor further has a page parameter, and the page parameter is used to indicate the target page.
[0140] According to one or more embodiments of the present disclosure, before obtaining the attribute information of the target page, the acquisition module is also used to: obtain a layout file corresponding to the target page; based on a preset parsing tool, compile the layout file to obtain the attribute information of the target page; wherein the parsing tool is an Android compilation and packaging tool aapt.
[0141] 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;
[0142] The memory stores computer-executable instructions;
[0143] The processor executes the computer-executable instructions stored in the memory to implement the page loading method as described in the first aspect and various possible designs of the first aspect.
[0144] 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 loading method described in the first aspect and various possible designs of the first aspect is implemented.
[0145] 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 loading method described in the first aspect and various possible designs of the first aspect.
[0146] 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.
[0147] 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.
[0148] 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 loading method, It is characterized in that include: Acquire attribute information of a target page, wherein the attribute information represents a page layout of the target page; According to the attribute information, a corresponding target constructor is obtained, wherein the target constructor has an attribute parameter for receiving the attribute information; A target view object is constructed according to the target constructor and the attribute information, and the target page is displayed based on the target view object.
2. The method according to claim 1, It is characterized in that The target constructor is a constructor of a view object, and the attribute parameters of the target constructor are custom attributes.
3. The method according to claim 1, It is characterized in that The method further comprises: Creating a layout data object in a first data format according to the attribute information, wherein the layout data object is used to represent the overall layout of each view object in the target page; According to the layout data object, obtaining attribute parameters of the target constructor; The step of constructing a target view object according to the target constructor and the attribute information includes: Construct a target view object according to the target constructor and the attribute parameters of the target constructor.
4. The method according to claim 3, It is characterized in that The step of obtaining attribute parameters of a target constructor according to the layout data object includes: Based on the layout data object, create a corresponding parser, wherein the parser is used to convert the layout file into a structured data structure; The attribute parameters of the target constructor are constructed through the parser.
5. The method according to claim 3, It is characterized in that The step of creating a layout data object having a first data format according to the attribute information comprises: Splitting the attribute information to obtain at least two sub-attribute information, wherein the sub-attribute information represents an attribute of a view object in the target page; Compiling each of the sub-attribute information to generate a corresponding sub-layout data object; The layout data object is obtained according to the sub-layout data object.
6. The method according to claim 3, It is characterized in that The step of creating a layout data object having a first data format according to the attribute information comprises: Compiling the attribute information to generate a corresponding overall layout data object; Splitting the overall layout object to obtain at least two sub-layout data objects; The layout data object is obtained according to the sub-layout data object.
7. The method according to claim 1, It is characterized in that The target constructor further has a page parameter, and the page parameter is used to indicate the target page.
8. The method according to claim 1, It is characterized in that Before acquiring the attribute information of the target page, the method further includes: Obtaining the layout file corresponding to the target page; Based on a preset parsing tool, compile the layout file to obtain attribute information of the target page; The analysis tool is the Android compilation and packaging tool aapt.
9. A page loading device, It is characterized in that include: An acquisition module, used to acquire attribute information of a target page, wherein the attribute information represents a page layout of the target page; A processing module, configured to obtain a corresponding target constructor according to the attribute information, wherein the target constructor has an attribute parameter for receiving the attribute information; The display module is used to construct a target view object according to the target constructor and the attribute information, and display the target page based on the target view object.
10. An electronic device, It is 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 loading method according to any one of claims 1 to 8.
11. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the page loading method according to any one of claims 1 to 8 is implemented.
12. A computer program product, It is characterized in that It comprises a computer program, which implements the page loading method according to any one of claims 1 to 8 when executed by a processor.
