Batch processing method, device, electronic device and storage medium for custom controls

By defining an interface in the Android system to uniformly manage the extension properties and methods of custom controls, the problems of batch processing complexity and interface coupling are solved, and a simplified batch expansion process is achieved.

CN112416343BActive Publication Date: 2025-02-18GUANGZHOU XIAOPENG MOTORS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011216198.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-04
Publication Date
2025-02-18
Estimated Expiration
2040-11-04

AI Technical Summary

Technical Problem

When customizing controls in Android systems, batch processing of extended attributes and methods is complex. The existing technology requires each custom control to add the same attributes and methods respectively, resulting in a large amount of repetitive work and the interface is coupled to the original control.

Method used

Define an interface, defines the properties and methods required to be extended in the interface, and implements the interface to enable multiple custom controls to batch process the extended properties and methods. Specific implementations include using arrays to store extended attributes, defining data objects, and defining methods through predetermined keywords.

Benefits of technology

Batch processing is implemented through interfaces, reducing the repetitive workload, avoiding the coupling between interfaces and custom controls, and simplifying the expansion process of custom controls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112416343B_ABST
    Figure CN112416343B_ABST
Patent Text Reader

Abstract

The present application discloses a method for batch processing of custom controls. The batch processing method includes: defining an interface, defining the required extended properties and methods in the interface, and implementing the interface so that multiple custom controls can perform batch processing on the extended properties and methods. In the batch processing method of the implementation mode of the present application, by defining an interface, defining the required extended properties and methods in the interface, and after multiple custom controls implement the interface, the effect of subclasses inheriting parent classes in the Java programming language is achieved, thereby simply realizing that multiple custom controls can perform batch processing on the extended properties and methods. It has little impact on the control code that has been implemented in the control library, and the code is simple, and the repetitive workload is significantly reduced. In this way, the properties and methods extended by multiple custom view controls can be implemented in a simple batch processing manner. The present application also discloses a batch processing device, an electronic device, and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a batch processing method, a processing device, an electronic device and a computer storage medium for custom controls. Background Art

[0002] In the process of developing the Android system using the Java programming language, custom controls are often required, such as custom view controls, and properties and methods need to be defined. It is more complicated when a batch of custom view controls need to uniformly add the same methods and properties. In the related art, the solution of adding the same properties and methods to each custom view control is adopted, and each can only be added separately, which results in a large amount of repetitive work; or the solution of using an interface to implement the methods therein is adopted, and this solution often only declares some methods to facilitate external unified calls, but each custom view control still needs to implement these methods separately, and the interface will be coupled with the original custom control. In this way, the repetitive work of the related art is relatively large, making it more complicated to batch process the extended properties and methods of custom controls. Summary of the invention

[0003] In view of this, the present application provides a batch processing method, processing device, electronic device and computer storage medium for custom controls.

[0004] The present application provides a batch processing method for custom controls, the processing method comprising:

[0005] Define an interface;

[0006] Define the required extended properties and methods in the interface;

[0007] The interface is implemented so that multiple custom controls can process the extended properties and methods in batches.

[0008] In some implementations, the attributes and methods required to be extended are defined in the interface and include:

[0009] An array is used in the interface to store the extended properties.

[0010] In some implementations, the attributes and methods required to be extended are defined in the interface and include:

[0011] The extended attributes are defined as data objects.

[0012] In some implementations, the attributes and methods required to be extended are defined in the interface and include:

[0013] The extended method is defined in the interface by using a predetermined keyword.

[0014] In some implementations, implementing the interface so that multiple custom controls can batch process the extended properties and methods includes:

[0015] The operations of the multiple custom controls on the properties and methods of the interface are implemented through the data object and the keyword so that the multiple custom controls can perform batch processing on the extended properties and methods.

[0016] The present application provides a batch processing device for custom controls, including:

[0017] Definition module, used to define an interface;

[0018] The definition module is also used to define the required extended properties and methods in the interface;

[0019] The implementation module is used to implement the interface so that multiple custom controls can batch process the extended properties and methods.

[0020] In some embodiments, the definition module is further configured to:

[0021] defining the extended attributes as data objects;

[0022] The extended method is defined in the interface by using a predetermined keyword.

[0023] In some embodiments, the implementation module is used to:

[0024] The operations of the multiple custom controls on the properties and methods of the interface are implemented through the data object and the keyword so that the multiple custom controls can perform batch processing on the extended properties and methods.

[0025] The present application provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the batch processing method of the custom controls is implemented.

[0026] The present application provides a non-volatile computer-readable storage medium of a computer program, and when the computer program is executed by one or more processors, the batch processing method of the custom controls is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] The above and / or additional aspects and advantages of the present application will become obvious and easily understood from the description of the embodiments in conjunction with the following drawings.

[0028] Figure 1 It is a flowchart of a method for batch processing of custom controls in certain implementation modes of the present application;

[0029] Figure 2 It is a module diagram of a batch processing device for customizing controls in certain implementation modes of the present application;

[0030] Figure 3 It is a flowchart of a method for batch processing of custom controls in certain implementation modes of the present application;

[0031] Figure 4 It is a flowchart of a method for batch processing of custom controls in certain implementation modes of the present application;

[0032] Figure 5 It is a flowchart of a method for batch processing of custom controls in certain implementation modes of the present application;

[0033] Figure 6 It is an overall architecture diagram of a batch processing method for custom controls in certain implementation modes of the present application. DETAILED DESCRIPTION

[0034] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0035] See also Figure 1 , this application provides a batch processing method for custom controls, including:

[0036] S10: define an interface;

[0037] S20: Define the required extended properties and methods in the interface;

[0038] S30: Implement an interface so that multiple custom controls can process extended properties and methods in batches.

[0039] See also Figure 2 The embodiment of the present application also provides a batch processing device 100 for custom controls, and the batch processing method of custom controls in the embodiment of the present application can be implemented by the batch processing device 100. The batch processing device 100 includes a definition module 110 and an implementation module 120. S10 can be implemented by the definition module 110, and S20 can be implemented by the implementation module 120. In other words, the definition module 110 is used to define an interface and to define the required extended properties and extended methods in the interface. The implementation module 120 is used to implement the interface so that multiple custom controls can perform batch processing on the extended properties and methods.

[0040] The present application also provides an electronic device. The electronic device includes a processor. The processor is used to define an interface, and is used to define the required extended properties and methods in the interface, and is used to implement the interface so that multiple custom controls can batch process the extended properties and methods.

[0041] Specifically, the implementation method of the present application is based on the Android system and adopts the Java development language, and the custom control is a view control. In the actual development process, since the aesthetics and corresponding functions of the system's own view control often cannot meet the development requirements, it is necessary to redesign the view that meets the requirements, that is, a custom view control is needed. Common view controls, such as buttons, scroll bars, and text input boxes in the graphical user interface, need to be redesigned when the aesthetics or corresponding functions of these view controls cannot meet the requirements, then a new view control, i.e. a custom view control, needs to be designed.

[0042] Custom view controls in Java need to define properties and methods. When a batch of custom view controls need to uniformly add the same methods and properties, it is more complicated and the workload is repetitive. In the related art, the solution of adding the same properties and methods to each custom view control is adopted, and each can only be added separately, which results in a large amount of repetitive work; or the solution of implementing the interface and implementing the methods therein is adopted. This solution often only declares some methods to facilitate external unified calls, but each custom view control still needs to implement these methods separately, and the interface will be coupled with the original custom control. For example, if the interface defines 20 methods and there are 100 custom view controls to implement this interface, then these 100 custom view controls need to implement 20 methods separately, totaling 100*20=2000 methods. In this way, the workload of the related art is relatively large, making it more complicated to batch process the extended properties and methods of custom controls.

[0043] Common custom view controls, such as buttons, scroll bars, and text input boxes in graphical user interfaces, all have properties, such as length, width, height, color, etc. There are also implementation types for these properties, i.e., methods. In this implementation, when a custom control user requests to change a property value, a "Get / Set method" is called.

[0044] Customizing the view control to implement the interface can batch process the extended attributes and methods. The interface can be implemented by calling the keyword implements in the Java programming language, and the program code used in this call is relatively simple. In this way, the workload can be reduced when batch processing extended attributes and methods, and there is no need to change other codes of the self, which is more convenient to implement.

[0045] In summary, the batch processing method, processing device and electronic device of the custom control of the embodiment of the present application, by defining an interface, defining the required extended properties and methods in the interface, and implementing the interface, can enable multiple custom controls to batch process the extended properties and methods. Compared with the scheme of adding the same properties and methods to each custom control in the related art, the scheme has less impact on the control code that has been implemented in the control library, and the code is simple, and the repetitive workload is significantly reduced; compared with the scheme of using an interface to implement and implement the methods therein in the related art, the code in the custom control and the properties and methods defined in the interface are isolated, thereby ensuring the simplicity of the code in the subclass custom control, and also realizing the decoupling between the extended properties and methods and the original control. For example, if the interface defines 20 methods and there are 100 custom view controls to implement this interface, then these 100 custom view controls only need to implement them separately, achieving one inheritance, and a total of 100 inheritance methods. In this way, the properties and methods extended by multiple custom view controls can be simply processed in batches.

[0046] See also Figure 3 In some embodiments, S20 includes:

[0047] S21: Use arrays to store extended properties in interfaces.

[0048] In some implementations, the processor is configured to store the extended attributes using an array in the interface.

[0049] In some implementations, S21 may be implemented by the definition module 110. In other words, the definition module 110 is used to store extended attributes using an array in the interface.

[0050] Specifically, in this embodiment, the required extended attributes need to be stored in an appropriate manner, and an array is used here to store the extended attributes. For example, an array SparseArray can be used to store the values ​​of the extended attributes. In other examples, a suitable array such as HashMap can also be used to store the values ​​of the extended attributes.

[0051] In this way, the interface can efficiently store extended properties.

[0052] See also Figure 4 In some embodiments, S20 further includes:

[0053] S22: Define the extended attributes as data objects.

[0054] In some embodiments, the processor is configured to define the extended attributes as a data object.

[0055] In some implementations, S22 may be implemented by the definition module 110. In other words, the definition module 110 is used to define the extended attribute as a data object.

[0056] Specifically, in this embodiment, the properties that need to be extended need to be defined in an appropriate manner. In the Java data object collection, there is an inner class of the object definition class, which can define several properties, namely the properties that need to be extended in this embodiment. Due to the limitations of the Java interface itself, the properties of the interface cannot be defined directly, because it will cause the custom view control to be unable to modify these property values ​​when implementing the interface. Therefore, in this embodiment, the data object includes an inner class definition to manage all properties. In this way, the properties defined by the inner class can be modified by the custom view control, thereby giving the custom view control the ability to operate these properties and solving the problem that the properties in the interface cannot be changed.

[0057] In some embodiments, S20 further includes:

[0058] S23: defining the extended method in the interface by using a predetermined keyword.

[0059] In some embodiments, the processor is configured to define an extended method in the interface using a predetermined keyword.

[0060] In some implementations, S23 may be implemented by the definition module 110. In other words, the implementation module 110 is used to define an extended method in an interface through a predetermined keyword.

[0061] Specifically, by adding the default keyword in front of the method name of the interface, the custom view control does not implement the method of the interface. In this way, by adding the default keyword in front of each method that needs to be implemented in the interface, the custom view control does not need to implement the method in the interface while implementing the interface, thereby achieving the effect of simulating the inheritance of the subclass from the parent class in Java. It not only takes advantage of the fact that batch custom view controls can implement the interface with simple code, but also decouples the interface and custom view controls, and achieves the effect of the subclass inheriting the parent class by using the interface, and can simply implement the batch processing of extended attributes and methods of custom view controls.

[0062] See also Figure 5 In some embodiments, S30 includes:

[0063] S31: Implementing operations of multiple custom controls on the properties and methods of the interface through data objects and keywords so that the multiple custom controls can perform batch processing on the extended properties and methods.

[0064] In some implementations, the processor is used to implement operations of multiple custom controls on the properties and methods of the interface through the data object and the keyword so that the multiple custom controls can perform batch processing on the extended properties and methods.

[0065] In some implementations, S31 may be implemented by the implementation module 120. In other words, the implementation module 120 is used to implement the operations of multiple custom controls on the properties and methods of the interface through the data object and the keyword so that the multiple custom controls can perform batch processing on the extended properties and methods.

[0066] Specifically, in this embodiment, an interface is defined, in which the required extended properties and methods are defined, wherein an array such as SparseArray is used to store the values ​​of the extended properties, a data object such as an inner class is used to define the extended properties, and the keyword default is used to modify the methods to be defined, so that the custom view control implements this interface, achieving the effect of simulating the subclass inheritance of the parent class in Java. It not only utilizes the fact that batch custom view controls can implement the interface with simple code, but also decouples the interface from the custom view control, and achieves the effect of subclass inheritance of the parent class by using the interface, so that the custom view control can simply process the extended properties and methods in batches.

[0067] The present implementation is described below using a specific programming example.

[0068] First, define the properties and methods that need to be extended through the interface. These properties can be defined as internal class variables, stored and managed using SparseArray, and the default keyword is added to each method.

[0069] Here is a specific example:

[0070]

[0071]

[0072] In this example, an interface IExtendsView is defined, which contains an attribute A defined in the inner class of Attr, and then two methods setA and getA are defined through the default keyword, and attribute A is operated through the inner class mAttr and the array mMap. In this way, the interface has attribute A and methods setA / getA to change the value of attribute A. When a custom control implements this interface, it also has the right to operate attribute A. Similarly, other attributes B, C, D, E... can be added. In this way, once the custom control implements this interface, it has the right to operate A, B, C, D, E...

[0073] Secondly, for each custom control to be extended, you only need to implement the interface IExtendsView defined above through implements. In this way, you will have all the methods and properties of the extended interface without changing other code.

[0074] Here is a specific example:

[0075]

[0076] In this example, XButton is a custom view control. Before implementing IExtendsView, it does not have the right to operate the properties A, B, C, D, E... in IExtendsView. However, after implementing IExtendsView, it has all the rights to operate IExtendsView, that is, it can assign values ​​to the properties A, B, C, D, E... defined in IExtendsView at will, and these properties belong to the custom view control XButton. The custom view control XButton does not need to add additional lines of code to have the methods setA / getA, setB / getB... defined in IExtendsView. This makes the code clean and simple, and is separated from the defined properties A, B, C, D, E... and not coupled with them.

[0077] For each custom view control in the control library that needs to be extended, the interface is implemented in the same way as above, so as to achieve batch extension of properties and methods. For the overall architecture diagram, please refer to Figure 6 .

[0078] like Figure 6 As shown in the figure, there are many custom view controls such as XButton under the view. These controls inherit the extension interface IExtendsView. Similar behaviors are performed on the remaining custom view controls to achieve batch extension of attributes and methods. For example, all controls that need to be extended, such as XEditText, XSwitch, and XFrameLayout, are added with the code implements IExtendsView. Therefore, there is no need to add other attributes and methods, and all the attributes and methods defined in IExtendsView are available. The batch extension of attributes and methods of custom view controls is simply achieved.

[0079] The present application also provides a computer-readable storage medium, one or more non-volatile computer-readable storage media storing a computer program, which, when executed by one or more processors, implements the batch processing method of custom controls of any of the above embodiments.

[0080] The present application also provides an electronic device. The electronic device includes a memory and one or more processors, and one or more programs are stored in the memory and configured to be executed by the one or more processors. The program includes instructions for executing the batch processing method of the custom control described in any one of the above embodiments.

[0081] The processor can be used to provide computing and control capabilities to support the operation of the entire electronic device. The memory provides an environment for the operation of computer-readable instructions stored therein.

[0082] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related software through a computer program. The program can be stored in a non-volatile computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM), etc.

[0083] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for batch processing of custom controls, characterized in that: include: Define an interface; In the interface, an array is used to store the required extended attributes, and the extended attributes are defined as data objects, so that all attributes are managed in a manner that the data objects include inner class definitions; In the interface, the required extended methods are defined by predetermined keywords, and the default keyword is added before each method to be implemented in the interface, so that the custom control does not need to implement the methods in the interface while implementing the interface; The operations of multiple custom controls on the properties and methods of the interface are implemented through the data object and the keyword so that the multiple custom controls can perform batch processing on the extended properties and methods.

2. A batch processing device for custom controls, characterized in that: include: Definition module, used to define an interface; The definition module is further used to store the required extended properties in the interface using an array, define the extended properties as data objects, manage all properties in a manner that the data objects include inner class definitions, and define the required extended methods in the interface using predetermined keywords, and add a default keyword in front of each method to be implemented in the interface, so that the custom control does not need to implement the methods in the interface while implementing the interface; The implementation module is used to implement the operations of multiple custom controls on the properties and methods of the interface through the data object and the keyword so that the multiple custom controls can perform batch processing on the extended properties and methods.

3. An electronic device, characterized in that: It comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the batch processing method of the custom controls according to claim 1 is implemented.

4. A non-volatile computer-readable storage medium for a computer program, characterized in that: When the computer program is executed by one or more processors, the batch processing method of custom controls described in claim 1 is implemented.