CN110032406B - Message-based view loading method, device, equipment and storage medium - Google Patents
Message-based view loading method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN110032406B CN110032406B CN201910304351.4A CN201910304351A CN110032406B CN 110032406 B CN110032406 B CN 110032406B CN 201910304351 A CN201910304351 A CN 201910304351A CN 110032406 B CN110032406 B CN 110032406B
- Authority
- CN
- China
- Prior art keywords
- view
- protocol
- loading
- function
- target
- 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
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44505—Configuring for program initiating, e.g. using registry, configuration files
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The embodiment of the invention discloses a message-based view loading method, a message-based view loading device, message-based view loading equipment and a message-based view loading storage medium. The method comprises the following steps: when a function starting message for triggering view loading is received, determining a target view identifier of a target view according to the function starting message; using the target view identification as an input parameter, calling an object acquisition function through an object set to obtain a target view protocol object corresponding to the target view identification, wherein the object set is used for storing each view identification and a view protocol object corresponding to each view identification, and the view protocol object is generated by an initial view class based on a predefined view loading protocol; and calling a view loading protocol function through the target view protocol object to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol. By the technical scheme, distributed loading of each view in the page is achieved, and the page starting speed is increased.
Description
Technical Field
The present invention relates to computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for message-based view loading.
Background
At present, in an application program developed based on an Android system, each view in one page is loaded when the page is started. If a very large number of views contained in a page are displayed during page starting, a large number of view loading operations need to be executed during the page starting process, so that the starting process of the whole page is time-consuming and long, the page starting speed is slow, and the user experience is affected.
Disclosure of Invention
The embodiment of the invention provides a message-based view loading method, a message-based view loading device and a message-based view loading storage medium, so as to realize distributed loading of each view in a page and improve the page starting speed.
In a first aspect, an embodiment of the present invention provides a message-based view loading method, including:
when a function starting message for triggering view loading is received, determining a target view identifier of a target view according to the function starting message;
using the target view identifier as an input parameter, calling an object acquisition function through an object set to obtain a target view protocol object corresponding to the target view identifier, wherein the object set is used for storing each view identifier and a view protocol object corresponding to each view identifier, and the view protocol object is generated by an initial view class based on a predefined view loading protocol;
and calling a view loading protocol function through the target view protocol object to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol.
Optionally, before the step of taking the target view identifier as an input parameter and calling an object obtaining function through an object set to obtain a target view protocol object corresponding to the target view identifier, the method further includes:
after any view protocol object is generated, the view identification of the view protocol object and the view protocol object are used as input parameters, an object registration function is called through a message distribution object, and the view identification of the view protocol object and the view protocol object are stored in the object set.
Further, generating the view protocol object includes:
the initial view class inherits the view loading protocol through a protocol inheriting keyword and rewrites a protocol function in the view loading protocol to obtain a protocol view class and the view loading protocol function in the protocol view class;
and generating the view protocol object according to the protocol view class, wherein the view protocol object is a view object of a view loading protocol type.
Optionally, the set of objects has a private rights modifier, the set of objects is a set of predefined key-value pair types, and the type of the key of the set of objects is a view loading protocol type.
Optionally, the view loading protocol function implements a function of loading the target view by:
taking a system layout service keyword as an input parameter, calling a system object acquisition function through a context object, and acquiring a system loading object;
and taking the layout file identifier corresponding to the target view as an input parameter, calling a view layout function through the system loading object, loading the layout file of the target view, and generating a loading view object of the view type.
Further, after generating the view object of the view type, the method further includes:
and respectively taking the sub-view identification corresponding to each sub-view in the target view as an input parameter, calling a sub-view search function through the loaded view object, and obtaining each sub-view object and the loading information corresponding to each sub-view object so as to fill the target view.
In a second aspect, an embodiment of the present invention further provides a message-based view loading apparatus, where the apparatus includes:
the target view identification determining module is used for determining the target view identification of the target view according to the function starting message when the function starting message triggering view loading is received;
a target view protocol object obtaining module, configured to call an object obtaining function through an object set by using the target view identifier as an input parameter, to obtain a target view protocol object corresponding to the target view identifier, where the object set is used to store each view identifier and a view protocol object corresponding to each view identifier, and the view protocol object is generated based on a predefined view loading protocol for an initial view class;
and the target view loading module is used for calling a view loading protocol function through the target view protocol object so as to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes an object storage module, configured to:
and after any view protocol object is generated, using the view identifier of the view protocol object and the view protocol object as input parameters, calling an object registration function through a message distribution object, and storing the view identifier of the view protocol object and the view protocol object to the object set.
Further, the object storage module comprises a view protocol object generation submodule for generating the view protocol object by:
the initial view class inherits the view loading protocol through a protocol inheriting keyword and overwrites a protocol function in the view loading protocol to obtain a protocol view class and the view loading protocol function in the protocol view class;
and generating the view protocol object according to the protocol view class, wherein the view protocol object is a view object of a view loading protocol type.
Optionally, the set of objects has a private rights modifier, the set of objects is a set of predefined key-value pair types, and the type of the key of the set of objects is a view loading protocol type.
Optionally, the target view loading module includes a function execution sub-module, configured to implement a function of loading the target view by:
taking a system layout service keyword as an input parameter, calling a system object acquisition function through a context object, and acquiring a system loading object;
and taking the layout file identifier corresponding to the target view as an input parameter, calling a view layout function through the system loading object, loading the layout file of the target view, and generating a loading view object of the view type.
Further, the function execution submodule is specifically configured to:
after generating a view type loading view object, respectively using a sub-view identifier corresponding to each sub-view in the target view as an input parameter, calling a sub-view search function through the loading view object, and obtaining each sub-view object and loading information corresponding to each sub-view object to fill the target view.
In a third aspect, an embodiment of the present invention further provides an apparatus, where the apparatus includes:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the message-based view loading method provided by any of the embodiments of the invention.
In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the message-based view loading method provided in any embodiment of the present invention.
The embodiment of the invention determines the target view identification of the target view according to the function starting message when receiving the function starting message for triggering view loading; taking the target view identification as an input parameter, calling an object acquisition function through an object set, and acquiring a target view protocol object corresponding to the target view identification; and calling a view loading protocol function through the target view protocol object to load the target view. The method and the device realize that the target view needing to be loaded is determined and the loading operation of the target view is executed in the message distributor according to the received function starting message, solve the problem of slow page starting caused by that all views in the page must be loaded when the page is started, and achieve the aim of carrying out distributed loading on each view in the page according to the message, thereby improving the page starting speed and the technical effect of improving the user experience.
Drawings
Fig. 1 is a flowchart of a message-based view loading method according to a first embodiment of the present invention;
fig. 2 is a schematic structural diagram of a message-based view loading apparatus according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of an apparatus in a third embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
The message-based view loading method provided by the embodiment can be applied to the starting situation of the application program based on the Android system. The method can be executed by a message-based view loading device, which can be implemented in a software and/or hardware manner, and the device can be integrated in a device equipped with an Android system, for example, a typical user terminal device, such as a mobile phone, a tablet computer, or a smart television. Referring to fig. 1, the method of the present embodiment includes:
s110, when a function starting message for triggering view loading is received, determining a target view identifier of a target view according to the function starting message.
The function starting message is the first message for triggering the control to execute the control function, and the issuing timing of the message is related to specific service requirements, for example, the message may be issued when the target view needs to be displayed, instead of being issued when the page where the target view is located is started. The function starting message at least comprises the corresponding view identification and the message content. The target view is the view that needs to be loaded. The target view identifier is an identifier of the target view, which may be at least one of a name, a substitute name, or other numbers, letters, symbols, etc. that uniquely characterize the target view.
Specifically, when the view loading apparatus receives a function start message, the view loading apparatus may parse the function start message, so as to obtain the view identifier included in the message, that is, obtain the target view identifier of the target view through the function start message. The reception of messages is usually provided with a message reception channel, which may also be referred to as a message distributor or message bus.
And S120, taking the target view identifier as an input parameter, calling an object acquisition function through the object set, and acquiring a target view protocol object corresponding to the target view identifier.
The object set is a predefined set for storing reference relationships of objects, and may be an array type or a list type, which may store data types of multiple objects. The object acquisition function is a member function of the object set that is used to acquire the set element values from the object set.
Illustratively, the set of objects has a private rights modifier, the set of objects is a set of predefined key-value pair types, and the type of the key of the set of objects is a view loading protocol type. Here, the view loading protocol is predefined, is used for implementing a protocol for loading views according to messages, and includes a view loading protocol function for implementing a view loading operation. For example, the protocol is implemented in the form of an interface, and then an example of the definition code of the view loading protocol is Public interface IInflate { Public void infileView (); h, IInfrate is the name of the view load protocol, and inflataView () is the view load protocol function. Taking Map key value pair as an example, an example code for defining and initializing an object set is private Map < String, iinfrate > mapList ═ new HashMap < String, iinfrate > (), mapList is the name of the object set, and is a global private variable, so that the object set mapList can only be accessed by a message distributor, and other classes cannot access the object set mapList. The key information in the object set is of a String type, which may correspond to a view id, and the value information in the object set represents object data of a view loading protocol type iinfly.
Illustratively, the object set is used to store view identifiers and view protocol objects corresponding to each view identifier. Wherein, the view protocol object is a view object of a view loading protocol type, which is generated based on a predefined view loading protocol for an initial view class, and comprises a view loading protocol function. According to the above description, the key information in the object set may correspond to a view identifier, and the value information may correspond to a view protocol object, that is, the object set constructs a mapping relationship between the view information and the view protocol object, and one view identifier corresponds to one view protocol object.
Specifically, after the view loading apparatus determines the target view identifier, in order to load the target view, it needs to acquire a view protocol object (i.e., a target view protocol object) corresponding to the target view, and then call a view loading protocol function through the target view protocol object, so as to implement loading of the target view.
Since the view protocol objects are all stored in the object set maintained by the message distributor, the view loading apparatus needs to first access the object set, which determines whether the object set mapList is empty by null. If the view loading process is empty, the view loading process based on the message is ended. If not, the object acquisition function, i.e. mapList.get (A), is called through the object set with the target view identification (e.g. A) as the function input parameter. The object obtaining function searches the value in the corresponding key value pair according to the target view identifier a and returns the value, that is, the view protocol object miilnflate corresponding to the target view identifier is obtained, which is called a target view protocol object.
Exemplarily, before S120, the method further includes: after any view protocol object is generated, the view identification and the view protocol object of the view protocol object are used as input parameters, an object registration function is called through a message distribution object, and the view identification and the view protocol object of the view protocol object are stored in an object set.
The message distribution object is an instantiation object corresponding to the message distributor, and is used for processing distribution of the message and view loading in the embodiment of the invention. The object registration function is a function defined in advance in the message distribution class, and is used for writing a set element into an object set, that is, registering the reference relationship of the view protocol object to the message distributor so that each view protocol object can be directly accessed when a view loading operation is performed. Example code for the object registration function is: public void setinflataLister (String viewName, IInflate inflataLister), the function name of which is setinflataLister, which is a function of Public type, and the return value is empty void type. The method is used for writing access to an object set, so that function input parameters of the method are the same as the key and value settings in the object set, the first function parameter is a String type argument viewName, and the second function parameter is an argument inflateLister of a view loading protocol IInflate type.
Specifically, according to the above description, the view identifier and the corresponding view protocol object are stored in the object set, so the adding process of the set element needs to be executed before the acquisition of the set element in S120 is executed. In specific implementation, after any view protocol object is generated, the view identifier corresponding to the view protocol object and the view protocol object are used as function input parameters, and an object registration function setinfiflelistener in the message distribution object is called. The internal implementation of the object registration function setinfiflelistener is: first, it may be determined whether the input parameter, i.e. the view protocol object and the view identifier thereof, is a correct function input parameter, for example, whether the view protocol object and the view identifier thereof are empty. If the current set element adding process is empty, the current set element adding process is ended. If not, the view protocol object and the view identifier thereof are used as function input parameters, an element addition function add () in the object set mapList is called, and the view identifier of the view protocol object and the view protocol object are stored in the object set.
Illustratively, generating the view protocol object includes: the initial view class inherits the view loading protocol through the protocol inheritance keyword and rewrites a protocol function in the view loading protocol to obtain the protocol view class and the view loading protocol function in the protocol view class; and generating a view protocol object according to the protocol view class, wherein the view protocol object is a view object of a view loading protocol type.
In particular, the view protocol object needs to be generated before a write access of the set of objects is performed. Since the view protocol object is a view object of a view loading protocol type, the initially defined view class (i.e., the initial view class) needs to be set to the legacy view loading protocol. In specific implementation, the view loading protocol is inherited by the initial view class through the protocol inheritance keyword instances, and a protocol function in the view loading protocol, namely the defined view loading protocol function, is rewritten and realized, so that the view class (namely the protocol view class) of the view loading protocol type and the view loading protocol function in the view loading protocol type can be obtained. Then, the object is instantiated based on the protocol view class, and a view protocol object is generated.
S130, calling a view loading protocol function through the target view protocol object to load the target view.
Specifically, after the target view protocol object is acquired, in order to improve the logic strictness, it is first determined whether the target view protocol object is empty by means of millinflate ═ null. And if the current view loading process is empty, ending the view loading process based on the message. If not, calling a view loading protocol function, namely mIInflate. inflateView (), in the target view protocol object to trigger and realize the loading operation of the target view.
Illustratively, the view loading protocol function implements the function of loading the target view by: taking a system layout service keyword as an input parameter, calling a system object acquisition function through a context object, and acquiring a system loading object; and taking the layout file identifier corresponding to the target view as an input parameter, calling a view layout function through the system loading object, loading the layout file of the target view, and generating a loading view object of the view type.
The system LAYOUT SERVICE keyword refers to a name or an identifier of a system development SERVICE provided by an Android system and used for realizing view LAYOUT, and may be, for example, LAYOUT _ inlater _ SERVICE. The system loading object is provided by an Android system and used for realizing view loading, and the system loading object comprises a function for realizing view layout and loading operation, namely a view layout function. The layout file is a file for recording information such as layout parameters of each view and control. The load view object refers to an object generated after the view is loaded.
Specifically, inside the view loading protocol function, view loading is realized through the following procedures: firstly, a system LAYOUT SERVICE keyword LAYOUT _ INFLATER _ SERVICE is taken as a function input parameter, a system object obtaining function getSystemservice in a Context object Context is called, namely Context. And then, calling a view layout function in a system loading object mInflater by taking a layout file identifier R.layout.view _ a corresponding to the target view A as a function input parameter to load the layout file information of the target view A, and laying out the target view according to the layout file information to generate a view loading object mView of the view type. The loading view object mView of view type in the memory represents the target view to be loaded, so that the loading of the whole target view A is completed.
According to the technical scheme of the embodiment, when a function starting message for triggering view loading is received, a target view identifier of a target view is determined according to the function starting message; taking the target view identification as an input parameter, calling an object acquisition function through an object set, and acquiring a target view protocol object corresponding to the target view identification; and calling a view loading protocol function through the target view protocol object to load the target view. The method and the device realize that the target view needing to be loaded is determined and the loading operation of the target view is executed in the message distributor according to the received function starting message, solve the problem of slow page starting caused by that all views in the page must be loaded when the page is started, and achieve the aim of carrying out distributed loading on each view in the page according to the message, thereby improving the page starting speed and the technical effect of improving the user experience.
On the basis of the above technical solution, after generating the view object of the view type, the method further includes: and respectively taking the sub-view identification corresponding to each sub-view in the target view as an input parameter, calling a sub-view search function through the loaded view object, and obtaining each sub-view object and the loading information corresponding to each sub-view object so as to fill the target view.
The sub-view identifier refers to an identifier uniquely characterizing the sub-view, and is a character string type, and may be at least one of letters, numbers, symbols, and the like. The sub-view searching function is a sub-view layout function provided by the Android system, and is used for determining layout information of the sub-view from the layout file and performing layout and content filling on the sub-view.
Specifically, the loaded target view is a parent view, also referred to as a view container, which is used to accommodate a specific display control, referred to as a child view of the parent view. After the target view is loaded, the content can be filled in each sub-view contained in the target view, so as to perform subsequent display operation. In specific implementation, the target view a includes several sub-views, and then the following processes are executed for several times: and calling a sub-view searching function findViewById () in the loaded view object mView by taking the sub-view identification as a function input parameter to obtain the sub-view object and layout information and loading information (such as filling content) of the sub-view object, so as to realize the loading and content filling of the sub-view. And after the loading operation of all the sub-views is finished, the target view is also filled. The advantage of this arrangement is that the corresponding display content filling can be directly performed after the target view is loaded, and the display speed of the target view can be further increased, thereby further increasing the page starting speed.
The following is an embodiment of a message-based view loading apparatus provided in an embodiment of the present invention, and the apparatus and the message-based view loading method in the foregoing embodiments belong to the same inventive concept, and details that are not described in detail in the embodiment of the message-based view loading apparatus may refer to the foregoing embodiment of the message-based view loading method.
Example two
The present embodiment provides a view loading apparatus based on a message, and referring to fig. 2, the apparatus specifically includes:
a target view identifier determining module 210, configured to determine, when receiving a function start message that triggers view loading, a target view identifier of a target view according to the function start message;
a target view protocol object obtaining module 220, configured to call an object obtaining function through an object set by using a target view identifier as an input parameter, to obtain a target view protocol object corresponding to the target view identifier, where the object set is used to store each view identifier and a view protocol object corresponding to each view identifier, and the view protocol object is generated based on a predefined view loading protocol for an initial view class;
and the target view loading module 230 is configured to call a view loading protocol function through the target view protocol object to load the target view, where the view loading protocol function is a protocol function included in the view loading protocol.
Optionally, on the basis of the foregoing apparatus, the apparatus further includes an object storage module, configured to:
before a target view protocol object corresponding to a target view identifier is obtained by calling an object acquisition function through an object set by taking the target view identifier as an input parameter, after any view protocol object is generated, an object registration function is called by taking the view identifier and the view protocol object of the view protocol object as the input parameters through a message distribution object, and the view identifier and the view protocol object of the view protocol object are stored in the object set.
Further, the object storage module comprises a view protocol object generation submodule for generating a view protocol object by:
the initial view class inherits the view loading protocol through the protocol inheriting keywords and rewrites a protocol function in the view loading protocol to obtain the protocol view class and the view loading protocol function in the protocol view class;
and generating a view protocol object according to the protocol view class, wherein the view protocol object is a view object of a view loading protocol type.
Optionally, the set of objects has a private rights modifier, the set of objects is a set of predefined key-value pairs types, and the type of the key of the set of objects is a view loading protocol type.
Optionally, the target view loading module 230 includes a function execution sub-module, configured to implement the function of loading the target view by:
taking a system layout service keyword as an input parameter, calling a system object acquisition function through a context object, and acquiring a system loading object;
and taking the layout file identifier corresponding to the target view as an input parameter, calling a view layout function through the system loading object, loading the layout file of the target view, and generating a loading view object of the view type.
Further, the function execution submodule is specifically configured to:
after the view type loading view object is generated, respectively taking the sub-view identifier corresponding to each sub-view in the target view as an input parameter, calling a sub-view search function through the loading view object, and obtaining the sub-view object and loading information corresponding to each sub-view object so as to fill the target view.
By the message-based view loading device in the second embodiment of the invention, distributed loading of each view in a page is realized, and the page starting speed is increased.
The message-based view loading device provided by the embodiment of the invention can execute the message-based view loading method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, in the embodiment of the message-based view loading apparatus, the included units and modules are merely divided according to functional logic, but are not limited to the above division as long as corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
EXAMPLE III
Referring to fig. 3, the present embodiment provides an apparatus 300 comprising: one or more processors 320; the storage device 310 is configured to store one or more programs, and when the one or more programs are executed by the one or more processors 320, the one or more processors 320 implement the message-based view loading method provided in the embodiment of the present invention, including:
when a function starting message for triggering view loading is received, determining a target view identifier of a target view according to the function starting message;
using the target view identification as an input parameter, calling an object acquisition function through an object set to obtain a target view protocol object corresponding to the target view identification, wherein the object set is used for storing each view identification and a view protocol object corresponding to each view identification, and the view protocol object is generated by an initial view class based on a predefined view loading protocol;
and calling a view loading protocol function through the target view protocol object to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol.
Of course, those skilled in the art will understand that the processor 320 may also implement the technical solution of the message-based view loading method provided in any embodiment of the present invention.
The device 300 shown in fig. 3 is only an example and should not bring any limitation to the function and scope of use of the embodiments of the present invention. As shown in fig. 3, the apparatus 300 includes a processor 320, a storage device 310, an input device 330, and an output device 340; the number of the processors 320 in the device may be one or more, and one processor 320 is taken as an example in fig. 3; the processor 320, the storage device 310, the input device 330, and the output device 340 of the apparatus may be connected by a bus or other means, such as by a bus 350 in fig. 3.
The storage device 310, which is a computer-readable storage medium, may be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the message-based view loading method in the embodiment of the present invention (for example, a target view identification determining module, a target view protocol object obtaining module, and a target view loading module in the message-based view loading device).
The storage device 310 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to the use of the terminal, and the like. Further, the storage device 310 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, storage 310 may further include memory located remotely from processor 320, which may be connected to devices over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 330 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function controls of the apparatus. The output device 340 may include a display device such as a display screen.
Example four
The present embodiments provide a storage medium containing computer-executable instructions which, when executed by a computer processor, are operable to perform a message-based view loading method, the method comprising:
when a function starting message for triggering view loading is received, determining a target view identifier of a target view according to the function starting message;
using the target view identification as an input parameter, calling an object acquisition function through an object set to obtain a target view protocol object corresponding to the target view identification, wherein the object set is used for storing each view identification and a view protocol object corresponding to each view identification, and the view protocol object is generated by an initial view class based on a predefined view loading protocol;
and calling a view loading protocol function through the target view protocol object to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol.
Of course, the storage medium provided by the embodiment of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the above method operations, and may also perform related operations in the message-based view loading method provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solution of the present invention or a part contributing to the prior art may be embodied in the form of a software product, where the computer software product may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk, or an optical disk of a computer, and includes several instructions to enable a device (which may be a mobile phone, a palmtop computer, or a smart television, etc.) equipped with an Android system to execute the message-based view loading method provided in each embodiment of the present invention.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims (10)
1. A message-based view loading method, comprising:
when a function starting message for triggering view loading is received, determining a target view identifier of a target view according to the function starting message;
using the target view identifier as an input parameter, calling an object acquisition function through an object set to obtain a target view protocol object corresponding to the target view identifier, wherein the object set is used for storing each view identifier and a view protocol object corresponding to each view identifier, and the view protocol object is generated by an initial view class based on a predefined view loading protocol;
and calling a view loading protocol function through the target view protocol object to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol.
2. The method according to claim 1, before taking the target view identifier as an input parameter and calling an object obtaining function through an object set to obtain a target view protocol object corresponding to the target view identifier, further comprising:
after any view protocol object is generated, the view identification of the view protocol object and the view protocol object are used as input parameters, an object registration function is called through a message distribution object, and the view identification of the view protocol object and the view protocol object are stored in the object set.
3. The method of claim 2, wherein generating a view protocol object comprises:
the initial view class inherits the view loading protocol through a protocol inheriting keyword and overwrites a protocol function in the view loading protocol to obtain a protocol view class and the view loading protocol function in the protocol view class;
and generating the view protocol object according to the protocol view class, wherein the view protocol object is a view object of a view loading protocol type.
4. The method according to any of claims 1-3, wherein the set of objects has a private rights modifier, the set of objects is a set of predefined key-value pair types, and the type of the key of the set of objects is a view loading protocol type.
5. The method of claim 1, wherein the view loading protocol function implements the function of loading the target view by:
taking a system layout service keyword as an input parameter, calling a system object acquisition function through a context object, and acquiring a system loading object;
and taking the layout file identifier corresponding to the target view as an input parameter, calling a view layout function through the system loading object, loading the layout file of the target view, and generating a loading view object of the view type.
6. The method of claim 5, after generating the load view object of view type, further comprising:
and respectively taking the sub-view identification corresponding to each sub-view in the target view as an input parameter, calling a sub-view search function through the loading view object, and obtaining each sub-view object and loading information corresponding to each sub-view object so as to fill the target view.
7. A message-based view loading apparatus, comprising:
the target view identification determining module is used for determining the target view identification of the target view according to the function starting message when the function starting message triggering view loading is received;
a target view protocol object acquisition module, configured to call an object acquisition function through an object set by using the target view identifier as an input parameter, to obtain a target view protocol object corresponding to the target view identifier, where the object set is used to store each view identifier and a view protocol object corresponding to each view identifier, and the view protocol object is generated based on a predefined view loading protocol for an initial view class;
and the target view loading module is used for calling a view loading protocol function through the target view protocol object so as to load the target view, wherein the view loading protocol function is a protocol function contained in the view loading protocol.
8. The apparatus according to claim 7, wherein the target view loading module includes a function execution sub-module, configured to implement the function of loading the target view by:
taking a system layout service keyword as an input parameter, calling a system object acquisition function through a context object, and acquiring a system loading object;
and taking the layout file identifier corresponding to the target view as an input parameter, calling a view layout function through the system loading object, loading the layout file of the target view, and generating a loading view object of the view type.
9. A computer device, the device comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the message-based view loading method of any of claims 1-6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the message-based view loading method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910304351.4A CN110032406B (en) | 2019-04-16 | 2019-04-16 | Message-based view loading method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910304351.4A CN110032406B (en) | 2019-04-16 | 2019-04-16 | Message-based view loading method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110032406A CN110032406A (en) | 2019-07-19 |
CN110032406B true CN110032406B (en) | 2022-07-05 |
Family
ID=67238604
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910304351.4A Active CN110032406B (en) | 2019-04-16 | 2019-04-16 | Message-based view loading method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110032406B (en) |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106598588A (en) * | 2016-12-09 | 2017-04-26 | 武汉斗鱼网络科技有限公司 | Method and device for loading page element |
CN107491298A (en) * | 2017-07-07 | 2017-12-19 | 武汉斗鱼网络科技有限公司 | A kind of button object automatic scanning method and system |
CN108196929A (en) * | 2018-01-09 | 2018-06-22 | 武汉斗鱼网络科技有限公司 | A kind of intelligence loading system, method, storage medium and equipment |
-
2019
- 2019-04-16 CN CN201910304351.4A patent/CN110032406B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106598588A (en) * | 2016-12-09 | 2017-04-26 | 武汉斗鱼网络科技有限公司 | Method and device for loading page element |
CN107491298A (en) * | 2017-07-07 | 2017-12-19 | 武汉斗鱼网络科技有限公司 | A kind of button object automatic scanning method and system |
CN108196929A (en) * | 2018-01-09 | 2018-06-22 | 武汉斗鱼网络科技有限公司 | A kind of intelligence loading system, method, storage medium and equipment |
Non-Patent Citations (1)
Title |
---|
View的inflate详解;csdn;《https://blog.csdn.net/boyeleven/article/details/82776485》;20180921;全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN110032406A (en) | 2019-07-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111343181B (en) | Message processing method and system, data pool and computer readable storage medium | |
CN110990008B (en) | Page updating method and device, storage medium and electronic equipment | |
CN109343983B (en) | Information interaction method, device, equipment and storage medium between function modules | |
CN110750315B (en) | Class loading method, device, equipment and storage medium in Android system | |
CN109144633B (en) | Data sharing method, device and equipment of active window and storage medium | |
CN111090823A (en) | Integration platform of page application and application access method, device and equipment | |
CN110324722B (en) | Method, device, equipment and storage medium for acquiring data in live broadcast room | |
CN109388388B (en) | Information interaction method, device, equipment and storage medium between function modules | |
CN109343970B (en) | Application program-based operation method and device, electronic equipment and computer medium | |
CN112114871B (en) | Code sharing method, device, server, terminal and medium | |
CN114327710A (en) | Function management method, management device, terminal equipment and readable storage medium | |
CN109089163B (en) | Bullet screen message distribution method, device, equipment and storage medium | |
CN114222003A (en) | Service calling method, system, device, equipment and storage medium | |
CN117931374A (en) | Application processing method, device, equipment and storage medium based on container isolation | |
CN110032406B (en) | Message-based view loading method, device, equipment and storage medium | |
CN113127775B (en) | Page loading method, device, equipment and storage medium | |
CN109144520B (en) | Information interaction method, device, equipment and storage medium among different objects in Android | |
CN110045997B (en) | Object initialization method, device, equipment and storage medium of basic function module | |
CN109815202B (en) | Log editing method and related device | |
CN109947488B (en) | Object initialization method, device, equipment and storage medium of universal function module | |
CN108810645B (en) | Bullet screen message distribution method, device, equipment and storage medium | |
CN108804088B (en) | Protocol processing method and device | |
CN111767104B (en) | Language type switching method and device, computer equipment and storage medium | |
CN109062647B (en) | Data sharing method, device and equipment of active window and storage medium | |
CN112131263B (en) | Software package acquisition method, system, device, electronic equipment and 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 |