A multi-module and rapidly scalable Android application development system and method
By introducing components such as working modules, interface modules and global module routing tables in Android application development, the coupling problem between modules and Activity is solved, the independence and efficient maintenance of modules are achieved, and multi-module mutual exclusion and communication are supported. Reduces development complexity and activity burden.
Patent Information
- Application Number
- CN202411355116.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-27
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-27
AI Technical Summary
In Android multi-module application development, traditional methods lead to an increase in code coupling between modules and Activity. Module startup shutdown and communication depend on Activity, which increases the burden on Activity. In addition, authorization information and mutual exclusion relationships are difficult to implement, which easily creates bugs. .
A rapidly expandable Android application development system supporting multiple modules was designed. Through the working module, interface module, functional unit and global module routing table, independent registration, communication and mutually exclusive relationship management between modules is realized, so as to reduce the cost of the module. Activity dependency supports independent startup, shutdown and authorization management of modules.
It realizes the independence and efficient maintenance of each module, reduces the workload of developers, supports unified registration and startup shutdown methods, supports multi-module mutual exclusion and communication mechanism, separates the logic layer and UI layer, and facilitates the expansion of functions through interface design. , reduces the burden on the activity.
Smart Images

Figure CN118860375B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of Android application development, and in particular to a multi-module capable of rapidly expanding Android application development system and method. Background Art
[0002] In today's era, smart terminals are developing rapidly. The Android system has a huge market share in China. The competition in the app market is becoming increasingly fierce. The functional modules of mainstream apps are becoming more and more complex, constantly challenging the application development capabilities of developers. A mature, reliable and easy-to-maintain development framework is undoubtedly crucial for application development.
[0003] Currently, in the development of Android multi-module applications, the traditional method is mainly for engineers to manually create multiple View modules repeatedly after the Activity is started, write the business logic directly in the View and directly hold these module objects in the Activity, and the communication between modules is directly implemented using Activity forwarding.
[0004] However, the technology has the following disadvantages:
[0005] Disadvantage 1: Multiple modules are created together in Activity, which increases the code coupling between modules and Activity, is not conducive to function expansion, and makes Activity size become particularly large;
[0006] Disadvantage 2: The startup and shutdown of modules and multi-module communication are only implemented through Activity forwarding, which makes each module heavily dependent on Activity and increases the burden on Activity.
[0007] Disadvantage 3: The authorization information of the modules and the mutually exclusive relationship between multiple modules also need to be implemented by the developers themselves, which is prone to bugs.
[0008] Based on this, the present invention designs a multi-module and rapidly expandable Android application development system and method to solve the above problems. Summary of the invention
[0009] In view of the above-mentioned shortcomings of the prior art, the present invention provides an Android application development system and method that supports multiple modules and can be rapidly expanded.
[0010] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0011] A multi-module and rapidly expandable Android application development system includes at least one working module, wherein the working module is used to implement functions required by business logic and belongs to the business level;
[0012] The working module is electrically connected to an interface module, and the interface module is used to transmit working signals of the functional unit to the working module;
[0013] The interface module is electrically connected to a functional unit, which is used to help developers realize the system functions that the working module can provide and belongs to the development level;
[0014] The functional unit is electrically connected to a global module routing table, which is a globally unique static singleton in the code, including instance guides of all modules, mutually exclusive relationships between modules, and message monitoring registered between modules;
[0015] The global module routing table is electrically connected to a menu entry View, and the menu entry View is an entry interface;
[0016] Click on the instruction information of the corresponding working module in the menu entry View, and the menu entry View will pass the data information requesting the implementation of the function information of the corresponding working module to the global module routing table. The global module routing table will integrate and process the data information of the function registration, and then the global module routing table will pass the data information of the implemented function module to the functional unit. The functional unit will pass the function information to the working module through the interface module. After completing the instruction, the interface module will feedback to the functional unit, and the functional unit will feedback to the global module routing table. The global module routing table will feedback to the menu entry View. After completing the instruction, the corresponding module of the working module is registered in the functional unit.
[0017] Furthermore, there are multiple working modules, and different working modules can realize different functions. Here, one of the working modules is taken as an example. The working module includes a recording module and a module common base class. The module common base class receives the data information of the interface module and passes it to the recording module and the functional unit.
[0018] Furthermore, the interface module includes a module binding entry View interface, a module startup and shutdown interface, a module authorization interface, a module communication interface, a module mutually exclusive interface, and a module Presenter and View interface. The module binding entry View interface, the module startup and shutdown interface, the module authorization interface, the module communication interface, the module mutually exclusive interface, the module Presenter and View interface are all connected to the functional unit, and the module binding entry View interface, the module startup and shutdown interface, the module authorization interface, the module communication interface, the module mutually exclusive interface, the module Presenter and View interface are all electrically connected to the module common base class.
[0019] Furthermore, the functional unit includes a module registration functional unit, a module binding entry View functional unit, a module startup and shutdown functional unit, a module authorization functional unit, a module communication functional unit and a module mutual exclusion functional unit. The module registration functional unit, the module binding entry View functional unit, the module startup and shutdown functional unit, the module authorization functional unit, the module communication functional unit and the module mutual exclusion functional unit are all electrically connected to the global module routing table, the module registration functional unit is electrically connected to the module common base class, the module binding entry View functional unit is electrically connected to the module binding entry View interface, the module startup and shutdown functional unit is electrically connected to the module startup and shutdown interface, the module authorization functional unit is electrically connected to the module authorization interface, the module communication functional unit is electrically connected to the module communication interface, the module mutual exclusion functional unit is electrically connected to the module mutual exclusion interface, and the module Presenter and View functional unit is electrically connected to the module Presenter and View interface.
[0020] Furthermore, the module registration function unit is used for the registration method of the global module routing table, and adds itself to the global module routing table. The module registration function unit only receives the data information of the module's common base class;
[0021] The module binding entry View function unit is used to find the specified module through the global module routing table when building the menu entry View, and call bindView through the interface to allow the module to hold the menu entry View. The module binding entry View function unit passes the data information requested for binding to the module binding entry View interface. After the module binding entry View interface implements this function, it passes the completed data information to the module public base class;
[0022] The module startup and shutdown functional unit, when a module needs to be started, finds the specified module through the global module routing table, and calls goInFunc to start the module and goOutFunc to close the module through the interface. The module startup and shutdown functional unit passes the module startup and shutdown data information to the module startup and shutdown interface. After the module startup and shutdown interface implements the function, it passes the completed data information to the module common base class;
[0023] The module authorization functional unit, when it is necessary to detect the authorization status of a module, finds the specified module through the global module routing table, and calls the isSupport method through the interface. The module will return the specific authorization status implemented in this method. The module startup and shutdown functional unit will pass the data information of the request for authorization to the module authorization interface. After the module authorization interface implements this function, it will pass the completed data information to the module public base class;
[0024] Module communication functional unit, when messages need to be transmitted between modules, the receiver calls the monitoring method of the global module routing table to register the module message type that needs to be monitored, and the sender sends the specified type of message by calling the sending method of the global module routing table. The global module routing table will automatically help find the module that subscribes to this message and send it to the module communication functional unit. The module communication functional unit passes the data information of the request communication to the module communication interface. After the module communication interface implements this function, it passes the completed data information to the module public base class;
[0025] Module mutual exclusion functional unit, when mutual exclusion relationship is required between modules, the modules first need to register through the mutual exclusion relationship registration method of the global module routing table. When other modules are started, the global module routing table will be queried. If there is a mutual exclusion relationship, this method will be called to process the mutual exclusion logic. The module mutual exclusion functional unit will pass the data information of the mutual exclusion relationship to the module mutual exclusion interface. After the module mutual exclusion interface implements this function, it will pass the completed data information to the module common base class;
[0026] Module Presenter and View functional units, when a module needs to separate its logical data layer and View layer, it can implement the Presenter and View interfaces defined in the base class. If other modules need to access the Presenter or View layer of this module, they can directly call it through the interface in the global module routing table. The module Presenter and View functional units pass the data information requesting to call the Presenter and View interfaces to the module Presenter and View interfaces. After the module Presenter and View interfaces implement this function, they pass the completed data information to the module public base class.
[0027] Furthermore, the module registration functional unit is placed independently, mainly because the module registration functional unit requires the working module to inherit the entire base class and implement all functional interfaces before calling the global module routing table for registration.
[0028] Furthermore, the menu entry View includes multiple function buttons, and a recording button and an annotation button are taken as examples here. The recording button and the annotation button are both electrically connected to the global module routing table.
[0029] Furthermore, the recording button and the annotation button send data information of instructions to the global module routing table. After the global module routing table receives the command, the global module routing table sends the data information of the completed instructions to the recording button and the annotation button.
[0030] Furthermore, the functional unit includes the following functions:
[0031] Module registration function, create HomeFuncRouter, which is the only globally static singleton. It can add other module instances to its FuncList and mFuncMap members through its addMetaFunc method. In this way, HomeFuncRouter has a routing table containing all module instances, and can support fast access through the map key-value pair storage method, which is safe and efficient. Each module is constructed by inheriting AbsMetaFunc, and then it is created and added to the HomeFuncRouter module routing table when the system is initialized. Each module can directly obtain the module routing table instance through the getFuncRoute method contained in the base class AbsMetaFunc. By calling its getMetaFunc method and passing in FuncId, the specified module instance can be quickly obtained, which is convenient and fast.
[0032] The module binds the View function. When building the menu, the module's dedicated ViewId is set to the specified menu View, and then the bindView method of the module base class AbsMetaFunc is called to store the menu View reference into a weak reference WeakReference inside the module to avoid memory leaks. When the View needs to be obtained, the module calls the getFuncView method to obtain it, and can easily change the View style name and other properties;
[0033] The module startup and shutdown functions are to set the listening method for the menu View. When the user clicks the menu, the system reads the ViewId from the View, finds the module it belongs to through the module routing table, and calls its goInFunc to start the module. Calling its goOutFunc can close the module.
[0034] Module authorization configuration is implemented by overriding the isSupport method of the base class AbsMetaFunc. This method will be called when building the menu to decide whether to display the module entry;
[0035] Module communication function, the message bus is implemented by the base class AbsMetaBus of HomeFuncRouter, which contains a registration information table mMsgReceiverMap of ConcurrentHashMap type, which realizes one-to-many monitoring event registration and also supports thread-safe access; receiving messages means that the module registers the module message ID to be monitored to the event bus AbsMetaBus through the registerMetaEvent method in the base class AbsMetaFunc, and then implements the IMetaEventReceiver interface so that the module can receive and distribute messages; sending messages means that the module calls ObtainMessage in the singleton HomeFuncRoute to create a message, calls addReceiveId to configure the receiving module parameters, and then uses SendToTarget to send it to the specified module;
[0036] Module mutual exclusion function: the module adds the mutually exclusive FuncId and selfId to the mInterceptorMap of HomeFuncRoute through the addFuncInterceptor method. This table will be queried when other modules are started. If there is a mutual exclusion relationship, the onInterceptActionFunc method of the module will be called to handle the mutual exclusion logic.
[0037] The module has Presenter and View functions. The Presenter carries all the business logic of this module, and the View carries all the UI displays of this module. By implementing the Presenter interface and View interface held in AbsMetaFunc, the business logic and UI can be separated. The Presenter and View can call each other through the interface methods defined in the Contract. After the interface is established, multi-version business logic and multi-version UI can be easily expanded without affecting each other.
[0038] In order to better achieve the purpose of the present invention, the present invention also provides a method for developing an Android application that supports multiple modules and can be rapidly expanded. The implementation method for supporting multiple modules and can be rapidly deployed is specifically as follows;
[0039] Step 1: The developer imports all classes in the FuncCore directory of this system in the project, and adds the target Func that he needs to develop to the initRoute method of the singleton HomeFuncRouter;
[0040] Step 2: Create the RecordMetaFun class in the project and inherit the AbsMetaFunc base class in FuncCore;
[0041] Step 3: Rewrite the initMetaFuncData method and call the registration method RegisterMetaFuncData, passing in parameters such as funcId, funcName, funcIcon, etc., to register the function in the Func routing table, which can be used to display the function menu on the toolbar;
[0042] Step 4: Rewrite isSupport and modify the return value logic to automatically display or hide the Func menu on the menu bar based on the authorization information;
[0043] Step 5: Rewrite goInFunc in AbsMetaFunc to process the business logic after Func is started, and rewrite goOutFunc to implement the business logic of closing the Func function;
[0044] Step 6: Rewrite initMetaEvent in AbsMetaFunc, register the module ID to be monitored, and implement the business logic of processing message events in onReceiveFuncEvent;
[0045] Step 7: Rewrite the initFuncInterceptor method in AbsMetaFunc, register the mutually exclusive module ID, and implement the business logic of processing module mutual exclusion in onInterceptActionFunc;
[0046] Step 8: When instantiating the menu View in the main interface menu list, find the module instance through the singleton HomeFuncRouter and call its bindView to bind the menu View to the relevant module, so as to quickly modify the menu View properties.
[0047] The present invention has the following technical effects:
[0048] Through the development framework of the present invention, developers can quickly build a set of applications that support multiple modules, realize the complete independence of each module, support module binding with menu View, and automatically start the target module by clicking the menu, and have the advantages of high efficiency and high maintainability.
[0049] Without increasing the burden on the Activity, it supports unified registration and startup and shutdown methods, authorization, mutual exclusion of multiple modules, dedicated communication mechanism for multiple modules, separation of logic layer and UI layer, and all communications between Presenter and View layers are interface-based. The interface supports multiple inheritance, which facilitates function expansion and greatly reduces the workload of developers, allowing them to better focus their work on business logic. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0051] Figure 1 The overall block diagram of the Android application development system supporting multiple modules and capable of rapid expansion of the present invention is provided;
[0052] Figure 2 A block diagram of a working module of the present invention;
[0053] Figure 3 is a block diagram of an interface module of the present invention;
[0054] Figure 4 is a block diagram of the functional units of the present invention;
[0055] Figure 5 A block diagram of the menu entry View of the present invention;
[0056] Figure 6 The present invention provides a connection diagram of a multi-module and rapidly expandable Android application development system.
[0057] The numbers in the figure represent:
[0058] 1. Working module; 11. Recording module; 12. Module common base class; 2. Interface module; 21. Module binding entry View interface; 22. Module startup and shutdown interface; 23. Module authorization interface; 24. Module communication interface; 25. Module mutual exclusion interface; 26. Module Presenter and View interface; 3. Functional unit; 31. Module registration functional unit; 32. Module binding entry View functional unit; 33. Module startup and shutdown functional unit; 34. Module authorization functional unit; 35. Module communication functional unit; 36. Module mutual exclusion functional unit; 37. Module Presenter and View functional unit; 4. Global module routing table; 5. Menu entry View; 51. Record button; 52. Annotation button. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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.
[0060] The present invention will be further described below in conjunction with the embodiments.
[0061] Example 1
[0062] Please refer to the instruction manual Figure 1-6 , a multi-module and rapidly expandable Android application development system, comprising at least one working module 1, wherein the working module 1 is used to implement the functions required by the business logic, belonging to the business level;
[0063] The working module 1 is electrically connected to an interface module 2, and the interface module 2 is used to transmit a working signal of the functional unit 3 to the working module 1;
[0064] The interface module 2 is electrically connected to a functional unit 3, which is used to help developers realize the system functions that the working module 1 can provide, and belongs to the development level;
[0065] The functional unit 3 is electrically connected to a global module routing table 4, which is a globally unique static singleton in the code, including instance guides of all modules, mutually exclusive relationships between modules, and message monitoring registered between modules;
[0066] The global module routing table 4 is electrically connected to a menu entry View5, which is an entry interface;
[0067] Click on the instruction information of the corresponding working module 1 in the menu entry View5, and the menu entry View5 will pass the data information requesting the implementation of the function information of the corresponding working module 1 to the global module routing table 4, and the global module routing table 4 will integrate and process the data information of the function registration, and then the global module routing table 4 will pass the data information of the implemented function module to the function unit 3, and the function unit 3 will pass the function information to the working module 1 through the interface module 2. After completing the instruction, the interface module 2 will feedback to the function unit 3, and the function unit 3 will feedback to the global module routing table 4, and the global module routing table 4 will feedback to the menu entry View5. After completing the instruction, the corresponding module of the working module 1 is registered in the function unit 3.
[0068] Through this development framework, developers can quickly build a set of applications that support multiple modules, and have the advantages of high efficiency and high maintainability. Without increasing the burden of Activity (Activity means activity, which is a core component in Android applications, representing an interface and user interaction part in the application), it supports unified registration and startup and shutdown methods, authorization, multi-module mutual exclusion, multi-module dedicated communication mechanism, and separation of logic layer and UI (User Interface) layer. Presenter (Presenter is a component in a design pattern, mainly used to realize the interaction and coordination between the business logic layer and the view layer) and View layer communication are all interfaced, and the interface supports multiple inheritance, which is convenient for function expansion, greatly reducing the workload of developers, and can better focus on business logic.
[0069] Example 2
[0070] like Figure 1-6 As shown, as a preferred embodiment of the present invention, the working modules 1 are provided in plurality, and different working modules 1 can realize different functions. Here, one of the working modules 1 is taken as an example. The working module 1 includes a recording module 11 and a module common base class 12. The module common base class 12 receives data information from the interface module 2 and transmits it to the recording module 11 and the functional unit 3.
[0071] The interface module 2 includes a module binding entry View interface 21, a module startup and shutdown interface 22, a module authorization interface 23, a module communication interface 24, a module mutual exclusion interface 25 and a module Presenter and View interface 26. The module binding entry View interface 21, the module startup and shutdown interface 22, the module authorization interface 23, the module communication interface 24, the module mutual exclusion interface 25, the module Presenter and View interface 26 are all connected to the functional unit 3, and the module binding entry View interface 21, the module startup and shutdown interface 22, the module authorization interface 23, the module communication interface 24, the module mutual exclusion interface 25, the module Presenter and View interface 26 are all electrically connected to the module common base class 12.
[0072] The functional unit 3 includes a module registration functional unit 31, a module binding entry View functional unit 32, a module startup and shutdown functional unit 33, a module authorization functional unit 34, a module communication functional unit 35 and a module mutual exclusion functional unit 36. The module registration functional unit 31, the module binding entry View functional unit 32, the module startup and shutdown functional unit 33, the module authorization functional unit 34, the module communication functional unit 35 and the module mutual exclusion functional unit 36 are all electrically connected to the global module routing table 4. The module registration functional unit 31 is electrically connected to the module common base class 12, the module binding entry View functional unit 32 is electrically connected to the module binding entry View interface 21, the module startup and shutdown functional unit 33 is electrically connected to the module startup and shutdown interface 22, the module authorization functional unit 34 is electrically connected to the module authorization interface 23, the module communication functional unit 35 is electrically connected to the module communication interface 24, the module mutual exclusion functional unit 36 is electrically connected to the module mutual exclusion interface 25, and the module Presenter and View functional unit 37 is electrically connected to the module Presenter and View interface 26.
[0073] The module registration function unit 31 is used for the registration method of the global module routing table 4, and adds itself to the global module routing table 4. The module registration function unit 31 only receives the data information of the module common base class 12;
[0074] The module binding entry View function unit 32 is used for the menu entry View5. When building, it finds the specified module through the global module routing table 4, and calls bindView through the interface (an annotation provided by the Butterknife library, which can automatically bind the view in the layout file to the corresponding variable. The Butterknife library is an open source library that annotates View, resource ID and some events, etc.), so that the module can hold the menu entry View5. The module binding entry View function unit 32 passes the data information requested for binding to the module binding entry View interface 21. After the module binding entry View interface 21 implements this function, it passes the completed data information to the module common base class 12;
[0075] The module startup and shutdown functional unit 33, when it is necessary to start a module, finds the specified module through the global module routing table 4, and calls goInFunc to start the module and goOutFunc to close the module through the interface. The module startup and shutdown functional unit 33 passes the module startup and shutdown data information to the module startup and shutdown interface 22. After the module startup and shutdown interface 22 implements the function, it passes the completed data information to the module common base class 12;
[0076] The module authorization function unit 34, when it is necessary to detect the authorization status of a module, finds the specified module through the global module routing table 4, and calls the isSupport (support status of a function or feature) method through the interface. This method will be called when building a menu to determine whether to display the module entry. The module will return the specific authorization status implemented in this method. The module startup and shutdown function unit 33 passes the data information of the request for authorization to the module authorization interface 23. After the module authorization interface 23 implements this function, it passes the completed data information to the module common base class 12;
[0077] Module communication function unit 35, when messages need to be transmitted between modules, the receiver calls the monitoring method of the global module routing table 4 to register the module message type that needs to be monitored, and the sender sends the specified type of message by calling the sending method of the global module routing table 4. The global module routing table 4 will automatically help find the module that subscribes to this message and send it to the module communication function unit 35. The module communication function unit 35 passes the data information of the request for communication to the module communication interface 24. After the module communication interface 24 implements this function, it passes the completed data information to the module common base class 12;
[0078] Module mutual exclusion function unit 36, when mutual exclusion relationship is required between modules, the modules first need to register through the mutual exclusion relationship registration method of the global module routing table 4, and the global module routing table 4 will be queried when other modules are started. If there is a mutual exclusion relationship, this method will be called to process the mutual exclusion logic. The module mutual exclusion function unit 36 passes the data information of the mutual exclusion relationship to the module mutual exclusion interface 25. After the module mutual exclusion interface 25 implements this function, it passes the completed data information to the module common base class 12;
[0079] Module Presenter and View functional unit 37, when the module needs to separate its logical data layer and View layer, it can implement the Presenter and View interface defined in the base class. If other modules need to access the Presenter or View layer of this module, they can directly call it through the interface in the global module routing table 4. The module Presenter and View functional unit 37 passes the data information requesting to call the Presenter and View interface to the module Presenter and View interface 26. After the module Presenter and View interface 26 implements this function, it passes the completed data information to the module common base class 12.
[0080] The module registration functional unit 31 is placed independently, mainly because the module registration functional unit 31 requires the working module 1 to inherit the entire basic class and implement all functional interfaces before calling the global module routing table 4 for registration.
[0081] The menu entry View5 includes multiple function buttons, and a recording button 51 and an annotation button 52 are taken as examples here. The recording button 51 and the annotation button 52 are both electrically connected to the global module routing table 4.
[0082] The recording button 51 and the annotation button 52 send data information of instructions to the global module routing table 4. After the global module routing table 4 receives the command, the global module routing table 4 sends the data information of the completed instructions to the recording button 51 and the annotation button 52.
[0083] Example 3
[0084] like Figure 1-6 As shown, as a preferred embodiment of the present invention, the functional unit 3 includes the following functions:
[0085] The module registration function creates HomeFuncRouter, which is a globally unique static singleton. It can add other module instances to its own FuncList and mFuncMap members through its own addMetaFunc method, so that HomeFuncRouter has a routing table containing all module instances, and through the map (mobile application part: in the communication field, map is used to connect the distributed switching unit and the main database. The main database can dynamically store the current location and preset files of mobile network users and is required when processing incoming calls) key-value pair storage method to support fast access, safe and efficient; each module is constructed by inheriting AbsMetaFunc, and then it is created and added to the HomeFuncRouter module routing table when the system is initialized. Each module can directly obtain the module routing table instance through the getFuncRoute method contained in the base class AbsMetaFunc, and can quickly obtain the specified module instance by calling its getMetaFunc method to pass in FuncId, which is convenient and fast;
[0086] The module binds the View function. When building the menu, the module's dedicated ViewId is set to the specified menu View, and then the bindView method of the module base class AbsMetaFunc is called to store the menu View reference into a weak reference WeakReference inside the module to avoid memory leaks. When the View needs to be obtained, the module calls the getFuncView method to obtain it, and can easily change the View style name and other properties;
[0087] The module startup and shutdown functions are to set the listening method for the menu View. When the user clicks the menu, the system reads the ViewId (an integer ID used to uniquely identify the View on the interface) from the View, finds the module to which it belongs through the module routing table, and calls its goInFunc to start the module. Calling its goOutFunc can close the module.
[0088] Module authorization configuration is implemented by overriding the isSupport method of the base class AbsMetaFunc. This method will be called when building the menu to decide whether to display the module entry;
[0089] Module communication function, the message bus is implemented by the base class AbsMetaBus of HomeFuncRouter, which contains a registration information table mMsgReceiverMap of ConcurrentHashMap type, which realizes one-to-many monitoring event registration and also supports thread-safe access; receiving messages means that the module registers the module message ID to be monitored to the event bus AbsMetaBus through the registerMetaEvent method in the base class AbsMetaFunc, and then implements the IMetaEventReceiver interface so that the module can receive and distribute messages; sending messages means that the module calls ObtainMessage in the singleton HomeFuncRoute to create a message, calls addReceiveId to configure the receiving module parameters, and then uses SendToTarget to send it to the specified module;
[0090] Module mutual exclusion function: the module adds the mutually exclusive FuncId and selfId to the mInterceptorMap of HomeFuncRoute through the addFuncInterceptor method. This table will be queried when other modules are started. If there is a mutual exclusion relationship, the onInterceptActionFunc method of the module will be called to handle the mutual exclusion logic.
[0091] The module has Presenter and View functions. The Presenter carries all the business logic of this module, and the View carries all the UI displays of this module. By implementing the Presenter interface and View interface held in AbsMetaFunc, the business logic and UI can be separated. The Presenter and View can call each other through the interface methods defined in the Contract. After the interface is established, multi-version business logic and multi-version UI can be easily expanded without affecting each other.
[0092] A method for developing an Android application that supports multiple modules and can be rapidly expanded, wherein the method for implementing the method for rapidly deploying multiple modules is as follows;
[0093] Step 1: The developer imports all classes in the FuncCore directory of this system in the project, and adds the target Func that he needs to develop in the initRoute method of the singleton HomeFuncRouter, such as addMetaFunc (newRecordMetaFunc). The following steps take the creation of RecordMetaFunc as an example;
[0094] Step 2: Create the RecordMetaFun class in the project and inherit the AbsMetaFunc base class in FuncCore;
[0095] Step 3: Rewrite the initMetaFuncData method and call the registration method RegisterMetaFuncData, passing in parameters such as funcId, funcName, funcIcon, etc., to register the function in the Func routing table, which can be used to display the function menu on the toolbar;
[0096] Step 4: Rewrite isSupport and modify the return value logic to automatically display or hide the Func menu on the menu bar based on the authorization information;
[0097] Step 5: Rewrite goInFunc in AbsMetaFunc to process the business logic after Func is started, and rewrite goOutFunc to implement the business logic of closing the Func function;
[0098] Step 6: Rewrite initMetaEvent in AbsMetaFunc, register the module ID to be monitored, and implement the business logic of processing message events in onReceiveFuncEvent;
[0099] Step 7: Rewrite the initFuncInterceptor method in AbsMetaFunc, register the mutually exclusive module ID, and implement the business logic of processing module mutual exclusion in onInterceptActionFunc;
[0100] Step 8: When instantiating the menu View in the main interface menu list, find the module instance through the singleton HomeFuncRouter and call its bindView to bind the menu View to the relevant module, so as to quickly modify the menu View properties.
[0101] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A multi-module and rapidly expandable Android application development system, characterized by: It comprises at least one working module (1), wherein the working module (1) is used to implement the functions required by the business logic and belongs to the business level; The working module (1) is electrically connected to an interface module (2), and the interface module (2) is used to transmit a working signal of a functional unit (3) to the working module (1); The interface module (2) is electrically connected to a functional unit (3), and the functional unit (3) is used to help developers realize the system functions that can be provided by the working module (1), and belongs to the development level; The functional unit (3) is electrically connected to a global module routing table (4), wherein the global module routing table (4) is a globally unique static singleton in the code, and contains instance instructions for all modules, mutually exclusive relationships between modules, and message monitoring registered between modules; The global module routing table (4) is electrically connected to a menu entry View (5), and the menu entry View (5) is an entry interface; In the menu entry View (5), the instruction information of the corresponding working module (1) is clicked, and the menu entry View (5) transmits the data information of the function information of the corresponding working module (1) to the global module routing table (4). The global module routing table (4) integrates and processes the data information of the function registration, and then the global module routing table (4) transmits the data information of the implemented function module to the function unit (3). The function unit (3) transmits the function information to the working module (1) through the interface module (2). After completing the instruction, the interface module (2) feeds back to the function unit (3), and the function unit (3) feeds back to the global module routing table (4). The global module routing table (4) feeds back to the menu entry View (5). After completing the instruction, the corresponding module of the working module (1) is registered in the function unit (3). The functional unit (3) comprises a module registration functional unit (31), a module binding entry View functional unit (32), a module startup and shutdown functional unit (33), a module authorization functional unit (34), a module communication functional unit (35) and a module mutual exclusion functional unit (36); the module registration functional unit (31), the module binding entry View functional unit (32), the module startup and shutdown functional unit (33), the module authorization functional unit (34), the module communication functional unit (35) and the module mutual exclusion functional unit (36) are all electrically connected to the global module routing table (4); the module registration functional unit (31) is electrically connected to the module The block common base class (12) is electrically connected, the module binding entry View function unit (32) is electrically connected to the module binding entry View interface (21), the module startup and shutdown function unit (33) is electrically connected to the module startup and shutdown interface (22), the module authorization function unit (34) is electrically connected to the module authorization interface (23), the module communication function unit (35) is electrically connected to the module communication interface (24), the module mutual exclusion function unit (36) is electrically connected to the module mutual exclusion interface (25), and the module Presenter and View function unit (37) is electrically connected to the module Presenter and View interface (26); The module registration function unit (31) is used for the registration method of the global module routing table (4), and adds itself to the global module routing table (4). The module registration function unit (31) only receives the data information of the module common base class (12); The module binding entry View function unit (32) is used to find the specified module through the global module routing table (4) when the menu entry View (5) is constructed, and bindView is called through the interface to allow the module to hold the menu entry View (5). The module binding entry View function unit (32) passes the data information requested for binding to the module binding entry View interface (21). After the module binding entry View interface (21) implements this function, it passes the completed data information to the module common base class (12); The module startup and shutdown functional unit (33) finds the specified module through the global module routing table (4) when a module needs to be started, and calls goInFunc to start the module and goOutFunc to close the module through the interface. The module startup and shutdown functional unit (33) passes the module startup and shutdown data information to the module startup and shutdown interface (22). After the module startup and shutdown interface (22) implements the function, it passes the completed data information to the module common base class (12); The module authorization function unit (34), when it is necessary to detect the authorization status of a module, finds the specified module through the global module routing table (4), and calls the isSupport method through the interface. The module will return the specific authorization status implemented in this method. The module startup and shutdown function unit (33) passes the data information of the request for authorization to the module authorization interface (23). After the module authorization interface (23) implements this function, it passes the completed data information to the module common base class (12); The module communication function unit (35) is used to transmit messages between modules. When the modules need to transmit messages, the receiver calls the monitoring method of the global module routing table (4) to register the module message type to be monitored. The sender sends the specified type of message by calling the sending method of the global module routing table (4). The global module routing table (4) will automatically help find the module that subscribes to this message and send it to the module communication function unit (35). The module communication function unit (35) transmits the data information of the request for communication to the module communication interface (24). After the module communication interface (24) implements this function, it transmits the completed data information to the module common base class (12). Module mutual exclusion function unit (36), when mutual exclusion relationship is required between modules, the modules first need to register through the mutual exclusion relationship registration method of the global module routing table (4), and the global module routing table (4) will be queried when other modules are started. If there is a mutual exclusion relationship, this method will be called to process the mutual exclusion logic. The module mutual exclusion function unit (36) passes the data information of the mutual exclusion relationship to the module mutual exclusion interface (25), and the module mutual exclusion interface (25) passes the completed data information to the module common base class (12) after implementing this function; Module Presenter and View functional unit (37), when the module needs to separate its logical data layer and View layer, it only needs to implement the Presenter and View interface defined in the base class. If other modules need to access the Presenter or View layer of this module, they can directly call it through the interface in the global module routing table (4). The module Presenter and View functional unit (37) passes the data information requesting to call the Presenter and View interface to the module Presenter and View interface (26). After the module Presenter and View interface (26) implements this function, it passes the completed data information to the module common base class (12).
2. The multi-module and rapidly expandable Android application development system according to claim 1, characterized in that: The working module (1) comprises a recording module (11) and a module common base class (12); the module common base class (12) receives data information from the interface module (2) and transmits it to the recording module (11) and the functional unit (3).
3. The multi-module and rapidly expandable Android application development system according to claim 2, characterized in that: The interface module (2) comprises a module binding entry View interface (21), a module startup and shutdown interface (22), a module authorization interface (23), a module communication interface (24), a module mutual exclusion interface (25), and a module Presenter and View interface (26); the module binding entry View interface (21), the module startup and shutdown interface (22), the module authorization interface (23), the module communication interface (24), the module mutual exclusion interface (25), and the module Presenter and View interface (26) are all connected to the functional unit (3); and the module binding entry View interface (21), the module startup and shutdown interface (22), the module authorization interface (23), the module communication interface (24), the module mutual exclusion interface (25), and the module Presenter and View interface (26) are all electrically connected to the module common base class (12).
4. The multi-module and rapidly expandable Android application development system according to claim 3, characterized in that: The module registration functional unit (31) is placed independently, and the module registration functional unit (31) requires the working module (1) to inherit the entire basic class and implement all functional interfaces before calling the global module routing table (4) for registration.
5. The multi-module and rapidly expandable Android application development system according to claim 4, characterized in that: The menu entry View (5) comprises a recording button (51) and an annotation button (52), and the recording button (51) and the annotation button (52) are both electrically connected to the global module routing table (4).
6. The multi-module and rapidly expandable Android application development system according to claim 5, characterized in that: The recording button (51) and the annotation button (52) send data information of instructions to the global module routing table (4). After the global module routing table (4) receives the command, the global module routing table (4) sends the data information of the completed instruction to the recording button (51) and the annotation button (52).
7. The multi-module and rapidly expandable Android application development system according to claim 6, characterized in that: The functional unit (3) includes the following functions: Module registration function, create HomeFuncRouter, which is the only globally static singleton. It can add other module instances to its FuncList and mFuncMap members through its addMetaFunc method. In this way, HomeFuncRouter has a routing table containing all module instances, and can support fast access through the map key-value pair storage method, which is safe and efficient. Each module is constructed by inheriting AbsMetaFunc, and then it is created and added to the HomeFuncRouter module routing table when the system is initialized. Each module can directly obtain the module routing table instance through the getFuncRoute method contained in the base class AbsMetaFunc. By calling its getMetaFunc method and passing in FuncId, the specified module instance can be quickly obtained, which is convenient and fast. The module binds the View function. When building the menu, the module's dedicated ViewId will be set to the specified menu View, and then the bindView method of the module base class AbsMetaFunc will be called to store the menu View reference into a weak reference WeakReference inside the module to avoid memory leaks. When the View needs to be obtained, the module can call the getFuncView method to obtain it, and the View style name attribute can be easily changed; The module startup and shutdown functions are to set the listening method for the menu View. When the user clicks the menu, the system reads the ViewId from the View, finds the module to which it belongs through the module routing table, and calls its goInFunc to start the module, and calls its goOutFunc to close the module. Module authorization configuration is implemented by overriding the isSupport method of the base class AbsMetaFunc. This method will be called when building the menu to decide whether to display the module entry; Module communication function, the message bus is implemented by the base class AbsMetaBus of HomeFuncRouter, which contains a registration information table mMsgReceiverMap of ConcurrentHashMap type, which realizes one-to-many monitoring event registration and also supports thread-safe access; receiving messages means that the module registers the module message ID to be monitored to the event bus AbsMetaBus through the registerMetaEvent method in the base class AbsMetaFunc, and then implements the IMetaEventReceiver interface to enable the module to receive and distribute messages; sending messages means that the module calls ObtainMessage in the singleton HomeFuncRoute to create a message, calls addReceiveId to configure the receiving module parameters, and then uses SendToTarget to send it to the specified module; Module mutual exclusion function: the module adds the mutually exclusive FuncId and selfId to the mInterceptorMap of HomeFuncRoute through the addFuncInterceptor method. This table will be queried when other modules are started. If there is a mutual exclusion relationship, the onInterceptActionFunc method of the module will be called to handle the mutual exclusion logic. The module has Presenter and View functions. The Presenter carries all the business logic of this module, and the View carries all the UI displays of this module. By implementing the Presenter interface and View interface held in AbsMetaFunc, the business logic and UI can be separated. The Presenter and View can call each other through the interface methods defined in the Contract. After the interface is established, multi-version business logic and multi-version UI can be easily expanded without affecting each other.
8. A method for developing an Android application that supports multiple modules and can be rapidly expanded, applied to the Android application development system that supports multiple modules and can be rapidly expanded as claimed in claim 7, characterized in that: The specific implementation method of supporting rapid deployment of multiple modules is as follows: Step 1: The developer imports all classes in the FuncCore directory of this system in the project, and adds the target Func that he needs to develop to the initRoute method of the singleton HomeFuncRouter; Step 2: Create the RecordMetaFun class in the project and inherit the AbsMetaFunc base class in FuncCore; Step 3: Rewrite the initMetaFuncData method and call the registration method RegisterMetaFuncData, passing in the funcId, funcName, and funcIcon parameters to register the function in the Func routing table, which can be used to display the function menu on the toolbar; Step 4: Rewrite isSupport and modify the return value logic to automatically display or hide the Func menu on the menu bar based on the authorization information; Step 5: Rewrite goInFunc in AbsMetaFunc to process the business logic after Func is started, and rewrite goOutFunc to implement the business logic of closing the Func function; Step 6: Rewrite initMetaEvent in AbsMetaFunc, register the module ID to be monitored, and implement the business logic of processing message events in onReceiveFuncEvent; Step 7: Rewrite the initFuncInterceptor method in AbsMetaFunc, register the mutually exclusive module ID, and implement the business logic of processing module mutual exclusion in onInterceptActionFunc; Step 8: When instantiating the menu View in the main interface menu list, find the module instance through the singleton HomeFuncRouter and call its bindView to bind the menu View to the relevant module, so as to quickly modify the menu View properties.
Citation Information
Patent Citations
Android application component quick development method through route configuration
CN108563432A
Method and apparatus for routing hopping
CN108897612A
