CN114637504A - Data adaptation method, device, equipment and storage medium - Google Patents

Data adaptation method, device, equipment and storage medium Download PDF

Info

Publication number
CN114637504A
CN114637504A CN202011486696.5A CN202011486696A CN114637504A CN 114637504 A CN114637504 A CN 114637504A CN 202011486696 A CN202011486696 A CN 202011486696A CN 114637504 A CN114637504 A CN 114637504A
Authority
CN
China
Prior art keywords
data
view
view container
class
type
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.)
Pending
Application number
CN202011486696.5A
Other languages
Chinese (zh)
Inventor
张磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Douyu Network Technology Co Ltd
Original Assignee
Wuhan Douyu Network Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Wuhan Douyu Network Technology Co Ltd filed Critical Wuhan Douyu Network Technology Co Ltd
Priority to CN202011486696.5A priority Critical patent/CN114637504A/en
Publication of CN114637504A publication Critical patent/CN114637504A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Abstract

The embodiment of the invention discloses a data adaptation method, a data adaptation device, data adaptation equipment and a storage medium, wherein the method comprises the following steps: acquiring a data package collection object; initializing a preset adapter class according to the data package set object, and creating a preset adapter object; constructing a current view container corresponding to the current view type to be displayed currently based on a view container construction class corresponding to each data type by calling a view container construction function in a preset adapter object; and by calling a view container binding function in the preset adapter object, constructing a class based on the view container corresponding to each data type, and binding target view data in the data package set object to the current view container. By the technical scheme of the embodiment of the invention, one or more types of view data can be adapted, so that the development efficiency is improved, and the application range of a scene is also improved.

Description

Data adaptation method, device, equipment and storage medium
Technical Field
The present invention relates to computer technologies, and in particular, to a data adaptation method, apparatus, device, and storage medium.
Background
With the rapid development of computer technology, more and more application software is developed to meet the increasing demands of users.
At present, in application software developed based on an Android system, a data adapter serves as a bridge between data and a view, and can adapt to data acquired from a data source, so that the data can be conveniently displayed on the view. Generally, the existing data adapter can only adapt to one type of view data, and cannot adapt to multiple types of view data, so that the development efficiency is reduced, and the application range of a scene is also reduced.
Disclosure of Invention
The embodiment of the invention provides a data adaptation method, a data adaptation device, data adaptation equipment and a storage medium, which are used for realizing the adaptation of one or more types of view data, so that the development efficiency is improved, and the application range of a scene is also improved.
In a first aspect, an embodiment of the present invention provides a data adaptation method, including:
acquiring a data package collection object, wherein the data package collection object is composed of one or more data package objects, and each data package object is used for storing view data of one data type;
initializing a preset adapter class according to the data package set object, and creating a preset adapter object;
constructing a current view container corresponding to the current view type to be displayed currently based on a view container construction class corresponding to each data type by calling a view container construction function in the preset adapter object;
and by calling a view container binding function in the preset adapter object, constructing a class based on the view container corresponding to each data type, and binding target view data in the data package set object to the current view container.
In a second aspect, an embodiment of the present invention further provides a data adaptation apparatus, including:
the data package collection object acquisition module is used for acquiring a data package collection object, wherein the data package collection object consists of one or more data package objects, and each data package object is used for storing view data of one data type;
the preset adapter object creating module is used for initializing a preset adapter class according to the data package set object and creating a preset adapter object;
a current view container construction module, configured to construct a current view container corresponding to a current view type to be currently displayed, based on a view container construction class corresponding to each data type, by calling a view container construction function in the preset adapter object;
and the target view data binding module is used for binding the target view data in the data package set object to the current view container by calling a view container binding function in the preset adapter object and constructing a class based on the view container corresponding to each data type.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a memory for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a data adaptation method as provided by any of the embodiments of the invention.
In a fourth aspect, the embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the data adaptation method provided in any embodiment of the present invention.
The embodiment of the invention has the following advantages or beneficial effects:
the preset adapter object is created by acquiring a view data package set object for storing one or more data types and initializing a preset adapter class according to the data package set object. By calling a view container construction function in a preset adapter object, a current view container corresponding to a current view type to be displayed at present can be constructed based on a view container construction class corresponding to each data type, and by calling a view container binding function in the preset adapter object, target view data in a data package set object can be bound to the current view container based on the view container construction class corresponding to each data type, so that a view container of one or more view types can be constructed by using the preset adapter object, and view data of one or more data types can be bound, thereby realizing adaptation of one or more types of view data, improving development efficiency, and also improving the application range of scenes.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief description will be given below of the drawings required for the embodiments or the technical solutions in the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a data adaptation method according to an embodiment of the present invention;
fig. 2 is a flowchart of a data adaptation method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a data adaptation apparatus according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to a fourth 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
Fig. 1 is a flowchart of a data adaptation method according to an embodiment of the present invention, which is applicable to a case of adapting view data to be displayed, which is acquired from a data source. The method can be executed by a data adaptation device, the device can be realized by software and/or hardware, and the device is integrated in an electronic device with an Android system, such as a smart phone, a tablet computer, a smart television or a notebook computer and other intelligent terminals. As shown in fig. 1, the method specifically includes the following steps:
s110, acquiring a data package set object, wherein the data package set object is composed of one or more data package objects, and each data package object is used for storing view data of one data type.
The view data may refer to data to be displayed by a view control in a page. The data type of the view data may be, but is not limited to, integer type, character string type, boolean type, enumeration type, and the like. View data for one or more different data types may be obtained from a data source.
Specifically, in this embodiment, view data of one or more different data types may be obtained from a data source corresponding to a page to be displayed in advance, and the view data of each data type is stored in one data package object, so that one or more data package objects corresponding to the page to be displayed may be obtained, and the data package objects are combined to obtain a data package set object.
Illustratively, S110 may include: initializing a predefined data package class according to view data of each data type to be adapted, and creating a data package object corresponding to each view data, wherein a construction function of the data package class comprises a first input parameter and a second input parameter, the first input parameter is data type information of an integer type, and the second input parameter is view data information of Any Any type; and determining a data package set object according to each data package object.
Wherein the data package class may be predefined for carrying classes of different types of view data. For example, a data package class may be defined as follows:
class VMZItemWrapper(val type:Int,val data:Any){
}
wherein, VMZItemWrapper is the class name of the data package class. The construction function of the data package class comprises a first input parameter type and a second input parameter data, wherein the first input parameter type is data type information of an integer type Int, and the second input parameter data is view data information of Any type Any. By defining the second input parameter data as an type Any, the data package class can be merged into various types of view data so as to realize the carrying of various types of data.
Specifically, when a data package object corresponding to the data package class is created, a constructor of the data package class may be called by using view data of each data type to be adapted as an input parameter, and an initial value is given to a member variable in the data package class, so that the data package object storing each view data is created. The created respective data package objects may be stored in a collection object of a preset variable list type musablelist < VMZItemWrapper >, thereby obtaining data package collection object dataList.
And S120, initializing the preset adapter class according to the data package set object, and creating a preset adapter object.
The preset adapter class may be a predefined general adapter class that can adapt to one or more types of view data. The preset adapter object may be an object for binding data with the view container so as to display the data on the view control accommodated by the view container.
Specifically, by initializing the preset adapter class, a preset adapter object for adapting all types of view data in the data package set object can be created.
Exemplarily, S120 may include: initializing a preset adapter class based on a constructor of the preset adapter class, and creating a preset adapter object; the input parameters of the constructor of the preset adapter class are respectively context object, data package set object and page type information.
For example, the preset adapter class may be defined as follows:
open class VMZBaseAdapter(context:Context,dataList:MutableList<VMZItemWrapper>,pageType:Int):RecyclerView.Adapter<RecyclerView.ViewHolder>(){}
wherein, VMZBaseAdap is the class name of the preset adapter class. The constructor of the preset adapter comprises three input parameters, namely a Context object Context of a Context type, a data package set object dataList of a Mutablel < VMZItemWrapper > variable list type and a page type information pageType of an Int type.
The access type of the preset adapter class VMZBaseAdapter can be defined as an open type, so that inheritance can be performed more conveniently. The preset adapter class vmzbase adapter may inherit a view recycle adapter recycleview < recycleview.viewholder > in the system, and may rewrite a view container construction function onCreateViewHolder and a view container binding function onBindViewHolder in the view recycle adapter, so that the created view container construction function onCreateViewHolder in the preset adapter object may implement a construction logic function of a view container, and the view container binding function onBindViewHolder may implement a binding logic function of binding data to a corresponding view container.
For example, the view container construction function onCreateViewHolder in the view reclamation adaptor that is duplicated in the preset adaptor class may be:
override fun onCreateViewHolder(parent:ViewGroup,viewType:Int):RecyclerView.ViewHolder{}
the view container binding function onBindViewHolder in the view reclamation adaptor duplicated in the preset adaptor class may be:
override fun onBindViewHolder(holder:RecyclerView.ViewHolder,position:Int){}
specifically, a context object context, a data package set object dataList and a page type information pageType are used as input parameters, a construction function of a preset adapter class is called, an initial value is given to a member variable in the preset adapter class, a construction logic function of a view container is subjected to function realization in a duplicated view container construction function onCreateViewHolder, and a binding logic function of binding data to a corresponding view container is subjected to function realization in a duplicated view container binding function onBindViewHolder, so that a universal preset adapter object for adapting one or more types of view data is created, adaptation of one or more types of view data can be realized on the basis of the preset adapter object subsequently, and the application range of a scene is improved.
S130, constructing a current view container corresponding to the current view type to be displayed currently based on the view container construction class corresponding to each data type by calling a view container construction function in the preset adapter object.
Wherein the view container construction function onCreateViewHolder may be a function for constructing a view container. The View container may be a container for holding View views. The view container construction class may be predefined for constructing classes of view containers corresponding to different data types. Each data type corresponds to a view container construction class, so that the isolation construction of the view container is realized through a plurality of view container construction classes, and the purposes of low coupling and high cohesion are further realized. The current view type to be displayed currently can be the view type viewType which needs to be displayed currently and is returned by the system.
Specifically, the current view type to be currently displayed and the root view group parent are used as input parameters, the replicated view container construction function onCreateViewHolder (parent: Viewgroup, viewType: Int) is called, and based on the view container construction class corresponding to each data type, the current view container corresponding to the current view type to be currently displayed can be constructed in an isolated manner, so that the isolated construction of the current view container is realized.
S140, by calling a view container binding function in the preset adapter object, constructing a class based on the view container corresponding to each data type, and binding the target view data in the data package set object to the current view container.
Wherein the view container binding function onBindViewHolder may be a function for binding view data to a view container. The view container construction class can also be used for binding view data to a corresponding view container, so that isolated binding of the view container can be realized through a plurality of view container construction classes, and the purpose of low coupling and high cohesion is further realized. The target view data may be the view data in the data package collection object that the current view container needs to bind to returned by the system.
Specifically, a rewritten view container binding function onBindView holder (holder: RecycleView. View holder, position: Int) can be called by using the current view container holder and the position information position corresponding to the target view data in the data package collection object to be bound as input parameters, the target view data in the data package collection object can be bound to the current view container in an isolated manner based on the view container construction class corresponding to each data type, so that the isolated binding of the current view container is realized, the view data of each data type can be bound to the constructed corresponding view container, each view data can be displayed on the view control in the corresponding view container, the adaptation of each type of view data is realized, the development efficiency is improved, and the method can also be applied to scenes adapted by one type or multiple types of data, the application range of the scene is improved.
According to the technical scheme of the embodiment, the preset adapter object is created by acquiring the view data package set object used for storing one or more data types and initializing the preset adapter class according to the data package set object. By calling a view container construction function in a preset adapter object, a current view container corresponding to a current view type to be displayed at present can be constructed based on a view container construction class corresponding to each data type, and by calling a view container binding function in the preset adapter object, target view data in a data package set object can be bound to the current view container based on the view container construction class corresponding to each data type, so that one or more view types of view containers can be constructed by using the preset adapter object, and one or more types of view data can be bound, thereby realizing the adaptation of one or more types of view data, improving the development efficiency, and also improving the application range of scenes.
Example two
Fig. 2 is a flowchart of a data adaptation method according to a second embodiment of the present invention, and this embodiment describes in detail a specific implementation process of a view container construction function based on the foregoing embodiments. On the basis, the specific implementation process of the view container binding function is further described in detail. Wherein explanations of the same or corresponding terms as those of the above embodiments are omitted.
Referring to fig. 2, the data adaptation method provided in this embodiment specifically includes the following steps:
s210, acquiring a data package set object, wherein the data package set object is composed of one or more data package objects, and each data package object is used for storing view data of one data type.
S220, initializing the preset adapter class according to the data package set object, and creating a preset adapter object.
S230, obtaining a predefined view container construction class corresponding to each data type, wherein each view container construction class comprises a predefined view container construction function.
Wherein, a corresponding view container construction class can be predefined for each data type, so that the view container construction class is used for isolating and constructing the view container of the corresponding type. For example, a view container construct class corresponding to a certain data type may be defined as: class HolderTogetherRoom { }. The view container constructor may be a predefined function in the view container construction class for constructing a view container. For example, in the holder to getthermom view container constructor class, the view container constructor getViewHolder may be defined as: fun getViewholder (parent: ViewGroup): Viewholder { }. Wherein, the input parameter of the view container constructor is the root view group.
Specifically, inside the duplicated view container construction function onCreateViewHolder (parent: Viewgroup, viewType: Int), view container construction classes corresponding to various predefined data types can be obtained first, so that the view container is isolated and constructed based on the view container construction classes, and the purpose of low coupling and high cohesion is achieved.
S240, matching the current view type to be displayed with the data type corresponding to each view container construction class, and determining a first view container construction class matched with the current view type.
Specifically, the currently to-be-displayed current view type viewType of the input integer type Int may be matched with a data type corresponding to each view container construction class, such as holdertowtherm from.
And S250, calling a view container construction function in the first view container construction class to construct a current view container corresponding to the current view type.
Specifically, if the first view container structure class is holdertowentherm, the current view container corresponding to the current view type may be constructed by calling a view container structure function holdertowentherm in the first view container structure class holdertowentherm. For example, inside the view container constructor in the first view container construction class, based on the specified layout information r.layout.xxxxx, an mroot view object may be obtained by calling val mroot view from (parent. context) info (r.layout. xxxxx, parent, false), and the mroot view object may be packaged into a view holder view container object by calling return view, so as to construct the current view container corresponding to the current view type.
Illustratively, inside the duplicate view container construction function onCreateViewholder (parent: ViewGroup, viewType: Int), the current view container corresponding to the current view type can be constructed as follows:
Figure BDA0002839462480000111
Figure BDA0002839462480000121
wherein, HolderTogetherRoom, AAAA, BBBB, CCCC and DDDD are view container construction classes corresponding to different data types. Inside the view container construction function, the isolated construction of the view container can be dynamically performed through the matching of types.
S260, obtaining a predefined view container construction class corresponding to each data type, wherein each view container construction class further comprises a predefined view container binding function.
The view container binding function can be further defined in the view container construction class corresponding to each data type, and is used for binding view data to the corresponding view container function, so that the purpose of low coupling and high cohesion of data binding is achieved. For example, in the holdertowentheroom view container construction class, the view container binding function may be defined as: the method comprises the steps of constructing a view container binding function, wherein the view container binding function comprises a fun Viewholder (Context: Context, holder: Viewholder, data: Any, position: Int) { }, wherein an input parameter holder of the view container binding function is the constructed current view container, the Context is a Context type Context object, the data is view data to be bound, and the position is integer type target position information.
Specifically, inside the duplicate view container binding function onBindViewHolder (holder: RecycleView. ViewHolder, position: Int), view container structure classes corresponding to various predefined data types can be obtained first, so that data binding of the view container is performed based on the view container structure classes, and the purpose of low coupling and high cohesion is achieved.
S270, matching the current view container with the view container corresponding to each view container construction class, and determining a second view container construction class matched with the current view container.
Specifically, the input current view container holder may be matched with a view container corresponding to each view container configuration class, for example, holdertotgetherfrom.
S280, determining target view data in the data package collection object according to the input target position information of the integer type.
Specifically, the target view data to be bound may be acquired by invoking the dataList [ position ]. data in the dataList of the data package aggregation object according to the input target position information position of the integer type int.
And S290, calling a view container binding function in the second view container construction class, and binding the target view data to the current view container.
Specifically, if the second view container structure class is holdertowerheat, the target view data may be bound to the current view container by calling a view container binding function holdertowerheat in the second view container structure class holdertowerheat. Different bound business operations can be completed inside the view container binding function based on business requirements.
Illustratively, inside the replicated view container binding function onBindViewholder (holder: RecycleView. Viewholder, position: Int), the target view data may be bound to the current view container by:
Figure BDA0002839462480000131
Figure BDA0002839462480000141
wherein, HolderTogetherRoom, AAAA, BBBB, CCCC and DDDD are view container structure types corresponding to different data types. Inside the view container binding function handleviewholder, data binding of the view container can be dynamically performed through type matching, so that the binding operation of multi-type data can be realized.
According to the technical scheme of the embodiment, the current view type to be displayed at present is matched with the data type corresponding to each view container construction class, the first view container construction class matched with the current view type is determined, the view container construction function in the first view container construction class is called, and the current view container corresponding to the current view type is constructed, so that the isolation construction of the view container can be realized. The current view container is matched with the view container corresponding to each view container construction class, a second view container construction class matched with the current view container is determined, a view container binding function in the second view container construction class is called, and target view data are bound to the current view container, so that multi-type data binding can be realized, the purpose of low coupling and high cohesion is realized, the development efficiency is improved, and the application range of a scene is also improved.
On the basis of the above technical solution, the "matching the current view container with the view container corresponding to each view container configuration class" in S270 may include: detecting whether the data package set object is an empty object and whether the input target position information of the integer type is larger than or equal to the size information of the data package set object; and if the data package set object is detected to be a non-empty object and the input target position information of the integer type is smaller than the size information of the data package set object, matching the current view container with the view container corresponding to each view container construction class.
Specifically, before performing data binding, the validity of the view data may be checked, for example, whether the data package set object dataList is an empty object and whether the input target position information position of the integer type is greater than or equal to the size information dataList. If it is detected that the data package aggregation object is a non-empty object and the input target position information position is smaller than the size information datasist.size of the data package aggregation object, it indicates that the target view data to be bound can be acquired, that is, the data is legal, and at this time, the data binding operation may be performed by performing S270. If the data package set object is detected to be an empty object or the input target position information position is smaller than the size information datalist.
The following is an embodiment of a data adaptation apparatus provided in an embodiment of the present invention, which belongs to the same inventive concept as the data adaptation methods of the above embodiments, and details that are not described in detail in the embodiment of the data adaptation apparatus may refer to the embodiment of the data adaptation method.
EXAMPLE III
Fig. 3 is a schematic structural diagram of a data adaptation apparatus according to a third embodiment of the present invention, which is applicable to a case of adapting view data to be displayed, which is acquired from a data source. As shown in fig. 3, the apparatus specifically includes: a data package collection object obtaining module 310, a preset adapter object creating module 320, a current view container building module 330, and a target view data binding module 340.
The data package collection object obtaining module 310 is configured to obtain a data package collection object, where the data package collection object is composed of one or more data package objects, and each data package object is used to store view data of one data type; a preset adapter object creating module 320, configured to initialize a preset adapter class according to the data package collection object, and create a preset adapter object; a current view container constructing module 330, configured to construct a current view container corresponding to a current view type to be currently displayed, based on a view container construction class corresponding to each data type by calling a view container construction function in a preset adapter object; and the target view data binding module 340 is configured to bind the target view data in the data package set object to the current view container by calling a view container binding function in the preset adapter object and based on the view container construction class corresponding to each data type.
Optionally, the data package set object obtaining module 310 is specifically configured to: initializing a predefined data package class according to view data of each data type to be adapted, and creating a data package object corresponding to each view data, wherein a construction function of the data package class comprises a first input parameter and a second input parameter, the first input parameter is data type information of an integer type, and the second input parameter is view data information of Any Any type; and determining a data package set object according to each data package object.
Optionally, the preset adapter object creating module 320 is specifically configured to: initializing a preset adapter class based on a constructor of the preset adapter class, and creating a preset adapter object; the input parameters of the constructor of the preset adapter class are respectively context object, data package set object and page type information.
Optionally, the apparatus further comprises: the view container construction function execution unit is used for realizing the function of constructing the current view container corresponding to the current view type to be displayed currently based on the view container construction class corresponding to each data type through the following steps:
acquiring a predefined view container construction class corresponding to each data type, wherein each view container construction class comprises a predefined view container construction function; matching the current view type to be displayed with the data type corresponding to each view container construction class, and determining a first view container construction class matched with the current view type; and calling a view container construction function in the first view container construction class to construct a current view container corresponding to the current view type.
Optionally, the apparatus further comprises: the view container binding function execution unit is used for realizing the function of binding the target view data in the data package collection object to the current view container based on the view container construction class corresponding to each data type through the following steps:
obtaining predefined view container construction classes corresponding to each data type, wherein each view container construction class further comprises a predefined view container binding function; matching the current view container with the view container corresponding to each view container construction class, and determining a second view container construction class matched with the current view container; determining target view data in the data package set object according to the input target position information of the integer type; and calling a view container binding function in the second view container construction class to bind the target view data to the current view container.
Optionally, matching the current view container with the view container corresponding to each view container construction class includes: detecting whether the data package set object is an empty object and whether the input target position information of the integer type is larger than or equal to the size information of the data package set object; and if the data package set object is detected to be a non-empty object and the input target position information of the integer type is smaller than the size information of the data package set object, matching the current view container with the view container corresponding to each view container construction class.
Optionally, the access type of the preset adapter class is an open type, the preset adapter class inherits the view recovery adapter in the system and duplicates a view container construction function and a view container binding function in the view recovery adapter, so that the created view container construction function in the preset adapter object realizes a construction logic function of the view container, and the view container binding function realizes a binding logic function of binding data to the corresponding view container.
The data adaptation device provided by the embodiment of the invention can execute the data adaptation method provided by any embodiment of the invention, and has the corresponding functional module and beneficial effect of executing the data adaptation method.
It should be noted that, in the embodiment of the data adaptation apparatus, the included units and modules are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, the specific names of the functional units are only for the convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
Example four
Fig. 4 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention. FIG. 4 illustrates a block diagram of an exemplary electronic device 12 suitable for use in implementing embodiments of the present invention. The electronic device 12 shown in fig. 4 is only an example and should not bring any limitation to the function and the scope of use of the embodiment of the present invention.
As shown in FIG. 4, electronic device 12 is embodied in the form of a general purpose computing device. The components of electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 and the processing unit 16.
Bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 12 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 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/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 4, and commonly referred to as a "hard drive"). Although not shown in FIG. 4, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 18 by one or more data media interfaces. System memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 40 having a set (at least one) of program modules 42 may be stored, for example, in system memory 28, such program modules 42 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 of which may comprise an implementation of a network environment. Program modules 42 generally carry out the functions and/or methodologies of the described embodiments of the invention.
Electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), with one or more devices that enable a user to interact with electronic device 12, and/or with any devices (e.g., network card, modem, etc.) that enable electronic device 12 to communicate with one or more other computing devices. Such communication may be through an input/output (I/O) interface 22. Also, the electronic device 12 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the Internet) via the network adapter 20. As shown, the network adapter 20 communicates with the other modules of the electronic device 12 over the bus 18. It should be understood that although not shown in the figures, other hardware and/or software modules may be used in conjunction with electronic device 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, for example, to implement a data adaptation method provided by the embodiment of the present invention, the method includes:
acquiring a data package collection object, wherein the data package collection object consists of one or more data package objects, and each data package object is used for storing view data of one data type;
initializing a preset adapter class according to the data package set object, and creating a preset adapter object;
constructing a current view container corresponding to the current view type to be displayed currently based on a view container construction class corresponding to each data type by calling a view container construction function in a preset adapter object;
and by calling a view container binding function in the preset adapter object, constructing a class based on the view container corresponding to each data type, and binding target view data in the data package set object to the current view container.
Of course, those skilled in the art can understand that the processor can also implement the technical solution of the data adaptation method provided in any embodiment of the present invention.
EXAMPLE five
The present embodiment provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of a data adaptation method as provided by any of the embodiments of the invention, the method comprising:
acquiring a data package collection object, wherein the data package collection object consists of one or more data package objects, and each data package object is used for storing view data of one data type;
initializing a preset adapter class according to the data package set object, and creating a preset adapter object;
constructing a current view container corresponding to the current view type to be displayed currently based on a view container construction class corresponding to each data type by calling a view container construction function in a preset adapter object;
and by calling a view container binding function in the preset adapter object, constructing a class based on the view container corresponding to each data type, and binding target view data in the data package set object to the current view container.
Computer storage media for embodiments of the present invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer-readable storage medium may be, for example but not limited to: an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the 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 network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It will be understood by those skilled in the art that the modules or steps of the invention described above may be implemented by a general purpose computing device, they may be centralized on a single computing device or distributed across a network of computing devices, and optionally they may be implemented by program code executable by a computing device, such that it may be stored in a memory device and executed by a computing device, or it may be separately fabricated into various integrated circuit modules, or it may be fabricated by fabricating a plurality of modules or steps thereof into a single integrated circuit module. Thus, the present invention is not limited to any specific combination of hardware and software.
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 data adaptation method, comprising:
acquiring a data package collection object, wherein the data package collection object is composed of one or more data package objects, and each data package object is used for storing view data of one data type;
initializing a preset adapter class according to the data package set object, and creating a preset adapter object;
constructing a current view container corresponding to the current view type to be displayed currently based on a view container construction class corresponding to each data type by calling a view container construction function in the preset adapter object;
and by calling a view container binding function in the preset adapter object, constructing a class based on the view container corresponding to each data type, and binding target view data in the data package set object to the current view container.
2. The method of claim 1, wherein obtaining a data package collection object comprises:
initializing a predefined data package class according to view data of each data type to be adapted, and creating a data package object corresponding to each view data, wherein a construction function of the data package class comprises a first input parameter and a second input parameter, the first input parameter is data type information of an integer type, and the second input parameter is view data information of Any Any type;
and determining a data package set object according to each data package object.
3. The method of claim 1, wherein initializing a preset adapter class according to the data package aggregation object, creating a preset adapter object, comprises:
initializing a preset adapter class based on a constructor of the preset adapter class, and creating a preset adapter object;
the input parameters of the constructor of the preset adapter class are respectively a context object, the data package set object and page type information.
4. The method according to claim 1, wherein the view container construction function implements a function of constructing a current view container corresponding to a current view type to be currently displayed based on a view container construction class corresponding to each data type by:
obtaining a predefined view container construction class corresponding to each data type, wherein each view container construction class comprises a predefined view container construction function;
matching the current view type to be displayed currently with the data type corresponding to each view container construction class, and determining a first view container construction class matched with the current view type;
and calling a view container construction function in the first view container construction class to construct a current view container corresponding to the current view type.
5. The method of claim 1, wherein the view container binding function implements the function of binding the target view data in the data package collection object to the current view container based on the view container construction class corresponding to each data type by:
obtaining predefined view container construction classes corresponding to each data type, wherein each view container construction class further comprises a predefined view container binding function;
matching the current view container with the view container corresponding to each view container construction class, and determining a second view container construction class matched with the current view container;
determining target view data in the data package set object according to the input target position information of the integer type;
and calling a view container binding function in the second view container construction class to bind the target view data to the current view container.
6. The method of claim 5, wherein matching the current view container with the view container corresponding to each of the view container construction classes comprises:
detecting whether the data package set object is an empty object and whether the input target position information of the integer type is larger than or equal to the size information of the data package set object;
and if the data package set object is detected to be a non-empty object and the input target position information of the integer type is smaller than the size information of the data package set object, matching the current view container with the view container corresponding to each view container construction class.
7. The method according to any one of claims 1 to 6, wherein the access type of the preset adapter class is an open type, and the preset adapter class inherits the view reclamation adapter in the system and duplicates the view container construction function and the view container binding function in the view reclamation adapter, so that the view container construction function in the created preset adapter object implements the construction logic function of the view container and the view container binding function implements the binding logic function of binding data to the corresponding view container.
8. A data adaptation apparatus, comprising:
the data package collection object acquisition module is used for acquiring a data package collection object, wherein the data package collection object consists of one or more data package objects, and each data package object is used for storing view data of one data type;
the preset adapter object creating module is used for initializing a preset adapter class according to the data package set object and creating a preset adapter object;
a current view container construction module, configured to construct a current view container corresponding to a current view type to be currently displayed, based on a view container construction class corresponding to each data type, by calling a view container construction function in the preset adapter object;
and the target view data binding module is used for binding the target view data in the data package set object to the current view container by calling a view container binding function in the preset adapter object and constructing a class based on the view container corresponding to each data type.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a memory for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the data adaptation method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the data adaptation method as claimed in any one of the claims 1 to 7.
CN202011486696.5A 2020-12-16 2020-12-16 Data adaptation method, device, equipment and storage medium Pending CN114637504A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011486696.5A CN114637504A (en) 2020-12-16 2020-12-16 Data adaptation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011486696.5A CN114637504A (en) 2020-12-16 2020-12-16 Data adaptation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114637504A true CN114637504A (en) 2022-06-17

Family

ID=81944802

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011486696.5A Pending CN114637504A (en) 2020-12-16 2020-12-16 Data adaptation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114637504A (en)

Similar Documents

Publication Publication Date Title
US11238099B2 (en) Method and device for obtaining answer, and computer device
US9934005B2 (en) Dynamically building locale objects or subsections of locale objects based on historical data
CN110908697B (en) Resource packaging method, device, server and storage medium
CN109062617A (en) A kind of application method, the mobile terminal of platform that supporting polymorphic type equipment
US20210096876A1 (en) Saving and restoring machine state between multiple executions of an instruction
CN109033456B (en) Condition query method and device, electronic equipment and storage medium
CN115795211A (en) Page display method, device, system, equipment and storage medium
US9141353B2 (en) Dynamically building locale objects at run-time
CN110737678B (en) Data searching method, device, equipment and storage medium
US20200142705A1 (en) Migration of partially completed instructions
CN114637504A (en) Data adaptation method, device, equipment and storage medium
CN112052040A (en) Processing method, processing device, computer equipment and storage medium
CN109284108A (en) Date storage method, device, electronic equipment and storage medium
CN113485686B (en) Information system program generation method and device, electronic equipment and storage medium
CN111447268B (en) File structure conversion method, device, equipment and storage medium
CN114185516A (en) Method, device, equipment and medium for adapting list item view in Android system
CN112764802A (en) Business logic customization method and device, electronic equipment and storage medium
CN112364268A (en) Resource acquisition method and device, electronic equipment and storage medium
CN113535660B (en) Android log storage method and device
CN112988150B (en) Page label operation method and device and electronic equipment
CN114138276A (en) Page compiling method and device, electronic equipment and storage medium
CN114546467A (en) Patch file delivery method, device, equipment and storage medium
CN113283017A (en) Part separation method, device, equipment and storage medium
CN115408003A (en) Data access method and device in virtual machine, electronic equipment and medium
CN114371832A (en) Business code generation method and device based on semantic analysis 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