Commit 3d08268f by 罗翻

测试

parent cbed9b96
...@@ -119,6 +119,7 @@ dependencies { ...@@ -119,6 +119,7 @@ dependencies {
kapt project(':apt') kapt project(':apt')
compile project(':annotation_lib') compile project(':annotation_lib')
compile project(':baselibrary')
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
kapt "com.android.databinding:compiler:$gradle_version" kapt "com.android.databinding:compiler:$gradle_version"
} }
......
package com.dayu.bigfish.api; package com.dayu.bigfish.api;
import com.dayu.base.api.BaseResponse;
import com.dayu.bigfish.Constants; import com.dayu.bigfish.Constants;
import com.dayu.bigfish.base.BasePageBean; import com.dayu.bigfish.base.BasePageBean;
import com.dayu.bigfish.base.BaseResponse;
import com.dayu.bigfish.bean.AccountBalance; import com.dayu.bigfish.bean.AccountBalance;
import com.dayu.bigfish.bean.AlipayInfo; import com.dayu.bigfish.bean.AlipayInfo;
import com.dayu.bigfish.bean.EngineerInfo; import com.dayu.bigfish.bean.EngineerInfo;
......
...@@ -30,9 +30,9 @@ import retrofit2.converter.gson.GsonConverterFactory; ...@@ -30,9 +30,9 @@ import retrofit2.converter.gson.GsonConverterFactory;
* Created by luofan on 2017/11/09. * Created by luofan on 2017/11/09.
*/ */
public class Api { public class Api {
private static Retrofit retrofit; private static Retrofit mRetrofit;
private static final int DEFAULT_TIMEOUT = 60; private static final int DEFAULT_TIMEOUT = 60;
private static Retrofit downloadRetrofit; private static Retrofit mDownloadRetrofit;
/** /**
* 普通retrofit. * 普通retrofit.
...@@ -40,7 +40,7 @@ public class Api { ...@@ -40,7 +40,7 @@ public class Api {
* @return * @return
*/ */
public static <T> T getService(Class<T> cls) { public static <T> T getService(Class<T> cls) {
return getRetrofit().create(cls); return getmRetrofit().create(cls);
} }
/** /**
...@@ -48,22 +48,22 @@ public class Api { ...@@ -48,22 +48,22 @@ public class Api {
* *
* @return * @return
*/ */
public static APIService getDownloadService() { public static <T> T getDownloadService(Class<T> cls) {
return getDownloadRetrofit().create(APIService.class); return getmDownloadRetrofit().create(cls);
} }
private static Retrofit getRetrofit() { private static Retrofit getmRetrofit() {
if (retrofit == null) { if (mRetrofit == null) {
retrofit = getRetrofit(""); mRetrofit = getRetrofit("");
} }
return retrofit; return mRetrofit;
} }
private static Retrofit getDownloadRetrofit() { private static Retrofit getmDownloadRetrofit() {
if (downloadRetrofit == null) { if (mDownloadRetrofit == null) {
downloadRetrofit = getRetrofit("download"); mDownloadRetrofit = getRetrofit("download");
} }
return downloadRetrofit; return mDownloadRetrofit;
} }
private static Retrofit getRetrofit(String type) { private static Retrofit getRetrofit(String type) {
......
...@@ -2,6 +2,7 @@ package com.dayu.bigfish.utils.managers; ...@@ -2,6 +2,7 @@ package com.dayu.bigfish.utils.managers;
import android.content.Context; import android.content.Context;
import com.dayu.bigfish.api.APIService;
import com.dayu.bigfish.api.Api; import com.dayu.bigfish.api.Api;
import com.dayu.bigfish.ui.listener.onDownloadListener; import com.dayu.bigfish.ui.listener.onDownloadListener;
...@@ -33,7 +34,7 @@ public class DownloadManager { ...@@ -33,7 +34,7 @@ public class DownloadManager {
* @param cd 订阅关系集合,在数据传输完毕时解除订阅 * @param cd 订阅关系集合,在数据传输完毕时解除订阅
*/ */
public static void download(final Context context, final String url, final String apkPath, final CompositeDisposable cd, onDownloadListener listener) { 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) .map(ResponseBody::source)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(Schedulers.io()) .observeOn(Schedulers.io())
......
...@@ -32,6 +32,13 @@ dependencies { ...@@ -32,6 +32,13 @@ dependencies {
androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.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