Commit 8ff37d5b by 霍志良

feat:底纹词接口对接

parent 81cf0c56
......@@ -53,18 +53,25 @@ import com.yidianling.consultant.ui.view.CategoryPopupWindow
import com.yidianling.consultant.ui.view.FilterPopupWindow
import com.yidianling.consultant.ui.view.SortPopupWindow
import com.yidianling.consultant.ui.view.topView.RecommendListView
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.consultant_activity_expert_search_list.*
import kotlinx.android.synthetic.main.consultant_item_filter_online.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.*
import kotlinx.android.synthetic.main.consultant_layout_search_toolbar.*
import org.json.JSONObject
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
@Route(path = "/consult/list")
class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPresenter>(),
View.OnClickListener, IExpertSearchView,
OnCategoriesSelectedListener, OnSortItemSelectedListener, OnFilterConfirmListener,
SwipeRefreshLayout.OnRefreshListener {
var bottomWordDisposable: Disposable? = null
private lateinit var bottomWordlist: List<FunctionWordBean>
override fun showImage(url: String?, imgView: ImageView) {
YDLImageCacheManager.showImage(ExpertSearchActivity@ this, url, imgView)
......@@ -397,7 +404,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
getRouterParam()
allFilter.showType.key = initShowType
if (!TextUtils.isEmpty(initCategory)&&initCategory!="0") {
if (!TextUtils.isEmpty(initCategory) && initCategory != "0") {
allFilter.categoryId2List.add(initCategory)
}
if (!TextUtils.isEmpty(cateName)) {
......@@ -513,6 +520,25 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
}
override fun onFunctionWordFetched(wordBean: List<FunctionWordBean>?) {
//获取底纹词
bottomWordlist = wordBean!!
if (bottomWordlist.isNullOrEmpty()) return
if (bottomWordlist.size == 1) {
tv_search_content.text = bottomWordlist[0].word
} else {
bottomWordDisposable = Observable.interval(0, 5, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
tv_search_content.text = bottomWordlist[(it % bottomWordlist.size).toInt()].word
}, {
}, {
})
}
}
/**
* 热门
*/
......@@ -1561,6 +1587,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun onDestroy() {
super.onDestroy()
mHandler = null
bottomWordDisposable?.dispose()
ConsultAssistantDialogUtils.INSTANCE.expertSearchResetStatus()
}
}
......@@ -4,6 +4,7 @@ import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Typeface
import android.os.Handler
......@@ -55,12 +56,17 @@ import com.yidianling.consultant.ui.view.SortPopupWindow
import com.yidianling.consultant.ui.view.topView.RecommendListView
import com.yidianling.home.api.event.HomeModuleTabEvent
import de.greenrobot.event.EventBus
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.consultant_activity_expert_search_list.*
import kotlinx.android.synthetic.main.consultant_item_filter_online.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.*
import kotlinx.android.synthetic.main.consultant_layout_search_toolbar.*
import org.json.JSONObject
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
@Route(path = "/consultant/consultant")
class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPresenter>(),
......@@ -72,7 +78,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
var startTime = 0L
var endTime = 0L
private var mIdssign1: String = "" // 列表埋点咨询师列表id拼接参数
var bottomWordDisposable: Disposable? = null
private lateinit var bottomWordlist: List<FunctionWordBean>
override fun layoutResId(): Int {
return R.layout.consultant_activity_expert_search_list
}
......@@ -143,6 +150,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
const val FROM_FIND_EXPERT = 1
const val FROM_ONLINE_EXPERT = 2
const val PAGE_SIZE = 15
//列表点击回来不刷新列表
var needRefresh = true;
}
......@@ -195,7 +203,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
srlContainer.isEnabled = i >= 0
})
doctorAdapter = ExpertSearchAdapter(mContext, this, doctorList,object :OnExpertClickListener{
doctorAdapter =
ExpertSearchAdapter(mContext, this, doctorList, object : OnExpertClickListener {
override fun onExpertClick() {
needRefresh = false
}
......@@ -344,7 +353,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
allFilter.showType.key = initShowType
getPresenter().fetchListHead()
getPresenter().fetchFunctionWord(2)
v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
......@@ -415,6 +424,26 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
@SuppressLint("CheckResult")
override fun onFunctionWordFetched(wordBean: List<FunctionWordBean>?) {
//获取底纹词
bottomWordlist = wordBean!!
if (bottomWordlist.isNullOrEmpty()) return
if (bottomWordlist.size == 1) {
tv_search_content.text = bottomWordlist[0].word
} else {
bottomWordDisposable = Observable.interval(0, 5, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
tv_search_content.text = bottomWordlist[(it % bottomWordlist.size).toInt()].word
}, {
}, {
})
}
}
/**
* 热门
*/
......@@ -1428,9 +1457,9 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
override fun onResume() {
super.onResume()
if (needRefresh){
if (needRefresh) {
refresh(false)
}else{
} else {
//
needRefresh = true
}
......@@ -1442,6 +1471,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
super.onDestroy()
EventBus.getDefault().unregister(this)
mHandler = null
bottomWordDisposable?.dispose()
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
}
}
......@@ -43,6 +43,24 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
})
}
// 查询底纹词
@SuppressLint("CheckResult")
fun fetchFunctionWord(type: Int) {
val map = HashMap<String, Any>()
map["type"] = type
SearchApi.getSearchApi()
.searchFunctionWord(map)
.compose(RxLifecycleUtils.bindToLifecycle(mView))//使用 Rxlifecycle,使 Disposable 和 Activity 一起销毁
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({ resp ->
mView.onFunctionWordFetched(resp)
}, { t ->
HttpErrorUtils.handleError(BaseApp.getApp(), t)
mView.fetchFailed(t.message)
})
}
@SuppressLint("CheckResult")
fun fetchListData(allFilter: AllFilter, extras: Extras?) {
......@@ -53,7 +71,7 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
// filter
val filterMap = HashMap<String, Any?>()
// 搜索词
if (!TextUtils.isEmpty(allFilter.searchWord)){
if (!TextUtils.isEmpty(allFilter.searchWord)) {
filterMap["__keywords"] = allFilter.searchWord
}
val categoryList = ArrayList<Any>()
......
......@@ -5,6 +5,7 @@ import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.consultant.model.bean.ExpertServiceItem
import com.yidianling.consultant.model.bean.Extras
import com.yidianling.consultant.model.bean.FunctionWordBean
import com.yidianling.consultant.model.bean.HeadData
/**
......@@ -16,7 +17,8 @@ interface IExpertSearchView : IView {
fun localData()
fun onHeadFetched(headData: HeadData?)
fun onDoctorListFetched(data: MutableList<ExpertServiceItem>, extras: Extras?,curPage:Int)
fun onFunctionWordFetched(wordBean: List<FunctionWordBean>?)
fun onDoctorListFetched(data: MutableList<ExpertServiceItem>, extras: Extras?, curPage: Int)
fun fetchFailed(msg: String?)
fun fetchListFailed(msg: String?)
fun fetchListEmpty(msg: String?)
......
......@@ -11,6 +11,7 @@ import com.yidianling.consultant.bean.GuideBean
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.model.bean.ExpertBean
import com.yidianling.consultant.model.bean.FunctionWordBean
import com.yidianling.consultant.model.bean.HeadData
import io.reactivex.Observable
import retrofit2.http.*
......@@ -43,13 +44,18 @@ interface SearchApi {
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun searchConditions(@Query("cateSource") cateSource: Int): Observable<BaseAPIResponse<HeadData>>
//查询功能词、底纹词
//(1热门词,2底纹词,3跳转词)
@POST("function/word/queryList")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun searchFunctionWord(@Body map: Map<String, @JvmSuppressWildcards Any>): Observable<BaseAPIResponse<List<FunctionWordBean>>>
/**
* 新咨询师列表接口(包含搜索、筛选咨询师)
*/
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA,"X-App-Id: plough_cloud")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "X-App-Id: plough_cloud")
@POST("smart-rank/v1/search")
fun getExpertList(@Body map: Map<String,@JvmSuppressWildcards Any>):Observable<BaseAPIResponse<ExpertBean>>
fun getExpertList(@Body map: Map<String, @JvmSuppressWildcards Any>): Observable<BaseAPIResponse<ExpertBean>>
/**
* 获取搜索联想词
......
package com.yidianling.consultant.model.bean
data class FunctionWordBean(
var id: Long?,
var word: String?,
var type: Int?,
var jumpUrl: String?
)
\ No newline at end of file
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