Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
fbb25365
Commit
fbb25365
authored
Dec 17, 2019
by
徐健
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
首頁mvp防止崩潰
parent
f1b324e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
28 deletions
+23
-28
BaseHomeModelImpl.kt
m-home/src/main/java/com/yidianling/home/model/BaseHomeModelImpl.kt
+0
-7
BaseHomePresenterImpl.kt
m-home/src/main/java/com/yidianling/home/presenter/BaseHomePresenterImpl.kt
+5
-9
HomePresenterImpl.kt
m-home/src/xlzx/java/com/yidianling/home/presenter/HomePresenterImpl.kt
+18
-12
No files found.
m-home/src/main/java/com/yidianling/home/model/BaseHomeModelImpl.kt
View file @
fbb25365
...
@@ -16,7 +16,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
...
@@ -16,7 +16,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
*/
override
fun
consultRequest
(
category
:
String
):
Observable
<
HomeConsultBean
>
{
override
fun
consultRequest
(
category
:
String
):
Observable
<
HomeConsultBean
>
{
return
HomeBaseHttp
.
getInstance
().
getConsultData
(
category
).
compose
(
RxUtils
.
resultJavaData
())
return
HomeBaseHttp
.
getInstance
().
getConsultData
(
category
).
compose
(
RxUtils
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
newThread
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
onErrorReturn
{
HomeConsultBean
(
true
)
}
.
onErrorReturn
{
HomeConsultBean
(
true
)
}
}
}
...
@@ -47,7 +46,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
...
@@ -47,7 +46,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
*/
override
fun
courseRequest
():
Observable
<
HomeCourseBean
>
{
override
fun
courseRequest
():
Observable
<
HomeCourseBean
>
{
return
HomeBaseHttp
.
getInstance
().
getCourseData
().
compose
(
RxUtils
.
resultJavaData
())
return
HomeBaseHttp
.
getInstance
().
getCourseData
().
compose
(
RxUtils
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
newThread
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
onErrorReturn
{
HomeCourseBean
(
true
)
}
.
onErrorReturn
{
HomeCourseBean
(
true
)
}
}
}
...
@@ -63,7 +61,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
...
@@ -63,7 +61,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
*/
override
fun
confideRequest
(
goodType
:
String
):
Observable
<
HomeConfideBean
>
{
override
fun
confideRequest
(
goodType
:
String
):
Observable
<
HomeConfideBean
>
{
return
HomeBaseHttp
.
getInstance
().
getConfideData
(
goodType
).
compose
(
RxUtils
.
resultJavaData
())
return
HomeBaseHttp
.
getInstance
().
getConfideData
(
goodType
).
compose
(
RxUtils
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
newThread
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
onErrorReturn
{
HomeConfideBean
(
true
)
}
.
onErrorReturn
{
HomeConfideBean
(
true
)
}
}
}
...
@@ -72,7 +69,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
...
@@ -72,7 +69,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
*/
override
fun
askRequest
():
Observable
<
HomeAskBean
>
{
override
fun
askRequest
():
Observable
<
HomeAskBean
>
{
return
HomeBaseHttp
.
getInstance
().
getAskData
().
compose
(
RxUtils
.
resultJavaData
())
return
HomeBaseHttp
.
getInstance
().
getAskData
().
compose
(
RxUtils
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
newThread
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
onErrorReturn
{
HomeAskBean
(
true
)
}
.
onErrorReturn
{
HomeAskBean
(
true
)
}
}
}
...
@@ -81,7 +77,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
...
@@ -81,7 +77,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
*/
override
fun
articleRequest
():
Observable
<
HomeArticleBean
>
{
override
fun
articleRequest
():
Observable
<
HomeArticleBean
>
{
return
HomeBaseHttp
.
getInstance
().
getArticleData
().
compose
(
RxUtils
.
resultJavaData
())
return
HomeBaseHttp
.
getInstance
().
getArticleData
().
compose
(
RxUtils
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
newThread
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
onErrorReturn
{
HomeArticleBean
(
true
)
}
.
onErrorReturn
{
HomeArticleBean
(
true
)
}
}
}
...
@@ -90,7 +85,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
...
@@ -90,7 +85,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
*/
override
fun
headerRequest
():
Observable
<
HomeHeaderBean
>
{
override
fun
headerRequest
():
Observable
<
HomeHeaderBean
>
{
return
HomeBaseHttp
.
getInstance
().
newHomeHeaderRequest
().
compose
(
RxUtils
.
resultJavaData
())
return
HomeBaseHttp
.
getInstance
().
newHomeHeaderRequest
().
compose
(
RxUtils
.
resultJavaData
())
.
subscribeOn
(
Schedulers
.
newThread
()).
observeOn
(
AndroidSchedulers
.
mainThread
())
.
onErrorReturn
{
HomeHeaderBean
(
true
)
}
.
onErrorReturn
{
HomeHeaderBean
(
true
)
}
}
}
}
}
\ No newline at end of file
m-home/src/main/java/com/yidianling/home/presenter/BaseHomePresenterImpl.kt
View file @
fbb25365
...
@@ -114,7 +114,7 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
...
@@ -114,7 +114,7 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
object
:
TypeToken
<
MutableList
<
HomePagerDataBean
>>()
{
object
:
TypeToken
<
MutableList
<
HomePagerDataBean
>>()
{
}.
type
}.
type
)
)
if
(
null
!=
list
&&
!
list
.
is
Empty
())
{
if
(
null
!=
list
&&
list
.
isNot
Empty
())
{
mView
.
homeDataResponse
(
list
)
mView
.
homeDataResponse
(
list
)
saveTempData
(
list
)
saveTempData
(
list
)
}
}
...
@@ -135,10 +135,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
...
@@ -135,10 +135,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
mConfideType
=
type
mConfideType
=
type
mConfideDisposable
=
mModel
.
confideRequest
(
type
)
mConfideDisposable
=
mModel
.
confideRequest
(
type
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
map
{
it
}
.
map
{
it
}
.
filter
{
true
}
.
filter
{
true
}
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
.
subscribe
(
Consumer
{
mView
.
confideDataResponse
(
it
,
selectPosition
)
mView
.
confideDataResponse
(
it
,
selectPosition
)
},
object
:
ThrowableConsumer
()
{
},
object
:
ThrowableConsumer
()
{
...
@@ -160,10 +159,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
...
@@ -160,10 +159,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
mConsultType
=
type
mConsultType
=
type
mConsultDisposable
=
mModel
.
consultRequest
(
type
)
mConsultDisposable
=
mModel
.
consultRequest
(
type
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
map
{
it
}
.
map
{
it
}
.
filter
{
true
}
.
filter
{
true
}
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
.
subscribe
(
Consumer
{
mView
.
consultDataResponse
(
it
,
selectPosition
)
mView
.
consultDataResponse
(
it
,
selectPosition
)
},
object
:
ThrowableConsumer
()
{
},
object
:
ThrowableConsumer
()
{
...
@@ -197,10 +195,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
...
@@ -197,10 +195,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
@SuppressLint
(
"CheckResult"
)
@SuppressLint
(
"CheckResult"
)
override
fun
askZan
(
position
:
Int
,
index
:
Int
,
id
:
String
)
{
override
fun
askZan
(
position
:
Int
,
index
:
Int
,
id
:
String
)
{
mModel
.
askZan
(
id
)
mModel
.
askZan
(
id
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
compose
(
RxUtils
.
netCheck
())
.
compose
(
RxUtils
.
netCheck
())
.
subscribeOn
(
Schedulers
.
io
())
.
map
{}
.
map
{}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
.
subscribe
(
Consumer
{
},
object
:
ThrowableConsumer
()
{
},
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
override
fun
accept
(
msg
:
String
)
{
...
@@ -216,10 +213,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
...
@@ -216,10 +213,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
@SuppressLint
(
"CheckResult"
)
@SuppressLint
(
"CheckResult"
)
override
fun
askFocus
(
position
:
Int
,
id
:
String
)
{
override
fun
askFocus
(
position
:
Int
,
id
:
String
)
{
mModel
.
askFocus
(
id
)
mModel
.
askFocus
(
id
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
compose
(
RxUtils
.
netCheck
())
.
compose
(
RxUtils
.
netCheck
())
.
subscribeOn
(
Schedulers
.
io
())
.
map
{}
.
map
{}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
.
subscribe
(
Consumer
{
// view.askDataResponse(it!!, position)
// view.askDataResponse(it!!, position)
},
object
:
ThrowableConsumer
()
{
},
object
:
ThrowableConsumer
()
{
...
...
m-home/src/xlzx/java/com/yidianling/home/presenter/HomePresenterImpl.kt
View file @
fbb25365
...
@@ -161,7 +161,9 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -161,7 +161,9 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
val
homeList
:
MutableList
<
HomePagerDataBean
>
=
mutableListOf
()
val
homeList
:
MutableList
<
HomePagerDataBean
>
=
mutableListOf
()
LogUtil
.
d
(
"mConsultType-loadHomeData:$mConsultType"
)
LogUtil
.
d
(
"mConsultType-loadHomeData:$mConsultType"
)
Observable
.
mergeArray
(
Observable
.
mergeArray
(
mModel
.
headerRequest
().
map
{
it
->
mModel
.
headerRequest
()
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
map
{
it
->
//首页头部数据 分类 & Banner
//首页头部数据 分类 & Banner
homeList
.
add
(
homeList
.
add
(
getHomeItemFromTempData
(
getHomeItemFromTempData
(
...
@@ -189,20 +191,24 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -189,20 +191,24 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
ModularServiceManager
.
provide
(
IConsultantService
::
class
.
java
).
setHotSearch
(
it
)
ModularServiceManager
.
provide
(
IConsultantService
::
class
.
java
).
setHotSearch
(
it
)
}
}
},
},
mModel
.
consultRequest
(
mConsultType
).
map
{
mModel
.
consultRequest
(
mConsultType
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
)).
map
{
//首页咨询数据
//首页咨询数据
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
CONSULT_VIEW
))
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
CONSULT_VIEW
))
},
},
//GoodType为空 获取默认类型
//GoodType为空 获取默认类型
mModel
.
confideRequest
(
mConfideType
).
map
{
mModel
.
confideRequest
(
mConfideType
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
)).
map
{
//首页倾述数据
//首页倾述数据
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
CONFIDE_VIEW
))
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
CONFIDE_VIEW
))
},
},
mModel
.
courseRequest
().
map
{
mModel
.
courseRequest
()
.
compose
(
RxUtils
.
applySchedulers
(
mView
)).
map
{
//首页课程数据
//首页课程数据
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
COURSE_VIEW
))
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
COURSE_VIEW
))
},
},
mModel
.
testRequest
().
map
{
mModel
.
testRequest
()
.
compose
(
RxUtils
.
applySchedulers
(
mView
)).
map
{
//首页测试数据
//首页测试数据
val
homeTestBean
=
HomeTestBean
()
val
homeTestBean
=
HomeTestBean
()
homeTestBean
.
testItemList
=
it
.
data
homeTestBean
.
testItemList
=
it
.
data
...
@@ -213,7 +219,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -213,7 +219,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
)
)
)
)
},
},
mModel
.
askRequest
().
map
{
mModel
.
askRequest
()
.
compose
(
RxUtils
.
applySchedulers
(
mView
)).
map
{
//首页问答数据
//首页问答数据
homeList
.
add
(
homeList
.
add
(
getHomeItemFromTempData
(
getHomeItemFromTempData
(
...
@@ -222,7 +229,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -222,7 +229,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
)
)
)
)
},
},
mModel
.
articleRequest
().
map
{
mModel
.
articleRequest
()
.
compose
(
RxUtils
.
applySchedulers
(
mView
)).
map
{
//首页文章数据
//首页文章数据
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
ARTICLE_VIEW
))
homeList
.
add
(
getHomeItemFromTempData
(
it
,
YdlHomeViewHolderConstract
.
ARTICLE_VIEW
))
homeList
.
add
(
HomePagerDataBean
(
YdlHomeViewHolderConstract
.
FOOTER_VIEW
))
homeList
.
add
(
HomePagerDataBean
(
YdlHomeViewHolderConstract
.
FOOTER_VIEW
))
...
@@ -265,11 +273,10 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -265,11 +273,10 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
val
couponIdsStr
=
Gson
().
toJson
(
bean
)
val
couponIdsStr
=
Gson
().
toJson
(
bean
)
mModel
.
receiveCoupon
(
uid
,
couponIdsStr
)
mModel
.
receiveCoupon
(
uid
,
couponIdsStr
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
compose
(
RxUtils
.
netCheck
())
.
compose
(
RxUtils
.
netCheck
())
.
subscribeOn
(
Schedulers
.
io
())
.
doOnSubscribe
{
mView
.
showHomeProgress
()
}
.
doOnSubscribe
{
mView
.
showHomeProgress
()
}
.
doAfterTerminate
{
mView
.
dismissHomeProgress
()
}
.
doAfterTerminate
{
mView
.
dismissHomeProgress
()
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
.
subscribe
(
Consumer
{
mView
.
receiveCouponResponse
(
it
)
mView
.
receiveCouponResponse
(
it
)
},
object
:
ThrowableConsumer
()
{
},
object
:
ThrowableConsumer
()
{
...
@@ -296,9 +303,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -296,9 +303,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
private
fun
getCouponData
()
{
private
fun
getCouponData
()
{
val
uid
=
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
getUserInfo
()
?.
uid
?:
""
val
uid
=
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
getUserInfo
()
?.
uid
?:
""
mModel
.
getCoupons
(
uid
)
mModel
.
getCoupons
(
uid
)
.
compose
(
RxUtils
.
applySchedulers
(
mView
))
.
compose
(
RxUtils
.
netCheck
())
.
compose
(
RxUtils
.
netCheck
())
.
subscribeOn
(
Schedulers
.
io
())
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
.
subscribe
(
Consumer
{
hasRequestCoupon
=
true
hasRequestCoupon
=
true
...
@@ -325,7 +331,7 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
...
@@ -325,7 +331,7 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
private
fun
compareCouponTime
():
Boolean
{
private
fun
compareCouponTime
():
Boolean
{
val
simpleFormat
=
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
)
//如2016-08-10
val
simpleFormat
=
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
)
//如2016-08-10
val
uid
=
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
getUserInfo
()
?.
uid
val
uid
=
ModularServiceManager
.
provide
(
IUserService
::
class
.
java
).
getUserInfo
()
?.
uid
val
last
=
YDLCacheUtils
.
getCouponTime
(
uid
)
;
val
last
=
YDLCacheUtils
.
getCouponTime
(
uid
)
if
(
TextUtils
.
isEmpty
(
last
))
{
if
(
TextUtils
.
isEmpty
(
last
))
{
//还没有获取过优惠券,直接请求数据
//还没有获取过优惠券,直接请求数据
return
true
return
true
...
...
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