CN112800362B - Interface view time delay loading method and device - Google Patents
Interface view time delay loading method and device Download PDFInfo
- Publication number
- CN112800362B CN112800362B CN202110155778.XA CN202110155778A CN112800362B CN 112800362 B CN112800362 B CN 112800362B CN 202110155778 A CN202110155778 A CN 202110155778A CN 112800362 B CN112800362 B CN 112800362B
- Authority
- CN
- China
- Prior art keywords
- view
- interface
- layout
- layout file
- attribute
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000011068 loading method Methods 0.000 title claims abstract description 105
- 238000000034 method Methods 0.000 claims description 25
- 230000001419 dependent effect Effects 0.000 claims description 13
- 230000006870 function Effects 0.000 claims description 7
- 238000009877 rendering Methods 0.000 claims description 2
- 238000011161 development Methods 0.000 abstract description 6
- 230000000694 effects Effects 0.000 abstract description 5
- 230000008878 coupling Effects 0.000 abstract description 3
- 238000010168 coupling process Methods 0.000 abstract description 3
- 238000005859 coupling reaction Methods 0.000 abstract description 3
- 230000003111 delayed effect Effects 0.000 abstract description 2
- 238000005034 decoration Methods 0.000 description 6
- 241000209140 Triticum Species 0.000 description 4
- 235000021307 Triticum Nutrition 0.000 description 4
- 230000008569 process Effects 0.000 description 4
- 238000013459 approach Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- 230000005540 biological transmission Effects 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 239000012634 fragment Substances 0.000 description 1
- 230000014509 gene expression Effects 0.000 description 1
- 238000003780 insertion Methods 0.000 description 1
- 230000037431 insertion Effects 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000008707 rearrangement Effects 0.000 description 1
- 238000010187 selection method Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/957—Browsing optimisation, e.g. caching or content distillation
- G06F16/9574—Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/451—Execution arrangements for user interfaces
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Human Computer Interaction (AREA)
- User Interface Of Digital Computer (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the application discloses an interface view delay loading method and device. According to the technical scheme provided by the embodiment of the application, the constraint layout of the flat view hierarchical structure is adopted as the root try group of the interface, so that view layout file analysis is more efficient in operation, more constraint rules can be provided, various complex layout effects are realized, and development efficiency is improved; the trace-source view with small memory occupation occupies a space in the constraint layout, and layout parameters of the view layout file in the constraint layout are set on the trace-source view, so that the dependency relationship between the hierarchical structure information of each trace-source view in the constraint layout and each trace-source view can be determined, and the analysis cost is low; via tracing view analysis to the view layout file of the view, the view metadata can be placed at the corresponding position, the view is loaded in a delayed mode according to the dependency relationship among the views, the running smoothness of the program is greatly improved, the layout coupling of complex interfaces is reduced, and the development iteration cost is reduced.
Description
Technical Field
The embodiment of the application relates to the technical field of application program development, in particular to an interface view delay loading method, an interface view delay loading device, computer equipment and a storage medium.
Background
In android, a layout is used to define interface structures in an application. All elements in the layout are built using the hierarchy of view and view group objects. Specifically, the layout can be declared in two ways, namely, interface elements are declared in XML (extensible markup language), and android provides concise XML words corresponding to view classes and subclasses thereof, such as words for views and layout; secondly, the layout elements are instantiated at runtime, and view objects and view group objects can be created programmatically. Each view object implements a nested class of extended view group layout parameters. The attribute type contained in this sub-class will define the size and location for each sub-view of the view group as desired. When compiling an application, the system will compile each XML layout file into view resources. Layout resources in the in-loading application code are implemented in the Activity.onCreate () method callback.
For a complex android interface, some view elements are displayed without reentering the interface, and only when the touch time of the relevant user or the program state change is received, two implementations are generally adopted. Firstly, all states are in the layout file, the visibility of the states is set to be hidden or invisible, and the states are set to be visible when the conditions are met. The disadvantage of this approach is that while the view is set invisible, a large number of view objects and layout attribute objects are created when loading the layout, more objects are created for more complex interfaces, affecting program execution performance, and more seriously causing interface jamming, affecting user experience. Secondly, the view element is instantiated again at the runtime, and a layout parameter object is created, and the view element is added to the interface. The disadvantage of this approach is that in order to guarantee the hierarchy of view elements, the position of view element insertion and the attribute of layout parameters need to be calculated in real time according to the layout state of the current interface, so as to avoid the situation that the view elements are blocked or the layout parameters are wrong. And when new view elements are dynamically added again later, the existing view elements also need to be adjusted according to the situation. For complex interfaces, code logic is difficult to write, and also causes program modification and maintenance difficulties when subsequent interface designs change.
Disclosure of Invention
The embodiment of the application provides an interface view delay loading method, an interface view delay loading device, computer equipment and a storage medium, which are used for realizing delay loading of view elements, ensuring smooth running of a program and supporting multi-service scene expansion.
In a first aspect, an embodiment of the present application provides an interface view delay loading method, including:
Loading an interface view layout file corresponding to an interface to be displayed, wherein the interface view layout file takes constraint layout as a root view group, a plurality of traceable views are formed in the root view group of the interface view layout file, each traceable view respectively has layout parameters and hierarchical structure information, and each traceable view forms a dependency relationship;
Analyzing the interface view layout file to obtain interface view metadata, wherein the interface view metadata comprises view layout files of views contained in an interface to be displayed, and the view layout files comprise attribute parameters and dependency relations among the views; each traceable view corresponds to a view layout file; the layout parameters of the traceable view are used for indicating the corresponding view layout file;
and when receiving view trigger information, responding to the view trigger information based on the corresponding view layout file.
In a second aspect, an embodiment of the present application provides an interface view delay loading device, including:
A file loading module: the method comprises the steps of loading an interface view layout file corresponding to an interface to be displayed, wherein the interface view layout file takes constraint layout as a root view group, a plurality of tracing views are formed in the root view group of the interface view layout file, each tracing view has layout parameters, and dependency relations are formed among the tracing views;
And a file analysis module: the interface view metadata comprises view layout files of views contained in the interface to be displayed, wherein the view layout files comprise attribute parameters and hierarchical structure information among the views; each traceable view corresponds to a view layout file; the layout parameters of the traceable view are used for indicating the corresponding view layout file;
view loading module: and the method is used for loading the corresponding view layout file when receiving the view trigger information.
In a third aspect, an embodiment of the present application provides a computer apparatus, including: a memory and one or more processors;
the memory is used for storing one or more programs;
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement an interface view latency loading method as described in the first aspect.
In a fourth aspect, embodiments of the present application provide a storage medium containing computer executable instructions which, when executed by a computer processor, are used to perform an interface view latency loading method as described in the first aspect.
According to the embodiment of the application, the constraint layout of the flat view hierarchical structure is adopted as the root try group of the interface, so that view layout file analysis is more efficient in operation, more constraint rules can be provided, various complex layout effects are realized, and development efficiency is improved; the trace-source view with small memory occupation occupies a space in the constraint layout, and the layout parameters of the view layout file in the constraint layout are set on the trace-source view, so that the dependency relationship between the hierarchical structure information of each trace-source view in the constraint layout and each trace-source view can be determined, and the analysis cost and the creation cost are low; via tracing view analysis to view layout file of view, the view metadata can be placed at corresponding position, and the view is loaded according to time delay according to dependency relationship between views, thereby greatly improving running smoothness of program, reducing layout coupling of complex interface, reducing development iteration cost, and supporting expansion of various service scenes.
Drawings
FIG. 1 is a flowchart of an interface view time-lapse loading method provided by an embodiment of the present application;
FIG. 2 is a flowchart of another method for loading interface view delay according to an embodiment of the present application;
FIG. 3 is a flow chart of another method for loading interface view time delay according to an embodiment of the present application;
FIG. 4 is a flowchart of another method for loading interface view delay according to an embodiment of the present application;
Fig. 5 is a schematic structural diagram of an interface view delay loading device according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the following detailed description of specific embodiments of the present application is given with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the matters related to the present application are shown in the accompanying drawings. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart depicts operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently, or at the same time. Furthermore, the order of the operations may be rearranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figures. The processes may correspond to methods, functions, procedures, subroutines, and the like.
The embodiment of the application provides an interface view delay loading method, an interface view delay loading device, computer equipment and a storage medium. According to the embodiment of the application, the constraint layout of the flat view hierarchical structure is adopted as the root try group of the interface, so that view layout file analysis is more efficient in operation, more constraint rules can be provided, various complex layout effects are realized, and development efficiency is improved; the trace-source view with small memory occupation occupies a space in the constraint layout, and the layout parameters of the view layout file in the constraint layout are set on the trace-source view, so that the dependency relationship between the hierarchical structure information of each trace-source view in the constraint layout and each trace-source view can be determined, and the analysis cost and the creation cost are low; via tracing view analysis to view layout file of view, the view metadata can be placed at corresponding position, and the view is loaded according to time delay according to dependency relationship between views, thereby greatly improving running smoothness of program, reducing layout coupling of complex interface, reducing development iteration cost, and supporting expansion of various service scenes.
The following detailed description is given respectively.
Fig. 1 shows a flowchart of an interface view delay loading method provided by an embodiment of the present application, where the interface view delay loading method provided by the embodiment of the present application may be implemented by an interface view delay loading device, and the interface view delay loading device may be implemented by hardware and/or software and is integrated in a computer device.
The following describes an example of an interface view delay loading device executing an interface view delay loading method. Referring to fig. 1, the interface view delay loading method includes:
101: and loading an interface view layout file corresponding to the interface to be displayed.
The interface view layout file is a file generated by describing interface view information of an interface to be displayed in advance by adopting a structured language. The developer can pre-create an interface view layout file according to the business needs and structured language specifications. In an embodiment of the present application, the structured language applied by the interface view layout file may be XML (extensible markup language). Interface view information of the interface to be displayed can correspond to one or more interface view layout files, namely, one or more views can be corresponding, and the number of the views can be set according to service requirements.
The interface view layout file in this embodiment has a constraint layout as the root view group. Constraint layout is the creation of a complex large layout, i.e., a non-nested view group, using a flat view hierarchy. All views in the constraint layout are laid out according to the relation between the peer view and the parent view, and the analysis of the layout file is more efficient in running. In the constraint layout, a plurality of traceable views are formed, and the traceable views occupy positions in the constraint layout. Each traceable view has layout parameters and hierarchical structure information, and dependency relations are formed among the traceable views. The trace-source view is an invisible view with the size of 0 in the embodiment, so that the layout parameters of the constraint layout are set on the trace-source view, and the hierarchical structure information of each trace-source view in the constraint layout and the interdependence relationship among each trace-source view can be determined. Because the trace-source view object has smaller memory occupation, the analysis and creation costs are lower.
In the embodiment of the application, the interface view layout file of the interface to be displayed can be specifically determined according to the corresponding relation between the interface and the interface view layout file. Layout parameters may include attribute parameters such as background color, foreground color, font color, text font, font size, font style, and the like. The hierarchical structure information includes a peer structure relationship and a parent-child structure relationship.
The traceability view can be expressed in a view stub mode in the embodiment of the application, and in other examples, the traceability view can also be a fragment view, and attribute information and dependency relationship of the view can be obtained through the traceability view.
102: And analyzing the interface view layout file to obtain the interface view metadata.
The interface view metadata comprises view layout files of views contained in the interface to be displayed, wherein the view layout files comprise attribute parameters and dependency relations among the views. Each traceable view corresponds to a view layout file, and layout parameters of the traceable view are used for indicating the corresponding view layout file.
The embodiment is applied to the android system, and the required hardware environment is hardware equipment supporting the android system. As an applicable hardware device, for example, an android mobile terminal. By way of example, layout loading may be applied to complex interfaces in android mobile terminals. For example, a forum application program applied to the android mobile terminal is used for loading interface view layout files of each application program in the android mobile terminal, wherein the interface view layout files comprise the forum application program. In the initial display interface of the android mobile terminal, only the view which is originally used for symbolizing the identity of the application program and plays a role in representation of the application program is often displayed, and various complex view relations in the application program are not loaded. When the user enters the interface, which may be the initial interface into the android mobile terminal, an initial view of one or more applications is displayed in the interface. Or a user entering an interface, which refers to the initial interface of a particular application that is displayed after the application is touched. In this embodiment, loading the interface view layout file corresponding to the interface to be displayed includes the two cases. For both cases, it is actually the end that a specific view in a specific application program is parsed and loaded. For the first case, the user enters the initial interface of the android mobile terminal, and the interface view layout files of all application programs in the interface are loaded. At this time, the step is often performed by selecting all the applications by the user, and selecting a specific application. And when the interface of the specific application program is accessed corresponding to the second condition, loading an interface view layout file of the application program.
As an application scenario, in the forum application, each registered user of the forum is given a virtual room in which a wheat position for giving the registered user a talk is set, and various decorations such as head portraits, head frames, nicknames, grades, expressions, special effects on wheat are provided on the wheat position. The decorations are stacked on the wheat position according to a certain layout rule, are not displayed when a registered user initially enters a room interface, and are displayed as required when the registered user pulls up data or receives a specific time notification. In the embodiment, the decorations are actually divided into different views, each view respectively completes own service functions, and the new addition, deletion, layout planning adjustment and the like of the decorations are easy to realize according to service adjustment, so that the codes are convenient, the flexible configuration is realized, and the expandability is strong.
Before the views are displayed according to the requirement, firstly entering an interface, and analyzing an interface view layout file corresponding to the interface to be displayed to obtain interface view metadata. The desired view may be displayed through a view layout file of the interface view metadata.
103: And when receiving view trigger information, responding to the view trigger information based on the corresponding view layout file.
The view trigger information in the embodiment of the application may be actively initiated by a user, and for example, when the user logs in to a specific application program interface, such as a forum application program, the forum application program provides a personal virtual room and a public forum, and when the user further clicks in the personal virtual room, the user triggers and loads a view layout file of a first-level decoration in the personal virtual room, such as a user name, a user grade, a user head portrait and a posting theory, and when the user further clicks in one posting theory, the user enters a next-level view layout file of the posting theory, and as a result of active triggering by the user, the view corresponding to the specific content of the posting theory is loaded. On the other hand, the method may also be triggered by other conditions, for example, a triggering condition is preset, when a user enters a personal virtual room in a forum application program, a view layout file of a first-level decoration in the personal virtual room is triggered and loaded, for example, a user name, a user grade and a user head portrait, if the triggering condition is a preset duration, and when the preset duration is met, the view layout file of a statement made by the user is automatically loaded and displayed.
In the embodiment of the application, the layout parameters of the traceable view comprise a first ID attribute and a lazy loading attribute, the view layout file comprises a second ID attribute, and the assignment of the first ID attribute, the assignment of the lazy loading (INFLATEDID) attribute and the assignment of the second ID attribute are equal.
Layout attributes are specified in layout parameters of the traceable view, which are used to indicate the corresponding view layout file. When the view elements of the view layout file are loaded in a subsequent time delay, the layout parameters of the traceable view are applied to the view. And designating a first ID attribute and a lazy loading attribute in layout parameters of the traceable view, and designating a second ID attribute of layout parameters of a view layout file, wherein the three attributes keep assignment consistency. And when the interface view layout file is loaded, the lazy loading attribute is used for rewriting the second ID attribute. After the view is loaded in a delay manner, constraint setting in the layout file can be guaranteed to be continuously effective according to the ID attribute of the view, so that the view element is placed on the corresponding position of the interface.
As shown in fig. 2, the embodiment of the present application further provides another interface view delay loading method, which includes:
201: and loading an interface view layout file corresponding to the interface to be displayed.
202: And analyzing the interface view layout file to obtain all view layout files of the interface view metadata.
And analyzing the interface view layout file based on the loaded interface view layout file to obtain the interface view metadata. In this embodiment, the interface view metadata corresponds to one or more view layout files, and after parsing, all view layout files of the interface view metadata may be obtained. The view layout file corresponds to a view, which may include one or more view elements.
203: Defining each view layout file corresponding to the traceable view as a target view layout file, acquiring attribute parameters of the target view layout file, and analyzing the attribute parameters of the target view layout file.
In the embodiment of the application, a root view group of constraint layout is adopted, and hierarchical structure information, namely hierarchical relations among different views, including parent-child relations between a peer in the root view group and an upper hierarchy and a lower hierarchy are contained in the root view group. The application mainly adopts a tracing view mode to occupy a place in the constraint layout, but not limits that all views in the constraint layout adopt a tracing view mode, but comprises a tracing view display mode and a non-tracing view display mode so as to adapt to delay loading on demand of some view elements and not delay loading of some view elements. In this embodiment, a further description is focused on view elements that need to be displayed with a delay. Therefore, the view layout file needing to be loaded according to the time delay is defined as the target view layout file, only the attribute parameters of the target view layout file are acquired, and the attribute parameters are analyzed so as to realize the loading of the view according to the attribute parameters later.
204: And acquiring the dependency relationship among the views based on the attribute parameters of the target view layout files.
Because the hierarchical structure relationship and the layout parameters of each traceable view are configured in the constraint layout, and the traceable view corresponds to a specific view layout file, the view layout file comprises attribute parameters, the attribute parameters of the view layout file and the attribute parameters of the traceable view are mapped with each other, and according to the attribute parameters of the view layout file, the traceable view corresponding to the view layout file can be obtained, and the traceable views have a dependency relationship, namely, the corresponding dependency relationship is formed among the respectively corresponding view layout files. In the application, dependency relationships, namely loaded precedence relationships, are formed among the views. Since the views correspond to view layout files, they are also referred to as dependencies between view layout files.
205: And when receiving view trigger information, responding to the view trigger information based on the corresponding view layout file.
Fig. 3 shows a flowchart of another interface view delay loading method according to an embodiment of the present application, and as shown in fig. 3, an interface view delay loading method includes:
301: and loading an interface view layout file corresponding to the interface to be displayed.
302: And analyzing the interface view layout file to obtain all view layout files of the interface view metadata.
303: Defining each view layout file corresponding to the traceable view as a target view layout file, acquiring attribute parameters of the target view layout file, and analyzing the attribute parameters of the target view layout file.
In this step, a view layout file of all views in the constraint layout can be obtained by using the GETCHILDREN () method in the constraint layout, whether the view is a traceable view is further determined, and the view is defined as ViewStub A, and if yes, all attribute parameters of the view layout file are obtained by using the getLayoutParams () method, and the attribute parameters are analyzed.
304: And calling a view searching function to search for the target object based on each assignment in the attribute parameters of the target view layout file. This view finding function is also called findViewById () method.
The attribute parameters correspond to a plurality of parameters, and each parameter corresponds to an assigned value. For example, the attribute parameters include font size, font color, then the font size and font analysis correspond to the assigned values, respectively. Specifically, for example, the attribute parameters include "layout_constraintLeft_toLeftOf、layout_constraintLeft_toRightOf、layout_constraintRight_toLeftOf、layout_constraintRight_toRightOf、layout_constraintTop_toTopOf、layout_constraintTop_toBottomOf、layout_constraintBottom_toTopOf、layout_constraintBottom_toBottomOf、layout_constraintBaseline_toBaselineOf、layout_constraintStart_toEndOf、layout_constraintStart_toStartOf、layout_constraintEnd_toStartOf、layout_constraintEnd_toEndOf", analyzing the attribute parameters to obtain values of each attribute parameter.
The findViewById () method finds the target object for invoking the required view in the object, i.e., looking up the view group and sub-view. And (3) judging the type of the obtained target object by calling findViewById () method, if the type is also the tracing view type and is positioned as ViewStub B, the ViewStub B is the view on which ViewStub A depends, and storing the dependency relationship into a set of storage dependency relationships. When the view pointed to by ViewStub A is to be loaded as needed, it is first determined ViewStub B whether the view pointed to has been loaded first.
305: When the target object corresponds to the traceable view, defining the target object as a dependent view layout file of the target view layout file, and acquiring a dependent relationship between the target view layout file and the target object.
When the found target object corresponds to the traceable view, namely belongs to the delayed on-demand loading view, the target object is a dependent view of the target view layout file, and the dependent relationship is acquired so as to judge whether the dependent view is loaded in advance when the view loading is carried out subsequently.
In this embodiment, the dependency relationship between the target view layout file and the target object is stored in a set, and flag information is further stored in the set, where the flag information is used to indicate whether loading of the target view layout file is completed.
306: And when receiving view trigger information, responding to the view trigger information based on the corresponding view layout file.
Fig. 4 is a flowchart of another interface view delay loading method according to an embodiment of the present application, and as shown in fig. 4, an interface view delay loading method includes:
401: and loading an interface view layout file corresponding to the interface to be displayed.
402: And analyzing the interface view layout file to obtain all view layout files of the interface view metadata.
403: Defining each view layout file corresponding to the traceable view as a target view layout file, acquiring attribute parameters of the target view layout file, and analyzing the attribute parameters of the target view layout file.
404: And calling a view searching function to search for the target object based on each assignment in the attribute parameters of the target view layout file. Specifically, in this embodiment, the view finding function is findViewById () method, which is to define the attribute of the view in the file to obtain the corresponding view object.
405: When the target object corresponds to the traceable view, defining the target object as a dependent view layout file of the target view layout file, and acquiring a dependent relationship between the target view layout file and the target object.
406: And receiving view trigger information, wherein the view trigger information comprises view information to be loaded. And calling a target view layout file corresponding to the view information to be loaded based on the view trigger information.
407: And detecting whether the loading of the target view layout file is completed. And when the loading of the target view layout file is completed, responding to the view trigger information. And when the target view layout file is not loaded, acquiring the dependency relationship of the target view layout file.
408: And judging whether all target objects corresponding to the dependency relationship are loaded, and loading the target view layout file when all target objects are loaded. And when the target objects are not completely loaded, loading the unloaded target objects, and loading the target view layout file after all the target objects are completely loaded.
In this embodiment, when performing view loading, it is checked first from the stored set of dependency relationships whether other views that are dependent have been previously loaded, and if not, the dependent views are loaded first. The recursion check is repeated until the views in the dependency relationship are loaded, and then the views are loaded. Expanding a flag bit in a set of storage dependency relationships, setting flag information, wherein the flag information is initially false, and is modified to true during loading, and whether the view is loaded or not can be judged according to the flag information.
As a preferred embodiment, responding to the view trigger information includes rendering and displaying a view corresponding to the target view layout file.
As shown in fig. 5, the embodiment of the present application further provides an interface view delay loading device, which includes a file loading module 501, a file parsing module 502, and a view loading module 503. The file loading module 501 is configured to load an interface view layout file corresponding to an interface to be displayed, where the interface view layout file uses constraint layout as a root view group, a plurality of trace views are formed in the root view group of the interface view layout file, each trace view has layout parameters, and dependency relationships are formed between trace views. The file parsing module 502 is configured to parse the interface view layout file to obtain interface view metadata, where the interface view metadata includes a view layout file of views included in the interface to be displayed, and the view layout file includes attribute parameters and hierarchical structure information between views; each traceable view corresponds to a view layout file; and the layout parameters of the traceable view are used for indicating the corresponding view layout file. The view loading module 503 is configured to load the corresponding view layout file when receiving the view trigger information.
In this embodiment, the layout parameters of the traceable view include a first ID attribute and a lazy loading attribute, and the view layout file includes a second ID attribute, where the assignment of the first ID attribute, the assignment of the lazy loading attribute, and the assignment of the second ID attribute are all equal. And when the interface view layout file is loaded, the lazy loading attribute is used for rewriting the second ID attribute.
As a preferred embodiment, in the file parsing module 502, the interface view layout file is parsed, specifically, the interface view layout file is parsed, so as to obtain all view layout files of the interface view metadata; defining each view layout file corresponding to the traceable view as a target view layout file, acquiring attribute parameters of the target view layout file, and analyzing the attribute parameters of the target view layout file; and acquiring the dependency relationship among the views based on the attribute parameters of the target view layout files.
As a still further preferred embodiment, the obtaining the dependency relationship between the views based on the attribute parameters of the view layout file of each object includes: calling findViewById () method to find a target object based on each assignment in the attribute parameters of the target view layout file; when the target object corresponds to the traceable view, defining the target object as a dependent view layout file of the target view layout file, and acquiring a dependent relationship between the target view layout file and the target object.
In this embodiment, the dependency relationship between the target view layout file and the target object is stored in a set, and flag information is further stored in the set, where the flag information is used to indicate whether loading of the target view layout file is completed. When view trigger information is received, a target view layout file corresponding to view information to be loaded contained in the view trigger information is called based on the view trigger information, whether the loading of the target view layout file is completed is detected, and when the loading of the target view layout file is completed, the view trigger information is responded; when the target view layout file is not loaded, acquiring the dependency relationship of the target view layout file; and judging whether all target objects corresponding to the dependency relationship are loaded, and loading the target view layout file when all target objects are loaded.
As shown in fig. 6, an embodiment of the present application further provides a computer device, including: a memory 601 and one or more processors 602; the memory 601 is used for storing one or more programs; the one or more programs, when executed by the one or more processors 602, cause the one or more processors to implement an interface view latency loading method in accordance with the present application.
Embodiments of the present application also provide a storage medium containing computer-executable instructions which, when executed by a computer processor, are used to perform an interface view latency loading method as provided by the above embodiments.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present application is not limited to the above-mentioned method for loading the interface view delay, and may also perform the related operations in the method for loading the interface view delay provided in any embodiment of the present application.
The interface view delay loading device, the device and the storage medium provided in the foregoing embodiments may perform the interface view delay loading method provided in any embodiment of the present application, and technical details not described in detail in the foregoing embodiments may refer to the path selection method based on data transmission of the internet of things provided in any embodiment of the present application.
The foregoing description is only of the preferred embodiments of the application and the technical principles employed. The present application is not limited to the specific embodiments described herein, but is capable of numerous modifications, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, while the application has been described in connection with the above embodiments, the application is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit of the application, the scope of which is set forth in the following claims.
Claims (9)
1. An interface view time delay loading method is characterized by comprising the following steps:
Loading an interface view layout file corresponding to an interface to be displayed, wherein the interface view layout file takes constraint layout as a root view group, a plurality of traceable views are formed in the root view group of the interface view layout file, each traceable view respectively has layout parameters and hierarchical structure information, and each traceable view forms a dependency relationship;
Analyzing the interface view layout file to obtain interface view metadata, wherein the interface view metadata comprises view layout files of views contained in an interface to be displayed, and the view layout files comprise attribute parameters and dependency relations among the views; each traceable view corresponds to a view layout file; the layout parameters of the traceable view are used for indicating the corresponding view layout file, the layout parameters of the traceable view comprise a first ID attribute and a lazy loading attribute, the view layout file comprises a second ID attribute, the assignment of the first ID attribute, the assignment of the lazy loading attribute and the assignment of the second ID attribute are all equal, and when the interface view layout file is loaded, the lazy loading attribute is used for rewriting the second ID attribute;
and when receiving view trigger information, responding to the view trigger information based on the corresponding view layout file.
2. The interface view delay loading method of claim 1, wherein parsing the interface view layout file comprises:
analyzing the interface view layout file to obtain all view layout files of the interface view metadata;
Defining each view layout file corresponding to the traceable view as a target view layout file, acquiring attribute parameters of the target view layout file, and analyzing the attribute parameters of the target view layout file;
And acquiring the dependency relationship among the views based on the attribute parameters of the target view layout files.
3. The interface view delay loading method of claim 2, wherein obtaining the dependency relationship between the views based on the attribute parameters of the target view layout file comprises:
calling a view searching function to search for a target object based on each assignment in the attribute parameters of the target view layout file;
When the target object corresponds to the traceable view, defining the target object as a dependent view layout file of the target view layout file, and acquiring a dependent relationship between the target view layout file and the target object.
4. The interface view latency loading method according to claim 3, wherein a dependency relationship between the target view layout file and the target object is stored in a set, and flag information is further stored in the set, wherein the flag information is used for indicating whether loading of the target view layout file is completed.
5. The interface view latency loading method according to claim 4, wherein when receiving view trigger information, responding to the view trigger information based on the corresponding view layout file, comprises:
receiving view trigger information, wherein the view trigger information comprises view information to be loaded;
calling a target view layout file corresponding to view information to be loaded based on view trigger information, and detecting whether the loading of the target view layout file is completed;
When the loading of the target view layout file is completed, responding to the view trigger information;
When the target view layout file is not loaded, acquiring the dependency relationship of the target view layout file;
and judging whether all target objects corresponding to the dependency relationship are loaded, and loading the target view layout file when all target objects are loaded.
6. The interface view latency loading method according to claim 5, wherein responding to the view trigger information comprises rendering and displaying a view corresponding to a target view layout file.
7. An interface view delay loading device, comprising:
A file loading module: the method comprises the steps of loading an interface view layout file corresponding to an interface to be displayed, wherein the interface view layout file takes constraint layout as a root view group, a plurality of tracing views are formed in the root view group of the interface view layout file, each tracing view has layout parameters, and dependency relations are formed among the tracing views;
And a file analysis module: the interface view metadata comprises view layout files of views contained in the interface to be displayed, wherein the view layout files comprise attribute parameters and hierarchical structure information among the views; each traceable view corresponds to a view layout file; the layout parameters of the traceable view are used for indicating the corresponding view layout file, the layout parameters of the traceable view comprise a first ID attribute and a lazy loading attribute, the view layout file comprises a second ID attribute, the assignment of the first ID attribute, the assignment of the lazy loading attribute and the assignment of the second ID attribute are all equal, and when the interface view layout file is loaded, the lazy loading attribute is used for rewriting the second ID attribute;
view loading module: and the method is used for loading the corresponding view layout file when receiving the view trigger information.
8. A computer device, comprising: a memory and one or more processors;
the memory is used for storing one or more programs;
When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the interface view latency loading method of any of claims 1-6.
9. A storage medium containing computer executable instructions which, when executed by a computer processor, are for performing the interface view latency loading method of any of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110155778.XA CN112800362B (en) | 2021-02-04 | 2021-02-04 | Interface view time delay loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110155778.XA CN112800362B (en) | 2021-02-04 | 2021-02-04 | Interface view time delay loading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112800362A CN112800362A (en) | 2021-05-14 |
CN112800362B true CN112800362B (en) | 2024-05-17 |
Family
ID=75814190
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110155778.XA Active CN112800362B (en) | 2021-02-04 | 2021-02-04 | Interface view time delay loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112800362B (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101652787A (en) * | 2007-03-30 | 2010-02-17 | 微软公司 | In-memory caching of shared customizable multi-tenant data |
CN105446755A (en) * | 2014-08-06 | 2016-03-30 | 阿里巴巴集团控股有限公司 | Method and device for rapidly loading Activity data for Android system |
CN109634598A (en) * | 2018-12-14 | 2019-04-16 | 北京字节跳动网络技术有限公司 | A kind of page display method, device, equipment and storage medium |
CN110020280A (en) * | 2017-09-08 | 2019-07-16 | 腾讯科技(深圳)有限公司 | Application page methods of exhibiting, device, storage medium and computer equipment |
CN110832456A (en) * | 2018-03-27 | 2020-02-21 | 谷歌有限责任公司 | Creating default layout constraints for a graphical interface |
CN111367518A (en) * | 2018-12-26 | 2020-07-03 | 北京奇虎科技有限公司 | Page layout method and device, computing equipment and computer storage medium |
CN111475163A (en) * | 2020-06-22 | 2020-07-31 | 腾讯科技(深圳)有限公司 | Method, device and equipment for generating code file of view template and storage medium |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9325806B2 (en) * | 2012-02-24 | 2016-04-26 | Qualcomm Incorporated | Cooperative loading of webpages based on shared meta information |
-
2021
- 2021-02-04 CN CN202110155778.XA patent/CN112800362B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101652787A (en) * | 2007-03-30 | 2010-02-17 | 微软公司 | In-memory caching of shared customizable multi-tenant data |
CN105446755A (en) * | 2014-08-06 | 2016-03-30 | 阿里巴巴集团控股有限公司 | Method and device for rapidly loading Activity data for Android system |
CN110020280A (en) * | 2017-09-08 | 2019-07-16 | 腾讯科技(深圳)有限公司 | Application page methods of exhibiting, device, storage medium and computer equipment |
CN110832456A (en) * | 2018-03-27 | 2020-02-21 | 谷歌有限责任公司 | Creating default layout constraints for a graphical interface |
CN109634598A (en) * | 2018-12-14 | 2019-04-16 | 北京字节跳动网络技术有限公司 | A kind of page display method, device, equipment and storage medium |
CN111367518A (en) * | 2018-12-26 | 2020-07-03 | 北京奇虎科技有限公司 | Page layout method and device, computing equipment and computer storage medium |
CN111475163A (en) * | 2020-06-22 | 2020-07-31 | 腾讯科技(深圳)有限公司 | Method, device and equipment for generating code file of view template and storage medium |
Non-Patent Citations (3)
Title |
---|
Inspection and Characterization of App File Usage in Mobile Devices;Cheng Ji et al.;《ACM Transactions on Storage》;20200924;1-25 * |
基于Android平台的保健食品移动监管系统的研究与开发;龚文静;《中国优秀硕士学位论文全文数据库 信息科技辑》;20160315;I138-2738 * |
基于Android的消息应用的设计与实现;郝秋影;《中国优秀硕士学位论文全文数据库 信息科技辑》;20131115;I138-410 * |
Also Published As
Publication number | Publication date |
---|---|
CN112800362A (en) | 2021-05-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20220318336A1 (en) | Method and Terminal Device for Extracting Web Page Content | |
KR101790190B1 (en) | Application scenario identification method, power consumption management method, apparatus, and terminal device | |
CN105511873B (en) | User interface control display method and device | |
CN110427215A (en) | A kind of program version mRNA differential display mRNA method and device applied to front end exploitation | |
CN113468448A (en) | Page rendering method and device | |
KR20080021081A (en) | Fine-grained control of z-order elements in a xml presentation | |
US9038019B2 (en) | Paige control for enterprise mobile applications | |
US20050289450A1 (en) | User interface virtualization | |
US9880861B2 (en) | Method and apparatus for page view switching | |
CN111068328A (en) | Game advertisement configuration table generation method, terminal device and medium | |
CN113641338B (en) | Method and device for dynamically generating view component | |
CN111625290B (en) | Layout file preloading method and device under Android platform and electronic equipment | |
CN112631591A (en) | Table element linkage method, device, equipment and computer readable storage medium | |
US20050216883A1 (en) | API for building semantically rich diagramming tools | |
CN112965716B (en) | Page processing method and device, electronic equipment and readable storage medium | |
CN114443024A (en) | Method and system for realizing visualized UI (user interface) dragging layout without limitation of nested hierarchy | |
CN107977307B (en) | Application debugging method and device | |
CN112800362B (en) | Interface view time delay loading method and device | |
CN114020589A (en) | Embedded point processing method and device, computer equipment and storage medium | |
CN111190653A (en) | Method, computing device and computer readable medium for implementing context menu expansion | |
CN114895884A (en) | Method and system for compiling and executing RPA script of terminal equipment | |
CN114489619A (en) | Interface view display method, terminal equipment and computer readable storage medium | |
CN112988136B (en) | User interface editing method and device | |
CN116628272B (en) | Tree structure node rapid selection method based on vue framework | |
CN112764750B (en) | Interface generation method, device, electronic equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |