Code Monkey home page Code Monkey logo

tobincomponent's Introduction

组件化开发

MVVM 模式 (ARouter + Jetpack + Rxjava2 + Retrofit2 + Okhttp3 + Room)

网络

项目统一使用Retrofit作为基础网络框架,基本使用如下:

// ViewModel 中请求网络
addDisposable(Box.getRetrofit(RecipeApi.class)
        .recipesClass()
        .compose(RxUtils.httpResponseTransformer())
        .subscribe(recipesClassBean -> {
            Timber.tag(TAG).i(recipesClassBean.toString());
            recipesClassLiveData.postValue(recipesClassBean);
        }, throwable ->{
            Timber.tag(TAG).i("throwable message: %s", throwable.getMessage());
            error.postValue(throwable);
        } , () -> {
            Timber.tag(TAG).e("onComplete");
            // 请求结束
        }));

用户系统

//设置进去
Box.getSessionManager().setUser(objects[0]);

//全局任意位置获取
SessionUserInfo userInfo = Box.getSessionManager().getUser();

路由

路由使用ARouter,项目地址:https://github.com/alibaba/ARouter

其他

  • 在Fragment中使用color、string等资源文件禁止直接使用getContext()获取到的上下文,而应该使用Box.class中提供的全局上下文,具体请查看Box.class
  • 全局所有配置均在GlobalConfiguration.class这个文件中

tobincomponent's People

Contributors

tobin-github avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

winfredzen

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.