Data processing method, device, electronic device and storage medium
By defining the calling function in the Android operating system, the offset address of the Fragment is automatically found, which solves the problem of complex data rendering logic between Fragment and View-Model, simplifies the development process and reduces maintenance costs.
Patent Information
- Application Number
- CN202111676626.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In the Android operating system, the data rendering logic between Fragment and View-Model is complex, causing developers to manually write multi-level offset address transfers, which increases development difficulty and maintenance costs.
By defining the calling function in multiple cascaded Views, the offset address of the Fragment is automatically searched in the property field of the View until the View is the first in the cascading order, thereby simplifying the acquisition of the offset address of the Fragment in the application. process.
It reduces the workload of developers, reduces labor costs and code complexity, simplifies the amount of code in Fragment, and reduces later maintenance costs.
Smart Images

Figure CN114416085B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device, electronic equipment and storage medium. Background Art
[0002] Fragment is a display control in the Android operating system. View can be created on Fragment, and View can be superimposed on View to form multiple cascaded Views.
[0003] View is a control in the Android operating system for displaying the user interface. Displaying data on a Fragment can be regarded as displaying data on a View in a Fragment.
[0004] In order to separate the data to be displayed, the logic of displaying data, and the logic of processing user interaction data to comply with the "single responsibility" principle, View can be responsible for displaying data and processing user interaction data, but not for storing and acquiring data. Data storage and acquisition can be handed over to the View-Model in the Fragment. That is, the data that the View needs to render can be obtained through the View-Model, and the data that the View needs to render can be stored in the View-Model. Summary of the invention
[0005] The present application illustrates a data processing method, device, electronic device and storage medium.
[0006] In a first aspect, the present application shows a data processing method, which is applied to a terminal, wherein an application is installed on the terminal, wherein the application has a fragment Fragment, wherein the Fragment includes a view model View-Model and a plurality of cascaded views View, wherein an attribute field in a View that is the first in the cascade order among the plurality of cascaded Views stores an offset address of the Fragment in the application, wherein the View-Model includes data that the View needs to render, and wherein the method includes:
[0007] For a target View in the cascaded multiple Views, when the target View needs to render data, searching the offset address of the Fragment in the application in the attribute field of the target View;
[0008] If the offset address of the Fragment in the application is not found in the attribute field of the target View, the offset address of the Fragment in the application is found in the attribute field of the upper-level View of the target View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views;
[0009] Retrieving data that needs to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application;
[0010] Render the retrieved data based on the target View.
[0011] In an optional implementation, searching the attribute field of the target View for the offset address of the Fragment in the application includes:
[0012] Obtain identification information of the Fragment to which the target View belongs, which is recorded in the target View;
[0013] Searching the attribute field of the target View for the offset address bound to the identification information of the Fragment;
[0014] In the case where the offset address bound to the identification information of the Fragment is not found, it can be determined that the offset address of the Fragment in the application is not found;
[0015] Alternatively, when the offset address bound to the identification information of the Fragment is found, the offset address of the Fragment in the application program may be acquired according to the found offset address.
[0016] In an optional implementation, the Fragment includes multiple View-Models, and different View-Models include data that needs to be rendered by different Views in the Fragment;
[0017] The step of retrieving data that needs to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application program includes:
[0018] At least according to the offset address of the Fragment in the application and the identification information of the target View, the data that needs to be rendered of the target View is retrieved from the View-Model corresponding to the target View.
[0019] In the second aspect, the present application shows a data processing method, wherein a terminal has an application development environment, wherein a fragment Fragment of the application has been developed in the development environment, wherein the Fragment includes a view model View-Model and a plurality of cascaded views View, wherein each View is used to render data, and the View-Model includes data that the View needs to render, and the method includes:
[0020] For the target View that needs to render data in the cascaded multiple Views, add a calling function in the target View according to the writing operation input by the developer;
[0021] And, in the process of compiling the Fragment developed in the development environment, determining a View that is first in the cascade order among the multiple cascaded Views, and storing an offset address of the Fragment in the application in an attribute field in the View that is first in the cascade order;
[0022] Among them, the calling function is used to: search for the offset address of the Fragment in the application in the attribute field of the View; if the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is first in the cascade order among the multiple cascaded Views.
[0023] In an optional implementation, storing the offset address of the Fragment in the application in the attribute field in the View that is first in the cascading order includes:
[0024] Obtain identification information of the Fragment;
[0025] Binding the identification information of the Fragment and the offset address of the Fragment in the application;
[0026] In the attribute field of the View that is first in the cascading order, the identification information of the bound Fragment and the offset address of the Fragment in the application are stored.
[0027] In a third aspect, the present application shows a data processing device, which is applied to a terminal, on which an application is installed, wherein the application has a fragment Fragment, wherein the Fragment includes a view model View-Model and a plurality of cascaded views View, wherein an attribute field in the View with the first cascade order in the plurality of cascaded Views stores an offset address of the Fragment in the application, wherein the View-Model includes data that the View needs to render, and the device includes:
[0028] A first search module is used for searching, for a target View in a plurality of cascaded Views, an offset address of the Fragment in the application in an attribute field of the target View when the target View needs to render data;
[0029] A second search module is used for searching the offset address of the Fragment in the application in the attribute field of the upper-level View of the target View in the cascaded multiple Views if the offset address of the Fragment in the application is not found in the attribute field of the target View, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views;
[0030] A calling module, used for calling the data to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application;
[0031] The rendering module is used to render the retrieved data based on the target View.
[0032] In an optional implementation, the first search module includes:
[0033] A first acquisition unit, configured to acquire identification information of the Fragment to which the target View belongs, recorded in the target View;
[0034] A search unit, configured to search an offset address bound to the identification information of the Fragment in an attribute field of the target View;
[0035] A determining unit, configured to determine that the offset address of the Fragment in the application program has not been found if the offset address bound to the identification information of the Fragment has not been found;
[0036] The second acquisition unit is configured to, when an offset address bound to the identification information of the Fragment is found, acquire the offset address of the Fragment in the application according to the found offset address.
[0037] In an optional implementation, the Fragment includes multiple View-Models, and different View-Models include data that needs to be rendered by different Views in the Fragment;
[0038] The calling module is specifically used to call the data that needs to be rendered of the target View from the View-Model corresponding to the target View at least according to the offset address of the Fragment in the application and the identification information of the target View.
[0039] In a fourth aspect, the present application shows a data processing device, wherein a terminal has an application development environment, wherein a fragment Fragment of the application has been developed in the development environment, wherein the Fragment includes a view model View-Model and a plurality of cascaded views View, wherein each View is used to render data, and the View-Model includes data that the View needs to render, and the device includes:
[0040] Add a module for adding a calling function in a target View that needs to render data among multiple cascaded Views according to the writing operation input by the developer;
[0041] A determination module, used for determining a View with a first cascade order among a plurality of cascaded Views during the process of compiling the Fragment developed in the development environment, and a storage module, used for storing an offset address of the Fragment in the application in an attribute field in the View with a first cascade order;
[0042] Among them, the calling function is used to: search for the offset address of the Fragment in the application in the attribute field of the View; if the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is first in the cascade order among the multiple cascaded Views.
[0043] In an optional implementation, the storage module includes:
[0044] A third acquisition unit, used to acquire identification information of the Fragment;
[0045] A binding unit, used to bind the identification information of the Fragment and the offset address of the Fragment in the application;
[0046] The storage unit is used to store the identification information of the bound Fragment and the offset address of the Fragment in the application program in the attribute field of the View that is first in the cascading order.
[0047] In a fifth aspect, the present application shows an electronic device, the electronic device comprising:
[0048] processor;
[0049] a memory for storing processor-executable instructions;
[0050] Wherein, the processor is configured to execute the data processing method as described in the first aspect.
[0051] In a sixth aspect, the present application illustrates a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to perform the data processing method as described in the first aspect.
[0052] In a seventh aspect, the present application illustrates a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method as described in the first aspect.
[0053] In an eighth aspect, the present application provides an electronic device, the electronic device comprising:
[0054] processor;
[0055] a memory for storing processor-executable instructions;
[0056] Wherein, the processor is configured to execute the data processing method as described in the second aspect.
[0057] In a ninth aspect, the present application illustrates a non-temporary computer-readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the data processing method as described in the second aspect.
[0058] In a tenth aspect, the present application illustrates a computer program product. When instructions in the computer program product are executed by a processor of an electronic device, the electronic device is enabled to perform the data processing method as described in the second aspect.
[0059] The technical solution provided by this application may have the following beneficial effects:
[0060] In the present application, for a target View among multiple cascaded Views, when the target View needs to render data, the offset address of the Fragment in the application is searched in the attribute field of the target View. If the offset address of the Fragment in the application is not found in the attribute field of the target View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the target View among the multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views. At least the data that needs to be rendered of the target View is retrieved from the View-Model based on the offset address of the Fragment in the application. The retrieved data is rendered based on the target View.
[0061] Through this application, it is supported to encapsulate "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View of the cascaded View in multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order of multiple cascaded Views" into a calling function during the application development stage. The calling function can be called by the View, and the calling function has a function name.
[0062] Secondly, when developing an application, the offset address of the Fragment in the application can be stored in the attribute field of the View that is the first in the cascading order of multiple cascaded Views.
[0063] In this way, for any View in the Fragment, if the View needs to retrieve the data that needs to be rendered by the View from the View-Model according to the offset address of the Fragment in the application, the developer can directly introduce the function name of the function in the View when writing the computer program code of the Fragment, so that the View can have the function of "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views." That is, the View can have the function of obtaining the offset address of the Fragment in the application.
[0064] The same is true for every other View in the Fragment.
[0065] In this way, developers can develop a call function and reuse the call function in multiple Views in the Fragment to achieve the function of obtaining the offset address of the Fragment in the application for multiple Views. The same is true for other Fragments in the application. In other words, other Fragments can reuse the call function.
[0066] In this way, through this application, the workload of developers can be reduced, the labor cost can be reduced, the amount of code in the Fragment can be reduced, the complexity of the Fragment code can be reduced, and the subsequent maintenance cost can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] Figure 1 It is a step flow chart of a data processing method of the present application.
[0068] Figure 2 It is a structural block diagram of a data processing device of the present application.
[0069] Figure 3 It is a structural block diagram of a data processing device of the present application.
[0070] Figure 4 It is a block diagram of an electronic device of the present application.
[0071] Figure 5 It is a block diagram of an electronic device of the present application. DETAILED DESCRIPTION
[0072] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0073] When the View needs to render data, you can access the View-Model through the ViewModelProviders.of function, and call the data that the View needs to render in the View-Model, and then you can render the data that the View needs to render in the View.
[0074] However, in one case, for any View in the Fragment, if you access the View-Model through the ViewModelProviders.of function, you need to pass in the "offset address of the Fragment in the application" in the ViewModelProviders.of function.
[0075] However, before passing the "offset address of the Fragment in the application" into the ViewModelProviders.of function, you first need to get the "offset address of the Fragment in the application".
[0076] However, for any View in a Fragment, the View can only interact directly with the View of the upper level of the View cascade, that is, the View can only transfer data with the View of the upper level of the View cascade.
[0077] In one case, there are many cascade levels between multiple Views in a Fragment. For a View at a deeper level, if it needs to obtain the "offset address of the Fragment in the application", it needs to pass the "offset address of the Fragment in the application" to the View in turn through all the Views cascaded by the View.
[0078] However, in this case, when the developer develops the computer program code of the Fragment, he needs to write the computer program code of "passing the 'offset address of the Fragment in the application' from the Fragment to the View in turn through all the upper Views cascaded by the View".
[0079] In this way, for the Fragment and each upper-level View of the View cascade, it is necessary to write computer program code to pass (or obtain, etc.) the "offset address of the Fragment in the application". For a View at a deeper level, it has several upper-level Views in the cascade, and it is necessary to write computer program code to pass the "offset address of the Fragment in the application" several times for several Views, resulting in a large development workload and high labor costs for developers, and the large amount of code in the Fragment leads to high subsequent maintenance costs.
[0080] After analyzing the above-described method, the inventor abandoned the idea of the above-described method and did not write a computer program code that "passes the 'offset address of the Fragment in the application' from the Fragment to the View through all the upper Views cascaded by the View in sequence". Instead, the inventor sets the offset address of the Fragment in the application in the attribute field of the View that is the first in the cascade order of multiple cascaded Views.
[0081] Also, developers can develop a caller function.
[0082] Among them, the calling function can play the following roles: "Search for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View of the cascaded View, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order of the cascaded Views."
[0083] The calling function can be called by View, and the calling function has a function name.
[0084] In this way, for any View in the Fragment, if the View needs to retrieve the data that needs to be rendered by the View from the View-Model according to the offset address of the Fragment in the application, the developer can directly introduce the function name of the function in the View when writing the computer program code of the Fragment, so that the View can have the function of "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views." That is, the View can have the function of obtaining the offset address of the Fragment in the application.
[0085] The same is true for every other View in the Fragment.
[0086] In this way, developers can develop a call function and reuse the call function in multiple Views in the Fragment to achieve the function of obtaining the offset address of the Fragment in the application for multiple Views. The same is true for other Fragments in the application. In other words, other Fragments can reuse the call function.
[0087] In this way, through this application, the workload of developers can be reduced, the labor cost can be reduced, the amount of code in the Fragment can be reduced, the complexity of the Fragment code can be reduced, and the subsequent maintenance cost can be reduced.
[0088] Specifically, refer to Figure 1 , showing a flow chart of the steps of a data processing method of the present application, which is applied to a terminal, an application is installed on the terminal, and the application has a Fragment, which includes a View-Model and multiple cascaded Views, and the offset address of the Fragment in the application is stored in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views. Each View is used to render data, and the View-Model includes the data that the View needs to render. The method may specifically include the following steps:
[0089] In step S101 , for a target View in a plurality of cascaded Views, when the target View needs to render data, the offset address of the Fragment in the application is searched in the attribute field of the target View.
[0090] In the present application, the target View may be any one of the multiple Views, etc. Among them, for the target View among the multiple Views, the process of steps S101 to S104 of the present application may be executed, and for each of the other Views among the multiple Views, the process of steps S101 to S104 of the present application may be executed.
[0091] Among them, a page of the application can be developed based on Fragment, and the Fragment includes multiple cascaded Views. In this way, what is reflected on the page is: the page includes multiple cascaded views, etc.
[0092] Each View has data that needs to be rendered. The data that the View needs to render in this application can be uniformly managed by the View-Model included in the Fragment. Therefore, for the View, it can only care about obtaining the data that needs to be rendered from the View-Model included in the Fragment and rendering the data, without caring about how the data that needs to be rendered is generated or where it comes from.
[0093] Among them, when the target View needs to render data, the data that needs to be rendered by the target View can be called from the View-Model. In order to be able to call the data that needs to be rendered by the target View from the View-Model, it is necessary to obtain the offset address of the Fragment in the application, and then call the data that needs to be rendered by the target View from the View-Model according to the offset address of the Fragment in the application, and then render the data that needs to be rendered by the target View based on the target View.
[0094] In order to obtain the offset address of the Fragment in the application, in one embodiment of the present application, in advance during the process of developing the application, (the developer) develops the Fragment for the application in the development environment of the application, and develops multiple cascaded Views for the Fragment.
[0095] When compiling a fragment in a development environment, the View that is first in the cascade order can be automatically determined among multiple cascaded Views.
[0096] Among them, the cascading order between multiple Views included in the Fragment can be set by the developer, for example, set in the development environment, etc. Therefore, according to the cascading relationship between the multiple Views included in the Fragment set by the developer, the View with the first cascading order in the cascaded multiple Views can be automatically determined.
[0097] In addition, the offset address of the Fragment in the application can also be determined, and then the offset address of the Fragment in the application can be stored in the attribute field in the View that is first in the cascading order.
[0098] In one embodiment, in the attribute field of the View that is first in the cascading order, data may be stored in the form of key-value pairs.
[0099] In this way, when the offset address of the Fragment in the application is stored in the attribute field of the View that is first in the cascading order, in order to uniquely identify the offset address of the Fragment in the application, the identification information of the Fragment can be obtained, wherein the identification information of different Fragments in the application in the present application can be different, and the identification information of the Fragment can be located in the attribute field of the Fragment. In this way, the identification information of the Fragment can be obtained from the attribute field of the Fragment.
[0100] Then the identification information of the Fragment and the offset address of the Fragment in the application are bound. For example, the identification information of the Fragment and the offset address of the Fragment in the application are combined into a key-value pair. In one example, for example, when the key-value pair is a "key-value" key-value pair, the identification information of the Fragment can be a key, and the offset address of the Fragment in the application can be a value, etc.
[0101] Then, the identification information of the bound Fragment and the offset address of the Fragment in the application can be stored in the attribute field of the View that is first in the cascading order, for example, a "key-value" key-value pair including the identification information of the Fragment and the offset address of the Fragment in the application can be stored.
[0102] In this way, when searching for the offset address of the Fragment in the application in the attribute field of the target View, the identification information of the Fragment to which the target View belongs recorded in the target View can be obtained.
[0103] For example, the identification information of the Fragment to which the target View belongs may be stored in a specific field in the target View. Thus, the identification information of the Fragment to which the target View belongs may be obtained in the specific field in the target View.
[0104] Then, the offset address bound to the identification information of the Fragment may be searched in the attribute field of the target View. For example, a key-value pair including "using the identification information of the Fragment as the key" may be searched in the attribute field of the target View.
[0105] If a key-value pair including the Fragment's identification information as the key is not found in the target View's attribute field, it can be determined that the offset address bound to the Fragment's identification information is not found. Alternatively, if a key-value pair including "the Fragment's identification information as the key" is found in the target View's attribute field, the value "offset address" in the key-value pair "the Fragment's identification information as the key" can be used as the offset address bound to the Fragment's identification information.
[0106] In the case where the offset address bound to the identification information of the Fragment is not found, it can be determined that the offset address of the Fragment in the application is not found.
[0107] Alternatively, when an offset address bound to the identification information of the Fragment is found, the offset address of the Fragment in the application can be obtained according to the found offset address. For example, the found offset address can be used as the offset address of the Fragment in the application.
[0108] In step S102, if the offset address of the Fragment in the application is not found in the attribute field of the target View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the target View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views.
[0109] Among them, when searching for the offset address of the Fragment in the application in the attribute field of the target View, in one embodiment of the present application, if the target View is the View that is the first in the cascade order in the Fragment, the offset address of the Fragment in the application can be searched in the attribute field of the target View, and then step S103 can be executed.
[0110] However, in another embodiment of the present application, if the target View is not the first View in the cascade order of the Fragment, the offset address of the Fragment in the application cannot be found in the attribute field of the target View. In order to obtain the offset address of the Fragment in the application, the offset address of the Fragment in the application can be searched in the attribute field of the upper-level View (adjacent) of the target View in the cascaded multiple Views.
[0111] The application's Fragment records the cascade relationship between multiple Views in the Fragment. For example, the cascade field in the next-level View records the identification information of the previous-level View (adjacent) of the next-level View cascade.
[0112] In this way, when the offset address of the Fragment in the application is not found in the attribute field of the target View, the identification information of the upper-level View (and adjacent) of the target View cascade can be obtained in the cascade field of the target View. The identification information of different Views is different. Then, based on the identification information of the upper-level View of the target View cascade, the upper-level View of the target View cascade can be determined among the multiple cascaded Views, and then the offset address of the Fragment in the application can be found in the attribute field of the upper-level View of the target View cascade in the multiple cascaded Views.
[0113] Among them, in one embodiment of the present application, if the upper level View of the target View cascade is the View that is the first in the cascade order in the Fragment, the offset address of the Fragment in the application can be found in the attribute field of the upper level View of the target View cascade, and then step S103 can be executed.
[0114] However, in another embodiment of the present application, if the previous level View of the target View cascade is not the first View in the cascade order of the Fragment, the offset address of the Fragment in the application cannot be found in the attribute field of the previous level View of the target View cascade. In order to obtain the offset address of the Fragment in the application, the offset address of the Fragment in the application can be searched in the attribute field of the previous level View cascaded by the previous level View (adjacent) in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple Views, and then step S103 can be executed.
[0115] In step S103, the data to be rendered of the target View is retrieved from the View-Model at least according to the offset address of the Fragment in the application.
[0116] In one embodiment of the present application, by passing in the "offset address of the Fragment in the application" in the acquisition function (such as ViewModel Providers.of, etc.), the data returned by the ViewModelProviders.of function can be obtained, and the data that needs to be rendered of the target View can be filtered out from the returned data.
[0117] In the above embodiment, the Fragment includes a View-Model, and the View-Model includes the data that needs to be rendered by all Views in the Fragment, that is, the View-Model in the Fragment and the View in the Fragment are in a one-to-many relationship. The acquisition function can return the data that needs to be rendered by all Views included in the Fragment, and then filter the data that needs to be rendered by the target View based on the data that needs to be rendered by all Views included in the returned Fragment.
[0118] However, the logic in the above method is relatively complex and consumes more system resources. Therefore, in order to save system resources, in another embodiment of the present application, in the process of developing an application, a corresponding View-Model can be developed for each View in the Fragment, and each View-Model is used to manage the data that needs to be rendered by different Views.
[0119] In this way, the Fragment includes multiple View-Models, and different View-Models may include different data that the View needs to render.
[0120] In this way, when the data that needs to be rendered of the target View is called from the View-Model at least according to the offset address of the Fragment in the application, the data that needs to be rendered of the target View can be called from the View-Model corresponding to the target View at least according to the offset address of the Fragment in the application and the identification information of the target View.
[0121] Among them, the identification information of each View is recorded in the View-Model corresponding to the View, so that the View-Model corresponding to the View can be indexed according to the identification information of the View.
[0122] For example, the developer can improve the acquisition function (such as ViewModel Providers.of, etc.) in advance so that the acquisition function can have at least two input parameters, and the at least two input parameters can include the offset address of the Fragment in the application and the identification information of the target View, so that the acquisition function can access the View-Model corresponding to the target View according to the offset address of the Fragment in the application and the identification information of the target View, and access the data that needs to be rendered of the target View from the View-Model corresponding to the target View, and return the data that needs to be rendered of the target View. The terminal can obtain the data that needs to be rendered of the target View returned by the acquisition function.
[0123] In addition, this embodiment can manage the data that different Views need to render through different View-Models, thereby improving the independence of the View-Models corresponding to each View.
[0124] In this way, if a View needs to be reused in different Fragments, the View developed in one Fragment and the View-Model corresponding to the View can be directly copied or introduced into another Fragment, without the need to introduce the View and the View-Model in the Fragment that includes the data that needs to be rendered for all Views in the Fragment into another Fragment, which can reduce the redundancy of another Fragment.
[0125] In step S104 , the retrieved data is rendered based on the target View.
[0126] In this application, any currently existing rendering method can be used to render the retrieved data based on the target View, and this application does not limit the specific rendering method.
[0127] In the present application, for a target View among multiple cascaded Views, when the target View needs to render data, the offset address of the Fragment in the application is searched in the attribute field of the target View. If the offset address of the Fragment in the application is not found in the attribute field of the target View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the target View among the multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views. At least the data that needs to be rendered of the target View is retrieved from the View-Model based on the offset address of the Fragment in the application. The retrieved data is rendered based on the target View.
[0128] Through this application, it is supported to encapsulate "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View of the cascaded View in multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order of multiple cascaded Views" into a calling function during the application development stage. The calling function can be called by the View, and the calling function has a function name.
[0129] Secondly, when developing an application, the offset address of the Fragment in the application can be stored in the attribute field of the View that is the first in the cascading order of multiple cascaded Views.
[0130] In this way, for any View in the Fragment, if the View needs to retrieve the data that needs to be rendered by the View from the View-Model according to the offset address of the Fragment in the application, the developer can directly introduce the function name of the function in the View when writing the computer program code of the Fragment, so that the View can have the function of "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views." That is, the View can have the function of obtaining the offset address of the Fragment in the application.
[0131] The same is true for every other View in the Fragment.
[0132] In this way, developers can develop a call function and reuse the call function in multiple Views in the Fragment to achieve the function of obtaining the offset address of the Fragment in the application for multiple Views. The same is true for other Fragments in the application. In other words, other Fragments can reuse the call function.
[0133] In this way, through this application, the workload of developers can be reduced, the labor cost can be reduced, the amount of code in the Fragment can be reduced, the complexity of the Fragment code can be reduced, and the subsequent maintenance cost can be reduced.
[0134] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by the present application.
[0135] Reference Figure 2, shows a structural block diagram of a data processing device of the present application, which is applied to a terminal, an application is installed on the terminal, and a fragment Fragment is included in the application, and the Fragment includes a view model View-Model and multiple cascaded views View, and the offset address of the Fragment in the application is stored in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views, and the View-Model includes data that the View needs to render, and the device includes:
[0136] A first search module 11 is used for searching, for a target View in a plurality of cascaded Views, an offset address of the Fragment in the application in an attribute field of the target View when the target View needs to render data;
[0137] The second search module 12 is used for searching the offset address of the Fragment in the application in the attribute field of the upper-level View of the target View in the cascaded multiple Views if the offset address of the Fragment in the application is not found in the attribute field of the target View, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views;
[0138] A calling module 13, configured to call the data to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application;
[0139] The rendering module 14 is used to render the retrieved data based on the target View.
[0140] In an optional implementation, the first search module includes:
[0141] A first acquisition unit, configured to acquire identification information of the Fragment to which the target View belongs, recorded in the target View;
[0142] A search unit, configured to search an offset address bound to the identification information of the Fragment in an attribute field of the target View;
[0143] A determining unit, configured to determine that the offset address of the Fragment in the application program has not been found if the offset address bound to the identification information of the Fragment has not been found;
[0144] The second acquisition unit is configured to, when an offset address bound to the identification information of the Fragment is found, acquire the offset address of the Fragment in the application according to the found offset address.
[0145] In an optional implementation, the Fragment includes multiple View-Models, and different View-Models include data that needs to be rendered by different Views in the Fragment;
[0146] The calling module is specifically used to call the data that needs to be rendered of the target View from the View-Model corresponding to the target View at least according to the offset address of the Fragment in the application and the identification information of the target View.
[0147] In the present application, for a target View among multiple cascaded Views, when the target View needs to render data, the offset address of the Fragment in the application is searched in the attribute field of the target View. If the offset address of the Fragment in the application is not found in the attribute field of the target View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the target View among the multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views. At least the data that needs to be rendered of the target View is retrieved from the View-Model based on the offset address of the Fragment in the application. The retrieved data is rendered based on the target View.
[0148] Through this application, it is supported to encapsulate "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View of the cascaded View in multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order of multiple cascaded Views" into a calling function during the application development stage. The calling function can be called by the View, and the calling function has a function name.
[0149] Secondly, when developing an application, the offset address of the Fragment in the application can be stored in the attribute field of the View that is the first in the cascading order of multiple cascaded Views.
[0150] In this way, for any View in the Fragment, if the View needs to retrieve the data that needs to be rendered by the View from the View-Model according to the offset address of the Fragment in the application, the developer can directly introduce the function name of the function in the View when writing the computer program code of the Fragment, so that the View can have the function of "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views." That is, the View can have the function of obtaining the offset address of the Fragment in the application.
[0151] The same is true for every other View in the Fragment.
[0152] In this way, developers can develop a call function and reuse the call function in multiple Views in the Fragment to achieve the function of obtaining the offset address of the Fragment in the application for multiple Views. The same is true for other Fragments in the application. In other words, other Fragments can reuse the call function.
[0153] In this way, through this application, the workload of developers can be reduced, the labor cost can be reduced, the amount of code in the Fragment can be reduced, the complexity of the Fragment code can be reduced, and the subsequent maintenance cost can be reduced.
[0154] Reference Figure 3 , shows a structural block diagram of a data processing device of the present application, wherein a terminal has an application development environment, wherein a fragment of the application has been developed in the development environment, wherein the fragment includes a view model View-Model and a plurality of cascaded views View, wherein each View is used to render data, wherein the View-Model includes data that the View needs to render, and wherein the device includes:
[0155] An adding module 21 is used to add a calling function in a target View that needs to render data among the cascaded multiple Views according to a writing operation input by a developer;
[0156] A determination module 22, used for determining a View with a first cascade order among a plurality of cascaded Views during the process of compiling the Fragment developed in the development environment, and a storage module 23, used for storing an offset address of the Fragment in the application in an attribute field of the View with a first cascade order;
[0157] Among them, the calling function is used to: search for the offset address of the Fragment in the application in the attribute field of the View; if the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is first in the cascade order among the multiple cascaded Views.
[0158] In an optional implementation, the storage module includes:
[0159] A third acquisition unit, used to acquire identification information of the Fragment;
[0160] A binding unit, used to bind the identification information of the Fragment and the offset address of the Fragment in the application;
[0161] The storage unit is used to store the identification information of the bound Fragment and the offset address of the Fragment in the application program in the attribute field of the View that is first in the cascading order.
[0162] Through this application, it is supported to encapsulate "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper-level View of the cascaded View in multiple cascaded Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order of multiple cascaded Views" into a calling function during the application development stage. The calling function can be called by the View, and the calling function has a function name.
[0163] Secondly, when developing an application, the offset address of the Fragment in the application can be stored in the attribute field of the View that is the first in the cascading order of multiple cascaded Views.
[0164] In this way, for any View in the Fragment, if the View needs to retrieve the data that needs to be rendered by the View from the View-Model according to the offset address of the Fragment in the application, the developer can directly introduce the function name of the function in the View when writing the computer program code of the Fragment, so that the View can have the function of "searching for the offset address of the Fragment in the application in the attribute field of the View. If the offset address of the Fragment in the application is not found in the attribute field of the View, the offset address of the Fragment in the application is searched in the attribute field of the upper-level View of the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the multiple cascaded Views." That is, the View can have the function of obtaining the offset address of the Fragment in the application.
[0165] The same is true for every other View in the Fragment.
[0166] In this way, developers can develop a call function and reuse the call function in multiple Views in the Fragment to achieve the function of obtaining the offset address of the Fragment in the application for multiple Views. The same is true for other Fragments in the application. In other words, other Fragments can reuse the call function.
[0167] In this way, through this application, the workload of developers can be reduced, the labor cost can be reduced, the amount of code in the Fragment can be reduced, the complexity of the Fragment code can be reduced, and the subsequent maintenance cost can be reduced.
[0168] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0169] Optionally, an embodiment of the present invention further provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned data processing method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0170] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned data processing method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0171] Figure 4 800 is a block diagram of an electronic device 800 shown in the present application. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0172] Reference Figure 4 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .
[0173] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0174] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, images, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0175] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.
[0176] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0177] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.
[0178] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.
[0179] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0180] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast operation information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0181] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0182] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the instructions can be executed by a processor 820 of an electronic device 800 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0183] Figure 51 is a block diagram of an electronic device 1900 shown in the present application. For example, the electronic device 1900 may be provided as a server.
[0184] Reference Figure 5 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0185] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output (I / O) interface 1958. The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™ or the like.
[0186] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0187] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0188] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
[0189] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of the present invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0190] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0191] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0192] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0193] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0194] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.
[0195] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A data processing method, characterized in that: The method is applied to a terminal, wherein an application is installed on the terminal, wherein the application has a fragment Fragment, wherein the Fragment includes a view model View-Model and multiple cascaded views View, wherein an attribute field in a View that is the first in the cascade order among the multiple cascaded views stores an offset address of the Fragment in the application, and the View-Model includes data that the View needs to render, and wherein the method includes: For a target View in the cascaded multiple Views, when the target View needs to render data, searching the offset address of the Fragment in the application in the attribute field of the target View; If the offset address of the Fragment in the application is not found in the attribute field of the target View, the offset address of the Fragment in the application is found in the attribute field of the upper-level View of the target View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views; Retrieving data that needs to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application; Rendering the retrieved data based on the target View; The searching the offset address of the Fragment in the application in the attribute field of the target View includes: Obtain identification information of the Fragment to which the target View belongs, which is recorded in the target View; Searching the attribute field of the target View for the offset address bound to the identification information of the Fragment; If the offset address bound to the identification information of the Fragment is not found, determining that the offset address of the Fragment in the application is not found; Alternatively, when the offset address bound to the identification information of the Fragment is found, the offset address of the Fragment in the application is obtained according to the found offset address.
2. The method according to claim 1, characterized in that The Fragment includes multiple View-Models, and different View-Models include data that different Views in the Fragment need to render; The step of retrieving data that needs to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application program includes: At least according to the offset address of the Fragment in the application and the identification information of the target View, the data that needs to be rendered of the target View is retrieved from the View-Model corresponding to the target View.
3. A data processing method, characterized in that: The terminal has an application development environment, in which a fragment Fragment of the application has been developed, the Fragment includes a view model View-Model and a plurality of cascaded views View, each View is used to render data, and the View-Model includes data that the View needs to render, and the method includes: For the target View that needs to render data in the cascaded multiple Views, add a calling function in the target View according to the writing operation input by the developer; And, in the process of compiling the Fragment developed in the development environment, determining a View that is first in the cascade order among the multiple cascaded Views, and storing an offset address of the Fragment in the application in an attribute field in the View that is first in the cascade order; The calling function is used to: search for the offset address of the Fragment in the application in the attribute field of the View, and if the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper level View of the cascaded View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views; The step of searching the offset address of the Fragment in the application program in the attribute field of the View includes: Obtain identification information of the Fragment to which the View belongs, which is recorded in the View; Searching the offset address bound to the identification information of the Fragment in the attribute field of the View; If the offset address bound to the identification information of the Fragment is not found, determining that the offset address of the Fragment in the application is not found; Alternatively, when the offset address bound to the identification information of the Fragment is found, the offset address of the Fragment in the application is obtained according to the found offset address.
4. The method according to claim 3, characterized in that The offset address of the Fragment in the application is stored in the attribute field in the View that is first in the cascading order, including: Obtain identification information of the Fragment; Binding the identification information of the Fragment and the offset address of the Fragment in the application; In the attribute field of the View that is first in the cascading order, the identification information of the bound Fragment and the offset address of the Fragment in the application are stored.
5. A data processing device, characterized in that: The device is applied to a terminal, wherein an application is installed on the terminal, wherein the application has a fragment Fragment, wherein the Fragment includes a view model View-Model and a plurality of cascaded views View, wherein an offset address of the Fragment in the application is stored in an attribute field of a View that is the first in the cascade order among the plurality of cascaded views, wherein the View-Model includes data that the View needs to render, and wherein the device includes: A first search module is used for searching, for a target View in the cascaded multiple Views, an offset address of the Fragment in the application in an attribute field of the target View when the target View needs to render data; A second search module is used for searching the offset address of the Fragment in the application in the attribute field of the upper-level View of the target View in the cascaded multiple Views if the offset address of the Fragment in the application is not found in the attribute field of the target View, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views; A calling module, used for calling the data to be rendered of the target View from the View-Model at least according to the offset address of the Fragment in the application; A rendering module, used for rendering the retrieved data based on the target View; The first search module includes: A first acquisition unit, configured to acquire identification information of the Fragment to which the target View belongs, recorded in the target View; A search unit, configured to search an offset address bound to the identification information of the Fragment in an attribute field of the target View; a determining unit, configured to determine that the offset address of the Fragment in the application program has not been found if the offset address bound to the identification information of the Fragment has not been found; The second acquisition unit is used to acquire the offset address of the Fragment in the application according to the found offset address when the offset address bound to the identification information of the Fragment is found.
6. The device according to claim 5, characterized in that The Fragment includes multiple View-Models, and different View-Models include data that different Views in the Fragment need to render; The calling module is specifically used to call the data that needs to be rendered of the target View from the View-Model corresponding to the target View at least according to the offset address of the Fragment in the application and the identification information of the target View.
7. A data processing device, characterized in that: The terminal has an application development environment, in which a fragment Fragment of the application has been developed, wherein the Fragment includes a view model View-Model and a plurality of cascaded views View, each View is used to render data, and the View-Model includes data that the View needs to render. The device includes: Add a module for adding a calling function in a target View that needs to render data among multiple cascaded Views according to the writing operation input by the developer; A determination module, used for determining a View with a first cascade order among a plurality of cascaded Views during the process of compiling the Fragment developed in the development environment, and a storage module, used for storing an offset address of the Fragment in the application in an attribute field of the View with a first cascade order; The calling function is used to: search for the offset address of the Fragment in the application in the attribute field of the View, and if the offset address of the Fragment in the application is not found in the attribute field of the View, search for the offset address of the Fragment in the application in the attribute field of the upper level View of the cascaded View in the cascaded multiple Views, and so on, until the offset address of the Fragment in the application is found in the attribute field of the View that is the first in the cascade order among the cascaded multiple Views; The step of searching the offset address of the Fragment in the application program in the attribute field of the View includes: Obtain identification information of the Fragment to which the View belongs, which is recorded in the View; Searching the offset address bound to the identification information of the Fragment in the attribute field of the View; If the offset address bound to the identification information of the Fragment is not found, determining that the offset address of the Fragment in the application is not found; Alternatively, when the offset address bound to the identification information of the Fragment is found, the offset address of the Fragment in the application is obtained according to the found offset address.
8. The device according to claim 7, characterized in that The storage module comprises: A third acquisition unit, used to acquire identification information of the Fragment; A binding unit, used to bind the identification information of the Fragment and the offset address of the Fragment in the application; The storage unit is used to store the identification information of the bound Fragment and the offset address of the Fragment in the application program in the attribute field of the View that is first in the cascading order.
9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the data processing method according to any one of claims 1 to 2 when executed by the processor.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data processing method according to any one of claims 1 to 2 are implemented.
11. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the data processing method according to any one of claims 3 to 4 when executed by the processor.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the data processing method according to any one of claims 3 to 4 are implemented.
