MVPFrame for Android 是一个集合了 Retrofit2 + RXJava2 + Mosby3 二次封装的MVP架构基类库,方便敏捷开发,后续会持续更新并完善。
<dependency>
<groupId>com.king.frame</groupId>
<artifactId>mvpframe</artifactId>
<version>1.0.0</version>
<type>pom</type>
</dependency>
compile 'com.king.frame:mvpframe:1.0.0'
<dependency org='com.king.frame' name='mvpframe' rev='1.0.0'>
<artifact name='$AID' ext='pom'></artifact>
</dependency>
allprojects {
repositories {
maven { url 'https://dl.bintray.com/jenly/maven' }
}
}
// Model-View-Intent
compile 'com.hannesdorfmann.mosby3:mvi:3.0.4'
// Plain MVP
compile 'com.hannesdorfmann.mosby3:mvp:3.0.4'
// MVP + ViewState support
compile 'com.hannesdorfmann.mosby3:viewstate:3.0.4'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
compile 'io.reactivex.rxjava2:rxjava:2.1.1'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.orhanobut:logger:1.15'
核心代码(在你项目的Application中的onCreate方法里面初始化)
//初始化:第一个参数是基本的Url地址,第二个参数是超时时间(单位为秒,可不填,默认为20s)
ApiManager.init(String baseUrl,int timeout);
代码示例 (示例出自于app中的Api.java)
public class Api {
private Api(){
throw new AssertionError();
}
private static ApiService getApiService(){
return ApiManager.getInstance().getApiService(ApiService.class);
}
public static void getApiAddr(String ip, SimpleCallback<IPAddress,IIPAddrView> callback){
getApiService().getIPAddr(ip)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(ApiObserver.getApiObserver(callback));
}
}
更多使用详情,请查看app中的源码使用示例
Name: Jenly
Email: [email protected] / [email protected]
CSDN: http://blog.csdn.net/jenly121
Github: https://github.com/jenly1314
微信公众号:
加入QQ群: 20867961