Class HeadModule

  • All Implemented Interfaces:

    
    public abstract class HeadModule
    
                        

    Main class to crate a Module for Hydra

    Don't modify this code, the main app and the module need to have exactly the same library implementation in order to work, in the same way you can only implement an specific list of libraries, the main app needs to have a copy of that library in order to work.

    TODO: Add compatible libraries list

    The modules are limited in the permission they can declare, if the main app detects any other permission besides those, the module will be ignored, the admitted permissions are:

    • android.permission.INTERNET

    • android.permission.ACCESS_WIFI_STATE

    To create a module you need to create a new Application project, once created you need to create a class named Module that extends HeadModule, because the core is based in abstract implementation the minimum required functions needs to be overridden, the other overridable functions are optional (i.e., the main app will try to use the functions, but if the module doesn't implement them or any of them fail/crash it will adapt the UI to hide the related elements).

    The name of the application doesn't need any requirements, but it can be a little descriptive for the users (e.g., Hydra Module: My module name) in case of a manual uninstall, the app won't use this name internally, instead it will use the name provided in the moduleName implementation.

    <b>Sample usage</b>

    class Module: HeadModule() {
         override val moduleVersionCode: Int = BuildConfig.VERSION_CODE
         override val moduleVersionName: String = BuildConfig.VERSION_NAME
         override val baseUrl: String = "https://empty.com"
         override val moduleName: String = "Test Module"
         override val dataRepository: HeadRepository = Repository()
         override val config: HeadConfig = TestConfig()
     }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
      HeadModule()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      abstract Integer getModuleVersionCode() The module version code, usually BuildConfig.
      abstract String getModuleVersionName() The module version name, usually BuildConfig.
      abstract String getBaseUrl() Base Url of the module to check for Cloudflare anti DDoS, in case of protected url the app will try to bypass it, in case of a custom behaviour is needed for the bypass use the BypassBehavior in config implementation.
      abstract String getModuleName() The module name, it will be used internally to list the Module
      abstract HeadRepository getDataRepository() Data repository for the module, all the data required by the Main app in order to show content comes from here.
      abstract HeadConfig getConfig() The configuration for the module, here you can enable and modify the behaviour of some features in the module.
      Unit onModuleInitialize() This method is called the first time the module is initialized, here you can get/create internal databases using createRoomDatabase.
      final <T extends RoomDatabase> RoomDatabase.Builder<T> createRoomDatabase(String name, KClass<T> clazz) Create or get a RoomDatabase, it will be created in the Main app storage and will persist if the module is uninstalled, we suggest to put the database reference inside an object for easier access through the module, this method can only be used inside of onModuleInitialize.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HeadModule

        HeadModule()
    • Method Detail

      • getModuleVersionCode

         abstract Integer getModuleVersionCode()

        The module version code, usually BuildConfig.VERSION_CODE for easier implementation

      • getModuleVersionName

         abstract String getModuleVersionName()

        The module version name, usually BuildConfig.VERSION_NAME for easier implementation

      • getBaseUrl

         abstract String getBaseUrl()

        Base Url of the module to check for Cloudflare anti DDoS, in case of protected url the app will try to bypass it, in case of a custom behaviour is needed for the bypass use the BypassBehavior in config implementation.

      • getModuleName

         abstract String getModuleName()

        The module name, it will be used internally to list the Module

      • getDataRepository

         abstract HeadRepository getDataRepository()

        Data repository for the module, all the data required by the Main app in order to show content comes from here.

      • getConfig

         abstract HeadConfig getConfig()

        The configuration for the module, here you can enable and modify the behaviour of some features in the module.

      • createRoomDatabase

         final <T extends RoomDatabase> RoomDatabase.Builder<T> createRoomDatabase(String name, KClass<T> clazz)

        Create or get a RoomDatabase, it will be created in the Main app storage and will persist if the module is uninstalled, we suggest to put the database reference inside an object for easier access through the module, this method can only be used inside of onModuleInitialize.

        Parameters:
        name - The name of the database, the package name of the Module is used to create an unique name
        clazz - The class of the Database
        Returns:

        The reference of the created/gotten Database