Giter Site home page Giter Site logo

implloader's Introduction

ImplLoader

当一个Android工程中如果已经使用不同的module来做工程隔离。那我们就可能有这种需求,module1想实例化一个module2的类。一般要怎么解决呢?

  1. module1依赖module2
  2. module2的这个类沉到底层库,然后module1module2都使用这个底层库。
  3. ....等

ImplLoader的解决方式

只需这样使用即可:

  1. 使用@Impl标记需要被加载的类
//`module2`中的类:
@Impl(name = "module2__text_view")
public class CommonView extends AppCompatTextView {

}
  1. 使用 ImplLoader.getImpl("module2__text_view") 来获取这个类
public class Module1Page extends LinearLayout {
    public Module1Page(@NonNull Context context) {
        super(context);
        init();
    }

    private void init() {
        //根据name,获取需要加载的类
        View module1Tv = ImplLoader.getView(getContext(), "common_view");
        addView(module1Tv);
    }
}
  1. 初始化ImplLoader
    ImplLoader.init()

ImplLoader的实现以及特性

  • 使用 注解、gradle transform、asm、javapoet来实现
  • 使用简单,一个@Impl注解标注即可
  • 支持kotlin

引入ImplLoader

implloader's People

Contributors

susionsuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.