Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
android
/
dayu
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3d08268f
authored
Feb 05, 2018
by
罗翻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
cbed9b96
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
18 deletions
app/build.gradle
app/src/main/java/com/dayu/bigfish/api/APIService.java
app/src/main/java/com/dayu/bigfish/api/Api.java
app/src/main/java/com/dayu/bigfish/utils/managers/DownloadManager.java
baselibrary/build.gradle
app/src/main/java/com/dayu/bigfish/base/BaseResponse.java → baselibrary/src/main/java/com/dayu/base/api/BaseResponse.java
app/build.gradle
View file @
3d08268f
...
@@ -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"
}
}
...
...
app/src/main/java/com/dayu/bigfish/api/APIService.java
View file @
3d08268f
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
;
...
...
app/src/main/java/com/dayu/bigfish/api/Api.java
View file @
3d08268f
...
@@ -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
r
etrofit
;
private
static
Retrofit
mR
etrofit
;
private
static
final
int
DEFAULT_TIMEOUT
=
60
;
private
static
final
int
DEFAULT_TIMEOUT
=
60
;
private
static
Retrofit
d
ownloadRetrofit
;
private
static
Retrofit
mD
ownloadRetrofit
;
/**
/**
* 普通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
get
m
Retrofit
().
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
get
DownloadRetrofit
().
create
(
APIService
.
clas
s
);
return
get
mDownloadRetrofit
().
create
(
cl
s
);
}
}
private
static
Retrofit
getRetrofit
()
{
private
static
Retrofit
get
m
Retrofit
()
{
if
(
r
etrofit
==
null
)
{
if
(
mR
etrofit
==
null
)
{
r
etrofit
=
getRetrofit
(
""
);
mR
etrofit
=
getRetrofit
(
""
);
}
}
return
r
etrofit
;
return
mR
etrofit
;
}
}
private
static
Retrofit
getDownloadRetrofit
()
{
private
static
Retrofit
get
m
DownloadRetrofit
()
{
if
(
d
ownloadRetrofit
==
null
)
{
if
(
mD
ownloadRetrofit
==
null
)
{
d
ownloadRetrofit
=
getRetrofit
(
"download"
);
mD
ownloadRetrofit
=
getRetrofit
(
"download"
);
}
}
return
d
ownloadRetrofit
;
return
mD
ownloadRetrofit
;
}
}
private
static
Retrofit
getRetrofit
(
String
type
)
{
private
static
Retrofit
getRetrofit
(
String
type
)
{
...
...
app/src/main/java/com/dayu/bigfish/utils/managers/DownloadManager.java
View file @
3d08268f
...
@@ -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
())
...
...
baselibrary/build.gradle
View file @
3d08268f
...
@@ -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'
)
}
}
app/src/main/java/com/dayu/bigfish/base
/BaseResponse.java
→
baselibrary/src/main/java/com/dayu/base/api
/BaseResponse.java
View file @
3d08268f
package
com
.
dayu
.
b
igfish
.
base
;
package
com
.
dayu
.
b
ase
.
api
;
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment