Giter VIP home page Giter VIP logo

kqsmea8 / auframe Goto Github PK

View Code? Open in Web Editor NEW

This project forked from p79n6a/auframe

0.0 0.0 0.0 64.17 MB

应对模块化开发的基础框架,网络层基于okhttp做的一个简单封装,项目分为三层:业务,基础组件,和主项目,业务依赖的library可以单独运行,打包需要更改业务项目为主项目的依赖项目,更改文件在gradle.properties isBuildModule字段

Java 100.00%

auframe's Introduction

Android模块化开发基础框架

应对模块化开发的基础框架,网络层基于okhttp做的一个简单封装,项目分为三层:业务,基础组件,和主项目,业务依赖的library可以单独运行,打包需要更改业务项目为主项目的依赖项目,更改文件在gradle.properties isBuildModule字段


Documents

关于模块化开发的具体的集成方式和项目的构建方式,请参考 https://www.aufuture.cn

Note:


Introduction

项目中模块化开发的跳转方式使用的是阿里云路由 https://github.com/alibaba/ARouter

请保证主项目中的

minSdkVersion 16
targetSdkVersion 25

与library中一致 并且上面的包也要在其中引用 不然注解无法生效

然后我们在library项目中需要跳转的Activity上添加注解

@Route(path = "/small/model/ui/testActivity")
public class TestSmallUiActivity extends Activity {

项目中的跳转示例

List<TestSmallBean> list = new ArrayList<>();
TestSmallBean bean = null;
for (int i = 0; i < 3; i++) {
    bean = new TestSmallBean();
    bean.setID(i);
    bean.setName("name is " + i);
}

ARouter.getInstance().build("/small/model/ui/testActivity")
             .withString("testString", "我是一个字符串")
             .withBoolean("testBoolean", true)
             .withSerializable("testBean", (Serializable) list)
             .navigation();

然后就是取值 取值有两种 一种是通过getIntent() 正常取值 一种是通过注解的方式

@Autowired(name = "testString")
public String mName;
@Autowired(name = "testBoolean")
public boolean mboolean;
@Autowired(name = "testBean")
public List<TestSmallBean> mData;

在onCreate中

ARouter.getInstance().inject(this);

另外一种方式为:

mData = (List<TestSmallBean>) getIntent().getSerializableExtra("testBean");

TestSmallBean写在library中 方便主项目调用

我们通过gradle.properties中的 isBuildModel 来切换 当我们在开发过程中的时候 将其设置为true

在运行工程中选择为model 那么model就可以作为独立的项目进行运行 设置为false 则项目model作为library应用于主项目

需要注意的是

  1. 我们应该尽量的规避主项目中使用到的jar资源文件出现在library中.
  2. 在library中,请尽量避免使用switch case 去判断资源文件
  3. 在声明Route Path的时候,以 "/" 开头,并保证第一个斜杠后的library名字与其他的不同

auframe's People

Contributors

jacklij avatar meburning avatar zxd13058027993 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.