Commit 2f0a352e by konghaorui

Merge branch 'feature/v3' of…

Merge branch 'feature/v3' of ssh://gitlab.yidianling.com:2224/app_android_lib/YDL-Component into feature/v3

# Conflicts:
#	m-home/src/xlzx/java/com/yidianling/home/presenter/HomePresenterImpl.kt
parents aeff1b11 3e852281
......@@ -16,7 +16,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
override fun consultRequest(category: String): Observable<HomeConsultBean> {
return HomeBaseHttp.getInstance().getConsultData(category).compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeConsultBean(true) }
}
......@@ -47,7 +46,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
override fun courseRequest(): Observable<HomeCourseBean> {
return HomeBaseHttp.getInstance().getCourseData().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeCourseBean(true) }
}
......@@ -63,7 +61,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
override fun confideRequest(goodType: String): Observable<HomeConfideBean> {
return HomeBaseHttp.getInstance().getConfideData(goodType).compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeConfideBean(true) }
}
......@@ -72,7 +69,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
override fun askRequest(): Observable<HomeAskBean> {
return HomeBaseHttp.getInstance().getAskData().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeAskBean(true) }
}
......@@ -81,7 +77,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
override fun articleRequest(): Observable<HomeArticleBean> {
return HomeBaseHttp.getInstance().getArticleData().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeArticleBean(true) }
}
......@@ -90,7 +85,6 @@ open class BaseHomeModelImpl : IHomeBaseContract.Model {
*/
override fun headerRequest(): Observable<HomeHeaderBean> {
return HomeBaseHttp.getInstance().newHomeHeaderRequest().compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread())
.onErrorReturn { HomeHeaderBean(true) }
}
}
\ No newline at end of file
......@@ -114,7 +114,7 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
object : TypeToken<MutableList<HomePagerDataBean>>() {
}.type
)
if (null != list && !list.isEmpty()) {
if (null != list && list.isNotEmpty()) {
mView.homeDataResponse(list)
saveTempData(list)
}
......@@ -135,10 +135,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
mConfideType = type
mConfideDisposable = mModel.confideRequest(type)
.compose(RxUtils.applySchedulers(mView))
.map { it }
.filter { true }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.confideDataResponse(it, selectPosition)
}, object : ThrowableConsumer() {
......@@ -160,10 +159,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
mConsultType = type
mConsultDisposable = mModel.consultRequest(type)
.compose(RxUtils.applySchedulers(mView))
.map { it }
.filter { true }
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.consultDataResponse(it, selectPosition)
}, object : ThrowableConsumer() {
......@@ -197,10 +195,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
@SuppressLint("CheckResult")
override fun askZan(position: Int, index: Int, id: String) {
mModel.askZan(id)
.compose(RxUtils.applySchedulers(mView))
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.map {}
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
......@@ -216,10 +213,9 @@ abstract class BaseHomePresenterImpl< V : IHomeBaseContract.View,M : IHomeBaseC
@SuppressLint("CheckResult")
override fun askFocus(position: Int, id: String) {
mModel.askFocus(id)
.compose(RxUtils.applySchedulers(mView))
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.map {}
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
// view.askDataResponse(it!!, position)
}, object : ThrowableConsumer() {
......
......@@ -161,7 +161,9 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
val homeList: MutableList<HomePagerDataBean> = mutableListOf()
LogUtil.d("mConsultType-loadHomeData:$mConsultType")
Observable.mergeArray(
mModel.headerRequest().map { it ->
mModel.headerRequest()
.compose(RxUtils.applySchedulers(mView))
.map { it ->
//首页头部数据 分类 & Banner
homeList.add(
getHomeItemFromTempData(
......@@ -190,20 +192,23 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
}
},
mModel.consultRequest(mConsultType)
.map {
.compose(RxUtils.applySchedulers(mView)).map {
//首页咨询数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.CONSULT_VIEW))
},
//GoodType为空 获取默认类型
mModel.confideRequest(mConfideType).map {
mModel.confideRequest(mConfideType)
.compose(RxUtils.applySchedulers(mView)).map {
//首页倾述数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.CONFIDE_VIEW))
},
mModel.courseRequest().map {
mModel.courseRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页课程数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.COURSE_VIEW))
},
mModel.testRequest().map {
mModel.testRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页测试数据
val homeTestBean = HomeTestBean()
homeTestBean.testItemList = it.data
......@@ -214,7 +219,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
)
)
},
mModel.askRequest().map {
mModel.askRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页问答数据
homeList.add(
getHomeItemFromTempData(
......@@ -223,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(HomePagerDataBean(YdlHomeViewHolderConstract.FOOTER_VIEW))
......@@ -266,11 +273,10 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
val couponIdsStr = Gson().toJson(bean)
mModel.receiveCoupon(uid, couponIdsStr)
.compose(RxUtils.applySchedulers(mView))
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.doOnSubscribe { mView.showHomeProgress() }
.doAfterTerminate { mView.dismissHomeProgress() }
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.receiveCouponResponse(it)
}, object : ThrowableConsumer() {
......@@ -297,9 +303,8 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
private fun getCouponData() {
val uid = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid ?: ""
mModel.getCoupons(uid)
.compose(RxUtils.applySchedulers(mView))
.compose(RxUtils.netCheck())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
hasRequestCoupon = true
......@@ -326,7 +331,7 @@ class HomePresenterImpl : BaseHomePresenterImpl<IHomeContract.View, IHomeContrac
private fun compareCouponTime(): Boolean {
val simpleFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")//如2016-08-10
val uid = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
val last = YDLCacheUtils.getCouponTime(uid);
val last = YDLCacheUtils.getCouponTime(uid)
if (TextUtils.isEmpty(last)) {
//还没有获取过优惠券,直接请求数据
return true
......
......@@ -3,6 +3,7 @@ package com.yidianling.home.presenter
import android.annotation.SuppressLint
import com.google.gson.Gson
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
......@@ -42,7 +43,8 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
val homeList: MutableList<HomePagerDataBean> = mutableListOf()
LogUtil.d("mConsultType-loadHomeData:$mConsultType")
Observable.mergeArray(
mModel.headerRequest().map { it ->
mModel.headerRequest()
.compose(RxUtils.applySchedulers(mView)).map { it ->
//首页头部数据 分类 & Banner
homeList.add(
getHomeItemFromTempData(
......@@ -64,20 +66,24 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
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))
},
//GoodType为空 获取默认类型
mModel.confideRequest(mConfideType).map {
mModel.confideRequest(mConfideType)
.compose(RxUtils.applySchedulers(mView)).map {
//首页倾述数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.CONFIDE_VIEW))
},
mModel.courseRequest().map {
mModel.courseRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页课程数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.COURSE_VIEW))
},
mModel.testRequest().map {
mModel.testRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页测试数据
val homeTestBean = HomeTestBean()
homeTestBean.testItemList = it.data
......@@ -88,7 +94,8 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
)
)
},
mModel.askRequest().map {
mModel.askRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页问答数据
homeList.add(
getHomeItemFromTempData(
......@@ -97,11 +104,13 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
)
)
},
mModel.museRequest().map {
mModel.museRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页冥想数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.MUSE_VIEW))
},
mModel.fmRequest().map {
mModel.fmRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页电台数据
homeList.add(
getHomeItemFromTempData(
......@@ -110,7 +119,8 @@ class HomePresenterImpl: BaseHomePresenterImpl<IHomeContract.View, IHomeContract
)
)
},
mModel.articleRequest().map {
mModel.articleRequest()
.compose(RxUtils.applySchedulers(mView)).map {
//首页文章数据
homeList.add(getHomeItemFromTempData(it, YdlHomeViewHolderConstract.ARTICLE_VIEW))
homeList.add(HomePagerDataBean(YdlHomeViewHolderConstract.FOOTER_VIEW))
......
......@@ -165,7 +165,7 @@
android:layout_marginLeft="8dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="@string/search_hint"
android:text="@string/home_search_hint"
android:textColor="#999999"
android:textSize="@dimen/platform_default_text_size_small"
android:textStyle="normal"
......
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 to comment