Commit 3d08268f by 罗翻

测试

parent cbed9b96
......@@ -119,6 +119,7 @@ dependencies {
kapt project(':apt')
compile project(':annotation_lib')
compile project(':baselibrary')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
kapt "com.android.databinding:compiler:$gradle_version"
}
......
package com.dayu.bigfish.api;
import com.dayu.base.api.BaseResponse;
import com.dayu.bigfish.Constants;
import com.dayu.bigfish.base.BasePageBean;
import com.dayu.bigfish.base.BaseResponse;
import com.dayu.bigfish.bean.AccountBalance;
import com.dayu.bigfish.bean.AlipayInfo;
import com.dayu.bigfish.bean.EngineerInfo;
......
......@@ -30,9 +30,9 @@ import retrofit2.converter.gson.GsonConverterFactory;
* Created by luofan on 2017/11/09.
*/
public class Api {
private static Retrofit retrofit;
private static Retrofit mRetrofit;
private static final int DEFAULT_TIMEOUT = 60;
private static Retrofit downloadRetrofit;
private static Retrofit mDownloadRetrofit;
/**
* 普通retrofit.
......@@ -40,7 +40,7 @@ public class Api {
* @return
*/
public static <T> T getService(Class<T> cls) {
return getRetrofit().create(cls);
return getmRetrofit().create(cls);
}
/**
......@@ -48,22 +48,22 @@ public class Api {
*
* @return
*/
public static APIService getDownloadService() {
return getDownloadRetrofit().create(APIService.class);
public static <T> T getDownloadService(Class<T> cls) {
return getmDownloadRetrofit().create(cls);
}
private static Retrofit getRetrofit() {
if (retrofit == null) {
retrofit = getRetrofit("");
private static Retrofit getmRetrofit() {
if (mRetrofit == null) {
mRetrofit = getRetrofit("");
}
return retrofit;
return mRetrofit;
}
private static Retrofit getDownloadRetrofit() {
if (downloadRetrofit == null) {
downloadRetrofit = getRetrofit("download");
private static Retrofit getmDownloadRetrofit() {
if (mDownloadRetrofit == null) {
mDownloadRetrofit = getRetrofit("download");
}
return downloadRetrofit;
return mDownloadRetrofit;
}
private static Retrofit getRetrofit(String type) {
......
......@@ -2,6 +2,7 @@ package com.dayu.bigfish.utils.managers;
import android.content.Context;
import com.dayu.bigfish.api.APIService;
import com.dayu.bigfish.api.Api;
import com.dayu.bigfish.ui.listener.onDownloadListener;
......@@ -33,7 +34,7 @@ public class DownloadManager {
* @param cd 订阅关系集合,在数据传输完毕时解除订阅
*/
public static void download(final Context context, final String url, final String apkPath, final CompositeDisposable cd, onDownloadListener listener) {
Api.getDownloadService().download(url)
Api.getDownloadService(APIService.class).download(url)
.map(ResponseBody::source)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
......
......@@ -32,6 +32,13 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//retrofit
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile 'io.reactivex.rxjava2:rxjava:2.0.5'
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
annotationProcessor project(':apt')
compile project(':annotation_lib')
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment