Data processing method, device, storage medium and electronic device
By defining abstract methods to obtain and bind cohesive data warehouse protocol objects and binder objects, the problems of logical errors and rendering exceptions in page rendering are solved, the correct display and positioning of page data is achieved, and the development efficiency is improved.
Patent Information
- Application Number
- CN202110866128.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-29
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2041-07-29
AI Technical Summary
In the prior art, there are logical errors and rendering exceptions during the page rendering process, resulting in low development efficiency and high error rate.
By defining abstract methods, obtain cohesive data warehouse protocol objects and binder objects, configure and bind page data, create views and parse binder objects to bind data warehouse protocol objects, and realize preprocessing and display of page data. Avoid rendering errors.
Reduces rendering complexity and error rate, improves development efficiency, and ensures correct display and positioning of page data.
Smart Images

Figure CN113569182B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular to a data processing method, device, storage medium, and electronic device. Background Art
[0002] With the continuous development of computer technology, electronic devices such as mobile phones and computers are widely used. During the use of the above electronic devices, they interact with users through UI interfaces. Specifically, the acquired data or data to be displayed is displayed through page rendering.
[0003] However, in the process of implementing the present invention, the inventors found that there are at least the following technical problems in the prior art: currently in the process of page rendering, there are problems such as low development efficiency and high error rate caused by logical errors and rendering anomalies. Summary of the invention
[0004] The embodiments of the present invention provide a data processing method, device, storage medium and electronic device to improve development efficiency.
[0005] In a first aspect, an embodiment of the present invention provides a method for acquiring page data, comprising:
[0006] Acquire page data and an identifier corresponding to the page data based on a preset first protocol method;
[0007] A first abstract method is defined in a preset abstract class, a cohesive data warehouse protocol object is obtained based on the first abstract method, and the obtained page data is configured into the cohesive data warehouse protocol object;
[0008] A second abstract method is defined in the preset abstract class, a cohesive binder object is obtained based on the second abstract method, and the cohesive data warehouse protocol object is bound to an identifier corresponding to the page data based on the cohesive binder object;
[0009] Creating a view, wherein the identifier of the view is the identifier corresponding to the page data;
[0010] The cohesive binder object corresponding to the identifier is parsed, and the view is bound to the parsed cohesive data warehouse protocol object based on a second protocol method to obtain page data for display.
[0011] Optionally, the first protocol method includes a first cohesive protocol and a second cohesive protocol, wherein the first cohesive protocol includes a first protocol function, and an input parameter of the first protocol function is a variable variable of Any type;
[0012] The second cohesive protocol includes a second protocol function, and the input parameters of the second protocol function include Int type data loadType and collection type rendering data.
[0013] Optionally, the second protocol method includes a binding view function and a binding data warehouse protocol object function.
[0014] Optionally, the creating a view includes:
[0015] Call the view creation method to create a view based on the preset page layout, logo and view container as input parameters.
[0016] Optionally, on this basis, before parsing the cohesive binder object corresponding to the identifier, the method further includes:
[0017] Calling a binder determination method to determine whether the cohesive binder object is empty;
[0018] If not, continue to execute the step of parsing the cohesive binder object corresponding to the identifier.
[0019] Optionally, on this basis, after parsing the cohesive binder object corresponding to the identifier, the method further includes:
[0020] Calling a data object determination method to determine whether the cohesive data warehouse protocol object is empty;
[0021] If not, continue to execute the step of binding the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain the page data for display.
[0022] Optionally, on this basis, the method further includes:
[0023] Creating a first service class for implementing the first protocol method;
[0024] A second service class is created to implement the second protocol method.
[0025] In a second aspect, an embodiment of the present invention further provides a device for acquiring page data, including:
[0026] A data acquisition module, used to acquire page data and an identifier corresponding to the page data based on a preset first protocol method;
[0027] A data configuration module, used to define a first abstract method in a preset abstract class, obtain a cohesive data warehouse protocol object based on the first abstract method, and configure the obtained page data into the cohesive data warehouse protocol object;
[0028] An object binding module, used for defining a second abstract method in the preset abstract class, obtaining a cohesive binder object based on the second abstract method, and binding the cohesive data warehouse protocol object with an identifier corresponding to the page data based on the cohesive binder object;
[0029] A view creation module, used to create a view, wherein the identifier of the view is the identifier corresponding to the page data;
[0030] The data binding module is used to parse the cohesive binder object corresponding to the identifier, and bind the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain page data for display.
[0031] In a third aspect, an embodiment of the present invention further provides an electronic device, which may include:
[0032] one or more processors;
[0033] A memory for storing one or more programs;
[0034] When one or more programs are executed by one or more processors, the one or more processors implement the page data acquisition method provided by any embodiment of the present invention.
[0035] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the page data acquisition method provided by any embodiment of the present invention is implemented.
[0036] The technical solution provided by the embodiment of the present invention obtains page data and an identifier corresponding to the page data based on a preset first protocol method, defines a first abstract method in a preset abstract class, obtains a cohesive data warehouse protocol object based on the first abstract method, configures the obtained page data into the cohesive data warehouse protocol object, and defines a second abstract method in the preset abstract class, obtains a cohesive binder object based on the second abstract method, binds the cohesive data warehouse protocol object with the identifier corresponding to the page data based on the cohesive binder object, thereby obtaining the page data content and configuring the page data content in the cohesive data warehouse protocol object, binds the cohesive data warehouse protocol object with the corresponding identifier through the cohesive binder object, and pre-processes the page data to facilitate rapid positioning of the page data through the identifier, thereby avoiding rendering errors caused by page data loss or positioning errors. Create a view, parse the cohesive binder object corresponding to the identifier, bind the view to the parsed cohesive data warehouse protocol object based on the second protocol method, obtain the page data for display, bind the view corresponding to the same identifier to the cohesive data warehouse protocol object, add the acquired page data to the corresponding view, obtain the page for rendering, display the page data, and achieve the acquisition and display of the page data. By binding the view and the cohesive data warehouse protocol object, the page data can be displayed at any time, and the bound cohesive data warehouse protocol object can be called, without logical errors or rendering anomalies, reducing the rendering complexity, the difficulty of controlling page rendering, and the error rate, and improving development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a flow chart of a method for acquiring page data provided in the first embodiment of the present invention;
[0038] Figure 2 It is a flow chart of a method for acquiring page data provided in the second embodiment of the present invention;
[0039] Figure 3 It is a flowchart of a method for obtaining page data provided by Embodiment 3 of the present invention;
[0040] Figure 4 is a structural diagram of a device for acquiring page data provided by a fourth embodiment of the present invention;
[0041] Figure 5 It is a structural schematic diagram of an electronic device provided in Embodiment 5 of the present invention. DETAILED DESCRIPTION
[0042] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0043] Embodiment 1
[0044] Figure 1 This is a flow chart of a method for acquiring page data provided in the first embodiment of the present invention. This embodiment is applicable to the case where the page data content is acquired and the page data is formed into page data for display. The method can be executed by the page data acquisition device provided in the embodiment of the present invention. The page data acquisition device can be implemented by software and / or hardware. The page data acquisition device can be configured on an electronic device configured with an Android system, such as a mobile phone, a tablet computer, a computer, etc., and specifically includes the following steps:
[0045] S110: Acquire page data and an identifier corresponding to the page data based on a preset first protocol method.
[0046] S120. Define a first abstract method in a preset abstract class, obtain a cohesive data warehouse protocol object based on the first abstract method, and configure the obtained page data into the cohesive data warehouse protocol object.
[0047] S130. Define a second abstract method in the preset abstract class, obtain a cohesive binder object based on the second abstract method, and bind the cohesive data warehouse protocol object to an identifier corresponding to the page data based on the cohesive binder object.
[0048] S140: Create a view, wherein the identifier of the view is an identifier corresponding to the page data.
[0049] S150, parsing the cohesive binder object corresponding to the identifier, and binding the view with the parsed cohesive data warehouse protocol object based on a second protocol method to obtain page data for display.
[0050] In this embodiment, the page data obtained by the first protocol method is data content, for example, it may include but is not limited to text content, graphic content, and image content. The above data content may be content displayed on the same page, corresponding to an identifier, which may be a page ID, or other identifiers that uniquely mark the above obtained page data, such as a string, etc., which are not limited to this. The identifier corresponding to the page content may be generated based on one or more of the acquisition timestamp of the above page data, the source of the page data (such as the original storage address), etc., for example, it may be obtained by processing one or more of the above acquisition timestamp, the source of the page data, etc. in a hashing manner.
[0051] The first protocol method is preset and stored in the electronic device. When a page data acquisition instruction is detected, the first protocol method is called to acquire the page data based on the first protocol method. Exemplarily, the page data acquisition instruction may be generated by a page refresh operation, a click operation on any page, or a login operation on any application or web page, or may be generated by detecting a voice-triggered page refresh or entering a page, etc., without limitation.
[0052] Optionally, the first protocol method includes a first cohesive protocol and a second cohesive protocol, wherein the cohesive protocol is a design that includes a protocol within a protocol, and by setting the cohesive protocol, at least two protocols are set to form a cohesive protocol, thereby improving the situation where multiple protocols are set separately, and correspondingly simplifying the association relationship between the protocols, thereby facilitating synchronous calling of multiple protocols.
[0053] In this embodiment, the first cohesive protocol includes a first protocol function, and the input parameter of the first protocol function is a variable variable of the Any type. Specifically, the setting method of the first cohesive protocol may be:
[0054]
[0055] The protocol name of the first protocol method is VMZContract, and the first cohesive protocol included in the first protocol method is the IRepository protocol, which is mainly used to build a standard for data access. The first cohesive protocol includes a first protocol function requestData, which has an input parameter vararg params:Any. The variable type of the input parameter is a mutable variable, and the data type is Any type. The advantage of setting the above-mentioned Any type of mutable variable is that it can accept any number and type of variables, that is, it can be used to obtain any type and any number of page data, and the obtained page data is packaged. The data type of the returned page data is a custom data package type, namely Observable. <MutableList<vmzitemwrapper>>? Type.
[0056] Optionally, the second cohesive protocol includes a second protocol function, and the input parameter of the second protocol function includes Int type data loadType and collection type rendering data. Specifically, the second cohesive protocol can be set in the following manner:
[0057]
[0058] The protocol name of the second cohesive protocol is IView, which is used to render page data. The second cohesive protocol includes a second protocol function onReceiveData, the input parameter of the second protocol function is Int type data loadType, and MutableList <vmzitemwrapper>The data of the collection type dataList, the MutableList <vmzitemwrapper>The data of the collection type dataList may be page data acquired by the first cohesion protocol, and the page data is used as rendering data. In some embodiments, the identifier of the page data may be used as the data of the Int type loadType.
[0059] On the basis of the above embodiment, the first protocol method is called, specifically, it can be: define an abstract class for overwriting the above first protocol method. Exemplarily, the abstract class can be VMZBaseFragment, which is integrated into the system class Fragment. The system class Fragment has the ability of UI display. Correspondingly, the abstract class VMZBaseFragment inherits from the system class Fragment and also has the ability of UI display. Among them, Fragment is a component provided by Android to adapt applications to large screens of different devices and support more dynamic and flexible UI design. Fragment objects generally cannot exist independently in applications. They must be embedded in activities, and the life cycle of Fragments is directly affected by the activities in which they are located. Fragment is the base class, and any created Fragment needs to inherit this class. The FragmentManager class is used to manage and maintain Fragments. The FragmentManager class is an abstract class, and the specific implementation class is FragmentManagerImpl. The FragmentTransaction class is used to add and delete Fragments, and operations such as need to be performed in a transactional manner. The FragmentTransaction class is an abstract class, and the specific implementation class is BackStackRecord. The extended subclasses of the system class Fragment include the dialog box DialogFragment, the list ListFragment, the option setting PreferenceFragment, and the WebView interface WebViewFragment.
[0060] In order to realize UI display of page data, it is necessary to obtain page data through the first cohesive protocol VMZContract in the first protocol method, and realize UI data reception through the second cohesive protocol VMZContract.IView. Specifically, the acquisition of page data is realized through the first protocol method VMZContract.IView.
[0061] For example, the definition of an abstract class may be:
[0062] abstract class VMZBaseFragment:Fragment(),VMZContract.IView{
[0063] }
[0064] In the above abstract type, the protocol function in the second cohesive protocol is copied, for example, it can be:
[0065] override fun onReceiveData(loadType:Int,dataList:MutableList <vmzitemwrapper>)
[0066] After obtaining the page data, in order to ensure the integrity of the page data and avoid information loss, a cohesive data warehouse protocol object is created, and the obtained page data is configured into the cohesive data warehouse protocol object. By calling the cohesive data warehouse protocol object, the above page data can be obtained. Specifically, by defining a first abstract method in an abstract class, the first abstract method is a method for creating a cohesive data warehouse protocol object, and calling the first abstract method returns a cohesive data warehouse protocol object. Exemplarily, the first abstract method can be:
[0067] abstract fun repoInstance():VMZContract.IRepository?
[0068] Since the page data is set with an identifier, the cohesive data warehouse protocol object configured with the page data corresponds to the above identifier. In this embodiment, by creating a binder object, the above cohesive data warehouse protocol object and the corresponding identifier are bound, which is convenient for quickly locating the cohesive data warehouse protocol object through the identifier, that is, quickly locating the page data to avoid logical errors or abnormal rendering of the page data. It should be noted that the cohesive data warehouse protocol object and the corresponding identifier are bound based on the binder object, and accordingly, there is a corresponding relationship between the binder object and the identifier.
[0069] Optionally, by defining a second abstract method in the abstract class, the second abstract method is a method for creating a binder object, and calling the second abstract method returns a cohesive binder object. Exemplarily, the second abstract method may be:
[0070] abstract fun presenterInstance():VMZContract.IPresenter?
[0071] Optionally, the cohesive binder object may be a nullable object. The advantage of designing the cohesive binder object as a nullable object is to avoid the occurrence of a null pointer exception.
[0072] In order to display the above-obtained page data, a view needs to be created, and the above-mentioned page data is displayed through the view. Accordingly, a view is created, and the identifier of the view is set to be the same as the identifier of the page data displayed above. By setting the same identifier, an association relationship between the view and the corresponding page data is established, so that the associated view and page data can be quickly determined through the identifier. Specifically, it can be calling a preset view creation method to return a view. Further, it can also be obtaining a view creation parameter, using the view creation parameter as an input parameter of the view creation method, and obtaining a view that meets the view creation parameter. Among them, the view creation parameter can be input by the user through an input device such as a keyboard, a mouse, a touch screen, etc., or it can be pre-stored and obtained by calling. The view creation parameters corresponding to different page data can be different. Optionally, the corresponding view creation parameter is called according to the source or data type of the page data, or it can also be called according to the user identifier. Pre-set view creation parameters, or it can also be determined according to user information. Recommended view creation parameters, and call the view creation parameters, are not limited to this. Correspondingly, the view creation parameters may include but are not limited to parameters such as the style and layout of the view. A variety of view creation parameters may be pre-stored in the electronic device for quick calling.
[0073] Bind the above-created view and the corresponding bound data warehouse protocol object to obtain page data that can be rendered. Determine the cohesive data warehouse protocol object through the identifier corresponding to the view, parse and process the bound cohesive data warehouse protocol object to obtain the page data content. Call the pre-set second protocol method, and use the second protocol method to bind the page data to the view to obtain the page data for display. By binding the page data to the view, the bound view and page data are rendered when the page is displayed, and there is no need to perform other control operations on the page data during the rendering process, which simplifies the page rendering process and reduces the rendering error rate.
[0074] Optionally, the second protocol method includes a binding view function and a binding data warehouse protocol object function. The second protocol method may be a cohesive protocol, and the second protocol method includes a protocol function, which simplifies the setting of the protocol method. In some embodiments, the second protocol method may be a tie protocol, and exemplary, the second protocol method may be:
[0075]
[0076]
[0077] Among them, the protocol method of the second protocol method is IPresenter, and the second protocol method includes a view binding function bindView and a data warehouse protocol object binding function bindRepository. The view binding function bindView is used to bind the created view. Specifically, for any identifier, the view corresponding to the identifier is bound by the view binding function bindView. The data warehouse protocol object binding function bindRepository is used to bind the data warehouse protocol object, and accordingly, the data warehouse protocol object corresponding to the above identifier is bound. Binding of the view to the page data of the data warehouse protocol object is realized.
[0078] The technical solution provided in this embodiment obtains page data and an identifier corresponding to the page data based on a preset first protocol method, defines a first abstract method in a preset abstract class, obtains a cohesive data warehouse protocol object based on the first abstract method, configures the obtained page data into the cohesive data warehouse protocol object, and defines a second abstract method in the preset abstract class, obtains a cohesive binder object based on the second abstract method, binds the cohesive data warehouse protocol object with the identifier corresponding to the page data based on the cohesive binder object, thereby obtaining the page data content and configuring the page data content in the cohesive data warehouse protocol object, binds the cohesive data warehouse protocol object with the corresponding identifier through the cohesive binder object, and pre-processes the page data to facilitate rapid positioning of the page data through the identifier, thereby avoiding rendering errors caused by page data loss or positioning errors. Create a view, parse the cohesive binder object corresponding to the identifier, bind the view to the parsed cohesive data warehouse protocol object based on the second protocol method, obtain the page data for display, bind the view corresponding to the same identifier to the cohesive data warehouse protocol object, add the acquired page data to the corresponding view, obtain the page for rendering, display the page data, and achieve the acquisition and display of the page data. At the same time, through the binding of the view and the cohesive data warehouse protocol object, the page data can be displayed at any time, and the bound cohesive data warehouse protocol object can be called, without logical errors or rendering anomalies, reducing the rendering complexity, the difficulty of controlling page rendering, and the error rate, and improving development efficiency.
[0079] Based on the above embodiments, since the above processes are all implemented through abstract classes and abstract functions, there is no specific implementation method for abstract classes and abstract methods. In response to the above problems, the method also includes: creating a first business class for implementing the first protocol method; creating a second business class for implementing the second protocol method.
[0080] Exemplarily, taking the first business class as an example, the first business class may be PresenterImpl, which is used to implement the first protocol method VMZContract.Irepository, and specifically may be:
[0081]
[0082] Correspondingly, the second business class is used to implement the second protocol method VMZContract.Ipresenter, which will not be described in detail here.
[0083] In this embodiment, by setting the first business class and the second business class, the first protocol method and the second protocol method are implemented respectively, which ensures the normal operation of the first protocol method and the second protocol method, and correspondingly ensures the acquisition and rendering of page data.
[0084] Embodiment 2
[0085] Figure 2 It is a flow chart of a page data acquisition method provided in an embodiment of the present invention, which is refined on the basis of the above embodiment. Optionally, creating a view includes: calling a view creation method, creating a view based on a preset page layout, identifier and view container as input parameters.
[0086] Specifically, the method comprises the following steps:
[0087] S210: Acquire page data and an identifier corresponding to the page data based on a preset first protocol method.
[0088] S220. Define a first abstract method in a preset abstract class, obtain a cohesive data warehouse protocol object based on the first abstract method, and configure the obtained page data into the cohesive data warehouse protocol object.
[0089] S230. Define a second abstract method in the preset abstract class, obtain a cohesive binder object based on the second abstract method, and bind the cohesive data warehouse protocol object to an identifier corresponding to the page data based on the cohesive binder object.
[0090] S240: Call a view creation method, create a view based on a preset page layout and a view container as input parameters, and set the identifier of the view to the identifier corresponding to the page data.
[0091] S250, parsing the cohesive binder object corresponding to the identifier, and binding the view with the parsed cohesive data warehouse protocol object based on a second protocol method to obtain page data for display.
[0092] In this embodiment, the page layout and view container required for creating a view are obtained, wherein the page layout may include but is not limited to the view margins, and the setting position of each view container, such as the top margin, bottom margin, left margin, and right margin, etc. The view container includes the type and quantity of required containers, wherein the view container may include but is not limited to virtual keys, input boxes, drop-down menus, etc.
[0093] Call the preset view creation method, create a view with the page layout and view container as input parameters, return a view, and set the view identifier, which is the same as the identifier of the page data obtained above.
[0094] Exemplarily, the view creation method may be:
[0095] override fun onCreateView(inflater:LayoutInflater,container:ViewGroup?,savedInstanceState:Bundle?):View? {}
[0096] Among them, the view creation method onCreateView, LayoutInflater is the page layout, ViewGroup is the view container, savedInstanceState is used to save the status information of the current activity before the workflow activity is interrupted, and Bundle is used to save the status information. The Bundle passes the saved information to the view creation method onCreateView. By setting the savedInstanceState mechanism, it is ensured that when the view creation process is interrupted, the current status information of the view creation is retained, and the current status information is passed to the view creation method onCreateView, so that the view creation method onCreateView can continue to create the view based on the current status information, thereby improving the efficiency of view creation.
[0097] Correspondingly, after the view is bound to the parsed cohesive data warehouse protocol object based on the second protocol method, the page data is added to the corresponding position of the view to form the page data for display.
[0098] The technical solution provided in this embodiment creates a view that meets the display requirements by obtaining the page layout and view container used to create the view, binds the view to the page data, and renders the page based on the binding relationship to obtain a page for display. There are no logical errors or rendering anomalies, which reduces the rendering complexity, the difficulty of controlling page rendering and the error rate, and improves development efficiency.
[0099] Embodiment 3
[0100] Figure 3 It is a flow chart of a page data acquisition method provided by an embodiment of the present invention, which is refined on the basis of the above embodiment. Optionally, after parsing the cohesive binder object corresponding to the identifier, the method further includes: calling a data object determination method to determine whether the cohesive data warehouse protocol object is empty; if not, continuing to execute the step of binding the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain the page data for display.
[0101] For details, see Figure 3 , the method comprises the following steps:
[0102] S310: Acquire page data and an identifier corresponding to the page data based on a preset first protocol method.
[0103] S320. Define a first abstract method in a preset abstract class, obtain a cohesive data warehouse protocol object based on the first abstract method, and configure the obtained page data into the cohesive data warehouse protocol object.
[0104] S330. Define a second abstract method in the preset abstract class, obtain a cohesive binder object based on the second abstract method, and bind the cohesive data warehouse protocol object to an identifier corresponding to the page data based on the cohesive binder object.
[0105] S340: Create a view, wherein the identifier of the view is the identifier corresponding to the page data.
[0106] S350, calling the binder determination method to determine whether the cohesive binder object is empty, if not, executing step S360, if yes, returning to execute step S310.
[0107] S360: Parse the cohesive binder object corresponding to the identifier, bind the view to the parsed cohesive data warehouse protocol object based on the second protocol method, and obtain page data for display.
[0108] In this embodiment, in order to ensure the normal operation of the binding between the view and the page data, it is necessary to determine that the page data to be bound is not empty. Before parsing the cohesive binder object corresponding to the identifier, the binder determination method is called to determine whether the cohesive binder object is empty. If it is empty, it is determined that there is no page data to be bound, and the page data needs to be reacquired. Specifically, the binder determination method can be: presenterInstance(). If the cohesive binder object is not empty, the cohesive data warehouse protocol object is parsed to obtain the page data.
[0109] Optionally, after parsing the cohesive binder object corresponding to the identifier, the method further includes: calling a data object determination method to determine whether the cohesive data warehouse protocol object is empty; if not, continuing to execute the step of binding the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain the page data for display.
[0110] The data object determination method may be repoInstance(). Accordingly, repoInstance()! ! indicates that the cohesive data warehouse protocol object is non-empty. By determining that the cohesive data warehouse protocol object is non-empty, it is ensured that the bound page data is non-empty.
[0111] Exemplarily, the binding of the data warehouse protocol object is implemented by calling the binding data warehouse protocol object function in the second protocol method, which may be:
[0112] presenterInstance()? .bindRepository(repoInstance()!!)
[0113] Call the binding view function in the second protocol method to bind the view, which can be:
[0114] presenterInstance()? .bindView(this)
[0115] The technical solution provided in this embodiment determines whether there is page data to be bound by performing null judgment on the binder object and the data warehouse protocol object respectively, so as to ensure the binding of the view and the page data, avoid rendering anomalies caused by binding failure when the page data is null, improve the accuracy of page data acquisition, and reduce the rendering error rate.
[0116] Embodiment 4
[0117] Figure 4 4 is a schematic diagram of the structure of a page data acquisition device provided in the fourth embodiment of the present invention, the device includes a data acquisition module 410, a data configuration module 420, an object binding module 430, a view creation module 440 and a data binding module 450, wherein:
[0118] The data acquisition module 410 is used to acquire the page data and the identifier corresponding to the page data based on a preset first protocol method;
[0119] The data configuration module 420 is used to define a first abstract method in a preset abstract class, obtain a cohesive data warehouse protocol object based on the first abstract method, and configure the obtained page data into the cohesive data warehouse protocol object;
[0120] An object binding module 430, configured to define a second abstract method in the preset abstract class, obtain a cohesive binder object based on the second abstract method, and bind the cohesive data warehouse protocol object to an identifier corresponding to the page data based on the cohesive binder object;
[0121] A view creation module 440, configured to create a view, wherein the identifier of the view is an identifier corresponding to the page data;
[0122] The data binding module 450 is used to parse the cohesive binder object corresponding to the identifier, and bind the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain page data for display.
[0123] Based on the above embodiment, optionally, the first protocol method includes a first cohesive protocol and a second cohesive protocol, wherein the first cohesive protocol includes a first protocol function, and an input parameter of the first protocol function is a variable variable of Any type;
[0124] The second cohesive protocol includes a second protocol function, and the input parameters of the second protocol function include Int type data loadType and collection type rendering data.
[0125] Based on the above embodiment, optionally, the second protocol method includes binding view function and binding data warehouse protocol object function.
[0126] Based on the above embodiment, optionally, the view creation module 440 is used to:
[0127] Call the view creation method to create a view based on the preset page layout and view container as input parameters.
[0128] Based on the above embodiment, optionally, the device further includes:
[0129] The cohesive binder object determination module is used to call the binder determination method before parsing the cohesive binder object corresponding to the identifier to determine whether the cohesive binder object is empty; if not, continue to execute the step of parsing the cohesive binder object corresponding to the identifier.
[0130] Based on the above embodiment, optionally, the device further includes:
[0131] The cohesive data warehouse protocol object determination module is used to call the data object determination method after parsing the cohesive binder object corresponding to the identifier to determine whether the cohesive data warehouse protocol object is empty; if not, continue to execute the step of binding the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain the page data for display.
[0132] Based on the above embodiment, optionally, the device further includes:
[0133] A first service class creation module, used to create a first service class for implementing the first protocol method;
[0134] The second service class creation module is used to create a second service class for implementing the second protocol method.
[0135] The page data acquisition device provided in the embodiment of the present invention can execute the page data acquisition method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the page data acquisition method.
[0136] Embodiment 5
[0137] Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 5 of the present invention. Figure 5 A block diagram of an electronic device 12 suitable for use in implementing embodiments of the present invention is shown. Figure 5 The electronic device 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention. The device 12 is typically an electronic device that undertakes the image classification function.
[0138] like Figure 5 As shown, the electronic device 12 is in the form of a general purpose computing device. The components of the electronic device 12 may include, but are not limited to: one or more processors 16, a storage device 28, and a bus 18 connecting various system components (including the storage device 28 and the processor 16).
[0139] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0140] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.
[0141] The storage device 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 5 not shown, usually called a "hard drive"). Although Figure 5 Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a read-only optical disk (Compact Disc-Read Only Memory, CD-ROM), a digital video disk (Digital Video Disc-Read Only Memory, DVD-ROM) or other optical media) may be provided. In these cases, each drive can be connected to the bus 18 through one or more data medium interfaces. The storage device 28 may include at least one program product, which has a set (such as at least one) of program modules, which are configured to perform the functions of various embodiments of the present invention.
[0142] A program 36 having a set (at least one) of program modules 26 may be stored, for example, in a storage device 28, such program modules 26 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination thereof may include an implementation of a gateway environment. The program modules 26 generally perform the functions and / or methods of the embodiments described herein.
[0143] The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, cameras, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the electronic device 12, and / or may communicate with any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. In addition, the electronic device 12 may also communicate with one or more gateways (e.g., a local area network (LAN), a wide area network (WAN), and / or a public gateway, such as the Internet) via a gateway adapter 20. As shown, the gateway adapter 20 communicates with other modules of the electronic device 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Disks, RAID) systems, tape drives, and data backup storage systems.
[0144] The processor 16 executes various functional applications and data processing by running the programs stored in the storage device 28, for example, implementing the page data acquisition method provided in the above embodiment of the present invention:
[0145] Acquire page data and an identifier corresponding to the page data based on a preset first protocol method;
[0146] A first abstract method is defined in a preset abstract class, a cohesive data warehouse protocol object is obtained based on the first abstract method, and the obtained page data is configured into the cohesive data warehouse protocol object;
[0147] A second abstract method is defined in the preset abstract class, a cohesive binder object is obtained based on the second abstract method, and the cohesive data warehouse protocol object is bound to an identifier corresponding to the page data based on the cohesive binder object;
[0148] Creating a view, wherein the identifier of the view is the identifier corresponding to the page data;
[0149] The cohesive binder object corresponding to the identifier is parsed, and the view is bound to the parsed cohesive data warehouse protocol object based on a second protocol method to obtain page data for display.
[0150] Embodiment 6
[0151] Embodiment 6 of the present invention provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for acquiring page data provided in the embodiment of the present invention is implemented.
[0152] Of course, the computer program stored in the computer-readable storage medium provided in the embodiment of the present invention is not limited to the method operation described above, and can also execute the page data acquisition method provided in any embodiment of the present invention:
[0153] Acquire page data and an identifier corresponding to the page data based on a preset first protocol method;
[0154] A first abstract method is defined in a preset abstract class, a cohesive data warehouse protocol object is obtained based on the first abstract method, and the obtained page data is configured into the cohesive data warehouse protocol object;
[0155] A second abstract method is defined in the preset abstract class, a cohesive binder object is obtained based on the second abstract method, and the cohesive data warehouse protocol object is bound to an identifier corresponding to the page data based on the cohesive binder object;
[0156] Creating a view, wherein the identifier of the view is the identifier corresponding to the page data;
[0157] The cohesive binder object corresponding to the identifier is parsed, and the view is bound to the parsed cohesive data warehouse protocol object based on a second protocol method to obtain page data for display.
[0158] The computer storage medium of the embodiment of the present invention can adopt any combination of one or more computer-readable media. The computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it.
[0159] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries a computer-readable source code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0160] Source code embodied on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0161] Computer source code for performing the operations of the present invention may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The source code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of gateway, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0162] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.< / vmzitemwrapper> < / vmzitemwrapper> < / vmzitemwrapper> < / vmzitemwrapper>
Claims
1. A method for acquiring page data, characterized in that: include: Acquire page data and an identifier corresponding to the page data based on a preset first protocol method; A first abstract method is defined in a preset abstract class, a cohesive data warehouse protocol object is obtained based on the first abstract method, and the obtained page data is configured into the cohesive data warehouse protocol object; A second abstract method is defined in the preset abstract class, a cohesive binder object is obtained based on the second abstract method, and the cohesive data warehouse protocol object is bound to an identifier corresponding to the page data based on the cohesive binder object; Creating a view, wherein the identifier of the view is the identifier corresponding to the page data; Parsing the cohesive binder object corresponding to the identifier, binding the view with the parsed cohesive data warehouse protocol object based on the second protocol method, and obtaining page data for display; The first protocol method includes a first cohesive protocol and a second cohesive protocol, wherein the first cohesive protocol includes a first protocol function, and an input parameter of the first protocol function is a variable variable of type Any; The second cohesive protocol includes a second protocol function, and the input parameter of the second protocol function includes Int type data loadType and collection type rendering data; Wherein, the cohesive data warehouse protocol includes the design of a data warehouse protocol, and at least two data warehouse protocols are set to form a cohesive data warehouse protocol; Wherein, the first abstract method is abstract fun repoInstance():VMZContract.IRepository?; Wherein, the second abstract method is abstract fun presenterInstance():VMZContract.IPresenter?; Among them, the protocol name of the first protocol method is VMZContract.
2. The method according to claim 1, characterized in that The second protocol method includes a binding view function and a binding data warehouse protocol object function.
3. The method according to claim 1, characterized in that The step of creating a view includes: Call the view creation method to create a view based on the preset page layout and view container as input parameters.
4. The method according to claim 1, characterized in that: Before parsing the cohesive binder object corresponding to the identifier, the method further includes: Calling a binder determination method to determine whether the cohesive binder object is empty; If not, continue to execute the step of parsing the cohesive binder object corresponding to the identifier.
5. The method according to claim 4, characterized in that After parsing the cohesive binder object corresponding to the identifier, the method further includes: Calling a data object determination method to determine whether the cohesive data warehouse protocol object is empty; If not, continue to execute the step of binding the view with the parsed cohesive data warehouse protocol object based on the second protocol method to obtain the page data for display.
6. The method according to claim 1, characterized in that The method further comprises: Creating a first service class for implementing the first protocol method; A second service class is created to implement the second protocol method.
7. A page data acquisition device, characterized in that: include: A data acquisition module, used to acquire page data and an identifier corresponding to the page data based on a preset first protocol method; A data configuration module, used to define a first abstract method in a preset abstract class, obtain a cohesive data warehouse protocol object based on the first abstract method, and configure the obtained page data into the cohesive data warehouse protocol object; An object binding module, used for defining a second abstract method in the preset abstract class, obtaining a cohesive binder object based on the second abstract method, and binding the cohesive data warehouse protocol object with an identifier corresponding to the page data based on the cohesive binder object; A view creation module, used to create a view, wherein the identifier of the view is the identifier corresponding to the page data; A data binding module, used for parsing the cohesive binder object corresponding to the identifier, and binding the view with the parsed cohesive data warehouse protocol object based on a second protocol method to obtain page data for display; The first protocol method includes a first cohesive protocol and a second cohesive protocol, wherein the first cohesive protocol includes a first protocol function, and the input parameter of the first protocol function is a variable variable of the Any type; the second cohesive protocol includes a second protocol function, and the input parameter of the second protocol function includes data loadType of the Int type and rendering data of the collection type; Wherein, the cohesive data warehouse protocol includes the design of a data warehouse protocol, and at least two data warehouse protocols are set to form a cohesive data warehouse protocol; Wherein, the first abstract method is abstract fun repoInstance():VMZContract.IRepository?; Wherein, the second abstract method is abstract fun presenterInstance():VMZContract.IPresenter?; Among them, the protocol name of the first protocol method is VMZContract.
8. An electronic device, characterized in that: include: one or more processors; A memory 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 implement the page data acquisition method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the page data acquisition method according to any one of claims 1 to 6 is implemented.
