Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
f81156d8
Commit
f81156d8
authored
Oct 11, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix
parent
13d4f873
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
28 deletions
+40
-28
src/main/java/tech/starwin/base/BasePresenter.java
+6
-7
src/main/java/tech/starwin/mvp/presenter/LoanPresenter.java
+14
-14
src/main/java/tech/starwin/mvp/presenter/UploadPresenter.java
+6
-6
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
+0
-0
src/main/java/tech/starwin/network/ServiceGenerator.java
+14
-1
No files found.
src/main/java/tech/starwin/base/BasePresenter.java
View file @
f81156d8
...
...
@@ -17,7 +17,6 @@ import retrofit2.Response;
import
tech.starwin.LibConfig
;
import
tech.starwin.impl.HttpObserver
;
import
tech.starwin.mvp.IView
;
import
tech.starwin.mvp.api.UploadApi
;
import
tech.starwin.network.ServiceGenerator
;
/**
...
...
@@ -26,18 +25,18 @@ import tech.starwin.network.ServiceGenerator;
public
class
BasePresenter
<
T
>
{
protected
String
TAG
;
protected
IView
view
;
protected
T
apiService
;
Class
<
T
>
serviceClz
;
/**
* 使用默认的HttpClient
*/
public
BasePresenter
(
Class
<
T
>
service
)
{
public
BasePresenter
(
Class
<
T
>
service
Clz
)
{
TAG
=
getClass
().
getSimpleName
();
apiService
=
ServiceGenerator
.
getService
(
service
)
;
this
.
serviceClz
=
serviceClz
;
}
protected
T
getApiService
()
{
return
apiService
;
return
ServiceGenerator
.
getService
(
serviceClz
)
;
}
@SuppressLint
(
"CheckResult"
)
...
...
@@ -49,7 +48,7 @@ public class BasePresenter<T> {
* 处理请求
*/
protected
<
T
>
void
handleRequest
(
Observable
<
T
>
observable
,
Observer
<
T
>
observer
)
{
if
(
DeviceInfo
.
isReviewMachine
(
LibConfig
.
getContext
()))
{
if
(
DeviceInfo
.
isReviewMachine
(
LibConfig
.
getContext
()))
{
return
;
}
observable
=
view
==
null
?
observable
:
observable
.
compose
(
view
.
bindToLifecycle
());
...
...
@@ -60,7 +59,7 @@ public class BasePresenter<T> {
protected
<
T
>
void
handleRequest
(
final
String
action
,
Observable
<
T
>
observable
)
{
if
(
DeviceInfo
.
isReviewMachine
(
LibConfig
.
getContext
()))
{
if
(
DeviceInfo
.
isReviewMachine
(
LibConfig
.
getContext
()))
{
return
;
}
observable
=
view
==
null
?
observable
:
observable
.
compose
(
view
.
bindToLifecycle
());
...
...
src/main/java/tech/starwin/mvp/presenter/LoanPresenter.java
View file @
f81156d8
...
...
@@ -34,14 +34,14 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
* 获取贷款额度、贷款周期 可选范围
*/
public
void
getLoanRange
(
String
action
)
{
handleRequest
(
action
,
apiService
.
getLoanRange
());
handleRequest
(
action
,
getApiService
()
.
getLoanRange
());
}
/**
* 验证贷款资格
*/
public
void
checkQualification
(
String
action
)
{
handleRequest
(
action
,
apiService
.
isQualification
());
handleRequest
(
action
,
getApiService
()
.
isQualification
());
}
/**
...
...
@@ -49,28 +49,28 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
*/
public
void
getCertifyProgress
(
String
action
)
{
boolean
tdFlag
=
!
TextUtils
.
isEmpty
(
LibConfig
.
TONGDUN_PARENT_KEY
);
handleRequest
(
action
,
apiService
.
getCertifyProgress
(
tdFlag
));
handleRequest
(
action
,
getApiService
()
.
getCertifyProgress
(
tdFlag
));
}
/**
* 获取贷款详情
*/
public
void
getLoanDetail
(
String
action
,
ProductBean
productBean
)
{
handleRequest
(
action
,
apiService
.
getLoanAmoutData
(
productBean
.
getCheckedAmount
(),
productBean
.
getCheckedPeriod
(),
productBean
.
getPeriodUnit
(),
productBean
.
getId
()));
handleRequest
(
action
,
getApiService
()
.
getLoanAmoutData
(
productBean
.
getCheckedAmount
(),
productBean
.
getCheckedPeriod
(),
productBean
.
getPeriodUnit
(),
productBean
.
getId
()));
}
/**
* 获取最新的贷款申请信息
*/
public
void
getLatestLoanApp
(
String
action
)
{
handleRequest
(
action
,
apiService
.
getLatestLoanApp
());
handleRequest
(
action
,
getApiService
()
.
getLatestLoanApp
());
}
/**
* 获取贷款记录
*/
public
void
getLoanHistory
(
String
action
)
{
handleRequest
(
apiService
.
getLoanAppAll
(),
new
HttpObserver
<
List
<
HistoryLoanAppInfoBean
>>()
{
handleRequest
(
getApiService
()
.
getLoanAppAll
(),
new
HttpObserver
<
List
<
HistoryLoanAppInfoBean
>>()
{
@Override
public
void
onStart
()
{
view
.
onHttpStart
(
action
,
true
);
...
...
@@ -98,7 +98,7 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
* 取消贷款
*/
public
void
cancelLoan
(
String
action
,
String
loanAppId
)
{
handleRequest
(
apiService
.
cancelLoan
(
loanAppId
),
new
HttpObserver
<
ResponseBody
>()
{
handleRequest
(
getApiService
()
.
cancelLoan
(
loanAppId
),
new
HttpObserver
<
ResponseBody
>()
{
@Override
public
void
onStart
()
{
view
.
onHttpStart
(
action
,
true
);
...
...
@@ -128,9 +128,9 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
*/
public
void
getProductList
(
String
action
)
{
if
(
TextUtils
.
isEmpty
(
LoginManager
.
get
().
getToken
()))
{
handleRequest
(
action
,
apiService
.
getProductsDefault
());
handleRequest
(
action
,
getApiService
()
.
getProductsDefault
());
}
else
{
handleRequest
(
action
,
apiService
.
getProducts
());
handleRequest
(
action
,
getApiService
()
.
getProducts
());
}
}
...
...
@@ -139,7 +139,7 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
*/
public
void
getBankList
(
String
action
)
{
handleRequest
(
action
,
apiService
.
getBankList
());
handleRequest
(
action
,
getApiService
()
.
getBankList
());
}
...
...
@@ -147,7 +147,7 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
* 申请贷款
*/
public
void
applyLoan
(
String
action
,
LatestLoanAppBean
loanInfo
)
{
Observable
<
ResponseBody
>
observable
=
apiService
.
addBank
(
loanInfo
.
getLoanAppId
(),
Observable
<
ResponseBody
>
observable
=
getApiService
()
.
addBank
(
loanInfo
.
getLoanAppId
(),
loanInfo
.
getBankCode
(),
loanInfo
.
getCardNo
(),
loanInfo
.
getApplyFor
(),
...
...
@@ -183,7 +183,7 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
* 获取付款方式
*/
public
void
getDepostMethods
(
String
action
)
{
handleRequest
(
action
,
apiService
.
getDepostMethods
());
handleRequest
(
action
,
getApiService
()
.
getDepostMethods
());
}
...
...
@@ -191,7 +191,7 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
* 是否授权数据
*/
public
void
getHarvestGrant
(
String
action
)
{
handleRequest
(
action
,
apiService
.
getHarvestGrant
());
handleRequest
(
action
,
getApiService
()
.
getHarvestGrant
());
}
...
...
@@ -200,7 +200,7 @@ public class LoanPresenter extends BasePresenter<LoanApi> {
*/
public
void
getRepayOrder
(
String
action
,
LatestLoanAppBean
loanAppBean
,
final
double
payAmount
,
final
String
repayMethodorBank
)
{
handleRequest
(
action
,
apiService
.
getRepayOrder
(
loanAppBean
.
getLoanAppId
(),
getApiService
()
.
getRepayOrder
(
loanAppBean
.
getLoanAppId
(),
"IDR"
,
repayMethodorBank
,
payAmount
...
...
src/main/java/tech/starwin/mvp/presenter/UploadPresenter.java
View file @
f81156d8
...
...
@@ -67,7 +67,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
* 身份证ocr识别,直接使用Bitmap
*/
private
void
identityOcr
(
final
String
action
,
MultipartBody
.
Part
filePart
)
{
handleRequest
(
apiService
.
identityOcr
(
filePart
),
handleRequest
(
getApiService
()
.
identityOcr
(
filePart
),
new
HttpObserver
<
OcrResultBean
>()
{
@Override
public
void
onStart
()
{
...
...
@@ -134,7 +134,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
public
void
faceVerify
(
final
String
action
,
String
androidId
,
String
faceData
,
double
amount
,
int
day
,
long
productId
,
String
method
)
{
handleRequest
(
apiService
.
faceVerify
(
getApiService
()
.
faceVerify
(
"PAYDAY"
,
amount
,
day
,
"D"
,
null
,
null
,
MultipartBodyMaker
.
makeSimplePart
(
"delta"
,
faceData
),
androidId
,
...
...
@@ -172,7 +172,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
public
void
faceVerifyWithoutSDK
(
final
String
action
,
Context
context
,
double
amount
,
int
day
,
long
productId
)
{
Observable
observable
=
Observable
.
fromArray
(
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
)
.
flatMap
((
Function
<
Integer
,
ObservableSource
<
BasicAck
>>)
integer
->
apiService
.
faceVerify
(
"PAYDAY"
,
amount
,
day
,
"D"
,
null
,
null
,
getApiService
()
.
faceVerify
(
"PAYDAY"
,
amount
,
day
,
"D"
,
null
,
null
,
MultipartBodyMaker
.
makeSimplePart
(
"delta"
,
"null"
),
AppInfoUtils
.
getAndroidID
(
context
),
productId
,
!
TextUtils
.
isEmpty
(
LibConfig
.
TONGDUN_PARENT_KEY
),
"yitu"
).
onErrorReturn
(
throwable
->
new
BasicAck
()))
...
...
@@ -210,7 +210,7 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
*/
public
void
uploadFirebaseToken
(
String
action
,
String
token
)
{
if
(!
TextUtils
.
isEmpty
(
token
))
{
handleRequest
(
action
,
apiService
.
uploadFirebaseToken
(
token
));
handleRequest
(
action
,
getApiService
()
.
uploadFirebaseToken
(
token
));
}
}
...
...
@@ -233,14 +233,14 @@ public class UploadPresenter extends BasePresenter<UploadApi> {
index
++;
}
}
handleRequest
(
action
,
apiService
.
uploadOtherPhoto
(
MultipartBodyMaker
.
makeSimplePart
(
"file"
,
file
),
"EXTRA"
,
index
,
"ADD"
));
handleRequest
(
action
,
getApiService
()
.
uploadOtherPhoto
(
MultipartBodyMaker
.
makeSimplePart
(
"file"
,
file
),
"EXTRA"
,
index
,
"ADD"
));
}
/**
* 删除其他证件照
*/
public
void
deleteOtherPhoto
(
String
action
,
int
photoIndex
)
{
handleRequest
(
action
,
apiService
.
uploadOtherPhoto
(
MultipartBodyMaker
.
makeSimplePart
(
"file"
,
"null"
),
"EXTRA"
,
photoIndex
,
"DELETE"
));
handleRequest
(
action
,
getApiService
()
.
uploadOtherPhoto
(
MultipartBodyMaker
.
makeSimplePart
(
"file"
,
"null"
),
"EXTRA"
,
photoIndex
,
"DELETE"
));
}
...
...
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
View file @
f81156d8
This diff is collapsed.
Click to expand it.
src/main/java/tech/starwin/network/ServiceGenerator.java
View file @
f81156d8
...
...
@@ -21,6 +21,7 @@ public class ServiceGenerator {
private
static
final
int
TIME_OUT
=
15
;
private
static
Map
<
String
,
Retrofit
>
retrofitMap
;
private
static
Map
<
String
,
Object
>
serviceMap
;
private
static
OkHttpClient
okHttpClient
;
static
{
...
...
@@ -59,7 +60,19 @@ public class ServiceGenerator {
.
build
();
retrofitMap
.
put
(
baseUrl
,
retrofit
);
}
return
retrofitMap
.
get
(
baseUrl
).
create
(
serviceClz
);
if
(
serviceMap
==
null
)
{
serviceMap
=
new
HashMap
<>();
}
String
key
=
baseUrl
+
serviceClz
.
getName
();
Object
service
=
serviceMap
.
get
(
key
);
if
(
service
==
null
)
{
service
=
retrofitMap
.
get
(
baseUrl
).
create
(
serviceClz
);
serviceMap
.
put
(
key
,
service
);
}
return
(
T
)
service
;
}
...
...
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