spi

Project Url: afirez/spi
Introduction: SPI for Android componentization.
More: Author   ReportBugs   
Tags:

中文

SPI for componentization.

Download

Add spi-gradle-plugin to your project !


buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'com.afirez.spi:spi-gradle-plugin:1.0.1'
  }
}

// in module build.gradle
apply plugin: 'com.android.application'
apply plugin: 'spi' 
// or apply plugin: 'com.afirez.spi'

Add spi to module project if needed !


implementation "com.afirez.spi:spi:1.0.1"

Usage

SPI AppLike

Make every module aware of Application lifecycle by annotated with @SPI, it will be discovered an registered to ExtensionLoader. eg:

Then, AppDelegate will load and dispatch AppLikes by ExtensionLoader.

Call AppDelegate in App and don't forget to register App to AndoridManifest.xml. Enjoy it!

SPI Actiivty

Annotate Activity with @SPI with path so that it will be discovered and registered to ExtensionLoader, then it can be loaded by ExtensionLoader with path. (if it annotated without path, path will be it's class name.)

SPI Fragment

Annotate Fragment with @SPI with path so that it will be discovered and registered to ExtensionLoader, then it can be loaded by ExtensionLoader with path. (if it annotated without path, path will be it's class name.)

SPI Provider

Annotate SpiKotlinProviderImpl with @SPI with path so that it will be discovered and registered to ExtensionLoader, then it can be loaded by ExtensionLoader with path.(if it annotated without path, path will be it's class name.)

Do more by SPI

SPI focuses on interface discovery, registration and routing table implementation. So We can collect and dispath interface like AppLike, or make a router implementation based on SPI, and etc.

Thanks

License

Copyright 2019 afirez

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apps
About Me
Google+: Trinea trinea
GitHub: Trinea