Code Monkey home page Code Monkey logo

kotlinmvpexample's Introduction

KotlinMvpExample

一个kotlin+mvp+retrofit+Rxjava的开发基础lib

项目介绍

  • 最近对项目进行了优化,之前写的代码有点小low,网络方面也进行了优化,并且上传到了jcenter库,可以直接添加依赖进行使用了,具体的介绍请移步博客查看,当然优化的内容博客里面并没有介绍

  • 博客地址https://blog.csdn.net/villa_mou/article/details/81185903

具体使用:

				implementation 'com.mou:mvp:1.0.0'

ps:如果直接添加依赖下载不下来,可以先添加仓库 : maven { url 'https://dl.bintray.com/mouxuefei/maven' }

优化内容

1,网络请求方面进行了优化处理

具体使用如下:

   mModel?.getMainData()
            ?.bindDialogAndDisposable(mView, mModel)
            ?.onResult {

            }

或者

   mModel?.getMainData()
            ?.bindDialog(mView)
            ?.bindDisposable(mModel)
            ?.onResult {

            }

或者

 mModel?.getMainData()?.mSubscribe(mView,mModel){
        
    }

都是可行的,只是进行了拆分

其中bindDisposable是肯定需要的,解决内存泄漏问题,当然有的人喜欢有autodispose也是很方便的,bindDialog代表有弹窗,不写表示没有弹窗,具体看自己的情况

2,网络配置方面进行了优化 具体如下:

object MainRetrofit : RetrofitFactory<MainApi>() {
override fun getBaseUrl()= "http://www.baidu.com"

override fun getHeader(builder: Request.Builder): Request.Builder {
    builder.addHeader("token","XXXXXXXXXXXXXXXXXXXXX")
    return  builder
}

override fun getApiService(): Class<MainApi> {
    return MainApi::class.java
}

}

可以配置header和baseurl

3,另外写了一个移除model的库,项目地址:https://github.com/mouxuefei/KotlinVpExample

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.