Commit 8f8a4292 by 霍志良

feat:热门词用新的接口实现

parent 4a0521ab
......@@ -31,6 +31,7 @@ import com.yidianling.consultant.api.IConsultantService
import com.yidianling.consultant.bean.*
import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.model.bean.FunctionWordBean
import com.yidianling.consultant.modular.utils.ConsultAssistantEntryUtils
import com.yidianling.consultant.modular.utils.TempH5RouteUtils
import com.yidianling.consultant.presenter.HotSearchPresenterImpl
......@@ -235,7 +236,9 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
private fun initData() {
initHistoryData()
mPresenter.localData(this)
val mapType = HashMap<String, Any>()
mapType["type"] = 1
mPresenter.searchHotWordData(mapType)
if (etSearch.requestFocus()) {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
val isShowing = imm.showSoftInput(etSearch, InputMethodManager.SHOW_IMPLICIT)
......@@ -254,30 +257,35 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
refreshBanner(hotSearchBean.focusList)
}
override fun requestFail() {
refreshBanner(null)
}
//刷新 热门搜索
private fun refreshHotSearchData(keywordData: MutableList<HotSearchKeyWordDataBean>?) {
if (null == keywordData || keywordData.isEmpty()) {
override fun searchHotWordData(wordList: List<FunctionWordBean>) {
//热门词搜索结果
if (null == wordList || wordList.isEmpty()) {
llHotSearch.visibility = View.GONE
return
}
llHotSearch.visibility = View.VISIBLE
flHotSearch.removeAllViews()
for (index in keywordData.indices) {
for (index in wordList.indices) {
val view = LayoutInflater.from(this)
.inflate(R.layout.consultant_item_expert_hot_search, flHotSearch, false)
view.tvHotSearch.text = keywordData[index].keyword
view.tvHotSearch.text = wordList[index].word
view.setOnClickListener {
getSearchWords(keywordData[index].keyword!!,true)
getSearchWords(wordList[index].word!!, true)
}
flHotSearch.addView(view)
}
}
override fun requestFail() {
refreshBanner(null)
}
//刷新 热门搜索
private fun refreshHotSearchData(keywordData: MutableList<HotSearchKeyWordDataBean>?) {
//旧的热门搜索
}
//刷新 本周热门专家
private fun refreshHotExpertData(hotSearchExpert: MutableList<HotSearchPopularDoctorBean>?) {
if (null == hotSearchExpert || hotSearchExpert.isEmpty()) {
......
......@@ -402,8 +402,6 @@ class ExpertSearchAdapter(
}
}
} else if (holder is FooterViewHolder) {
LogUtil.e("${listData.size}")
LogUtil.e("${hasMore}")
if (hasMore) {
holder.itemView.visibility = View.VISIBLE
holder.pbLoading.visibility = View.VISIBLE
......
package com.yidianling.consultant.contract
import android.content.Context
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.model.bean.FunctionWordBean
import io.reactivex.Observable
/**
......@@ -24,6 +26,11 @@ class IHotSearchContract {
fun searchDataResponse(hotSearchBean: HotSearchBean)
/**
* 搜索页请求热门词
*/
fun searchHotWordData(wordList: List<FunctionWordBean>)
/**
* 请求失败
*/
fun requestFail()
......@@ -31,7 +38,11 @@ class IHotSearchContract {
/**
* 联想词请求成功结果
*/
fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean)
fun getSearchWordsSuccess(
searchWordsBean: SearchWordsBean,
searchContent: String,
isClickWords: Boolean
)
}
interface Presenter : IPresenter<View> {
......@@ -46,9 +57,14 @@ class IHotSearchContract {
fun searchData()
/**
* 搜索页请求热门词
*/
fun searchHotWordData(map: HashMap<String, Any>)
/**
* 获取联想词
*/
fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean)
fun getSearchWords(map: HashMap<String, Any>, searchContent: String, isClickWords: Boolean)
}
interface Model : IModel {
......@@ -60,6 +76,11 @@ class IHotSearchContract {
/**
* 获取到联想词
*/
fun getSearchWords(map:HashMap<String,Any>): Observable<SearchWordsBean>
fun getSearchWords(map: HashMap<String, Any>): Observable<SearchWordsBean>
/**
* 搜索页请求热门词
*/
fun searchHotWordData(map: HashMap<String, Any>): Observable<BaseAPIResponse<List<FunctionWordBean>>>
}
}
\ No newline at end of file
......@@ -3,10 +3,13 @@ package com.yidianling.consultant.http.hotsearch
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.consultant.bean.FunctionWordConsultBean
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.HotSearchKeyWordDataBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.http.ExpertSearchParam
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.model.bean.FunctionWordBean
import io.reactivex.Observable
/**
......@@ -43,9 +46,13 @@ class HotSearchHttpImpl : IHotSearchHttp {
override fun searchData(): Observable<BaseAPIResponse<HotSearchBean>> {
return RxUtils.mapObservable(ExpertSearchParam(""))
.flatMap {
getSearchApi().searchPage()
}
.flatMap {
getSearchApi().searchPage()
}
}
override fun searchHotWordData(map: HashMap<String, Any>): Observable<BaseAPIResponse<List<FunctionWordBean>>> {
return getSearchApi().searchFunctionWord(map)
}
override fun getSearchWords(map: HashMap<String, Any>): Observable<BaseAPIResponse<SearchWordsBean>> {
......
......@@ -3,6 +3,7 @@ package com.yidianling.consultant.http.hotsearch
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.model.bean.FunctionWordBean
import io.reactivex.Observable
/**
......@@ -12,14 +13,19 @@ import io.reactivex.Observable
* @Company 壹点灵
* @date 2018/7/26
*/
interface IHotSearchHttp{
interface IHotSearchHttp {
/**
* 搜索页请求
*/
fun searchData(): Observable<BaseAPIResponse<HotSearchBean>>
/**
* 搜索页请求热门词
*/
fun searchHotWordData(map: HashMap<String, Any>): Observable<BaseAPIResponse<List<FunctionWordBean>>>
/**
* 搜索联想词请求
*/
fun getSearchWords(map:HashMap<String,Any>): Observable<BaseAPIResponse<SearchWordsBean>>
fun getSearchWords(map: HashMap<String, Any>): Observable<BaseAPIResponse<SearchWordsBean>>
}
\ No newline at end of file
package com.yidianling.consultant.model
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.http.hotsearch.HotSearchDataManager
import com.yidianling.consultant.model.bean.FunctionWordBean
import io.reactivex.Observable
/**
......@@ -14,12 +16,16 @@ import io.reactivex.Observable
* @Company 壹点灵
* @date 2018/7/26
*/
class HotSearchModelImpl : IHotSearchContract.Model{
class HotSearchModelImpl : IHotSearchContract.Model {
override fun searchData(): Observable<HotSearchBean> {
return HotSearchDataManager.getHttp().searchData().compose(RxUtils.resultJavaData())
}
override fun getSearchWords(map:HashMap<String,Any>): Observable<SearchWordsBean> {
override fun getSearchWords(map: HashMap<String, Any>): Observable<SearchWordsBean> {
return HotSearchDataManager.getHttp().getSearchWords(map).compose(RxUtils.resultJavaData())
}
override fun searchHotWordData(map: HashMap<String, Any>): Observable<BaseAPIResponse<List<FunctionWordBean>>> {
return HotSearchDataManager.getHttp().searchHotWordData(map)
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.text.TextUtils
import com.google.gson.Gson
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils
......@@ -13,6 +14,8 @@ import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.model.HotSearchModelImpl
import com.yidianling.consultant.model.bean.FunctionWordBean
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
......@@ -66,25 +69,43 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch
.filter { it != null }
.compose(RxLifecycleUtils.bindToLifecycle(mView!!))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.searchDataResponse(it)
YDLCacheUtils.saveHotSearchData(Gson().toJson(it))
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
mView.requestFail()
}
})
.subscribe(Consumer {
mView.searchDataResponse(it)
YDLCacheUtils.saveHotSearchData(Gson().toJson(it))
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
mView.requestFail()
}
})
}
@SuppressLint("CheckResult")
override fun searchHotWordData(map: HashMap<String, Any>) {
mModel.searchHotWordData(map).compose(RxLifecycleUtils.bindToLifecycle(mView!!))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.searchHotWordData(it.data)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
mView.requestFail()
}
})
}
@SuppressLint("CheckResult")
override fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean) {
override fun getSearchWords(
map: HashMap<String, Any>,
searchContent: String,
isClickWords: Boolean
) {
mModel.getSearchWords(map)
// .debounce(500L, TimeUnit.MILLISECONDS)
.compose(RxLifecycleUtils.bindToLifecycle(mView))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.getSearchWordsSuccess(it,searchContent,isClickWords)
mView.getSearchWordsSuccess(it, searchContent, isClickWords)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
......
......@@ -183,10 +183,10 @@ open class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterIm
}
open fun initSearchBar() {
if (!TextUtils.isEmpty(doctorName)) {
searchText = doctorName
}
home_tv.setOnClickListener { homeEvent?.searchTvClick(searchText) }
// if (!TextUtils.isEmpty(doctorName)) {
// searchText = doctorName
// }
home_tv.setOnClickListener { homeEvent?.searchTvClick(home_tv.text.toString()) }
// home_tv.text = searchText
}
......
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