Commit 2e5b358b by upwork.021

feat: 小众病症联想词代码提交

parent 1d79f603
...@@ -6,7 +6,7 @@ ext { ...@@ -6,7 +6,7 @@ ext {
// -------------- 业务模块 -------------- // -------------- 业务模块 --------------
//第三步 若干 //第三步 若干
"m-confide" : "0.0.49.72", "m-confide" : "0.0.49.72",
"m-consultant" : "0.0.60.39", "m-consultant" : "0.0.60.45",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04", "m-user" : "0.0.62.04",
"m-home" : "0.0.23.80", "m-home" : "0.0.23.80",
...@@ -92,7 +92,7 @@ ext { ...@@ -92,7 +92,7 @@ ext {
//第三步 若干 //第三步 若干
"m-confide" : "0.0.49.72", "m-confide" : "0.0.49.72",
"m-consultant" : "0.0.60.31", "m-consultant" : "0.0.60.44",
"m-fm" : "0.0.30.08", "m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04", "m-user" : "0.0.62.04",
"m-home" : "0.0.23.41", "m-home" : "0.0.23.41",
......
...@@ -9,10 +9,7 @@ import android.content.Context ...@@ -9,10 +9,7 @@ import android.content.Context
import android.content.Intent import android.content.Intent
import android.graphics.Typeface import android.graphics.Typeface
import android.os.Handler import android.os.Handler
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextUtils import android.text.TextUtils
import android.text.style.StyleSpan
import android.view.View import android.view.View
import android.view.WindowManager import android.view.WindowManager
import android.view.inputmethod.InputMethodManager import android.view.inputmethod.InputMethodManager
...@@ -236,14 +233,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -236,14 +233,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
onBackPressed() onBackPressed()
} }
doctorAdapter = ExpertSearchAdapter(this, this, doctorList) doctorAdapter = ExpertSearchAdapter(this, this, doctorList)
val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
rvExperts.adapter = doctorAdapter
val layoutManager = LinearLayoutManager(
this,
LinearLayoutManager.VERTICAL,
false
)
rvExperts.layoutManager = layoutManager rvExperts.layoutManager = layoutManager
rvExperts.adapter = doctorAdapter
doctorAdapter.setOnClickLister(object: ExpertSearchAdapter.OnClickLister{
override fun onClick(searchWords: String) {
allFilter.searchWord = searchWords
refresh(false)
}
})
onScrollListener = object : EndlessRecyclerViewScrollListener(layoutManager) { onScrollListener = object : EndlessRecyclerViewScrollListener(layoutManager) {
private var isBtnShow: Boolean = false private var isBtnShow: Boolean = false
private var sIsScrolling = false private var sIsScrolling = false
...@@ -333,19 +333,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -333,19 +333,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
} }
} }
} }
// rvExperts.addItemDecoration(ExpertItemDecoration(this))
rvExperts.addOnScrollListener(onScrollListener) rvExperts.addOnScrollListener(onScrollListener)
rvExperts.addOnScrollListener(YDLImageRecyclerOnScrollListener(ExpertSearchActivity@ this)) rvExperts.addOnScrollListener(YDLImageRecyclerOnScrollListener(ExpertSearchActivity@ this))
// etSearch.addTextChangedListener(object : TextWatcher {
// override fun afterTextChanged(s: Editable?) {}
//
// override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
//
// override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
//
// }
//
// })
image_scroll_top.setOnClickListener(this) image_scroll_top.setOnClickListener(this)
// initStatus() // initStatus()
...@@ -414,10 +403,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -414,10 +403,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
tv_search_content.text = searchWord tv_search_content.text = searchWord
// 判断搜索词和联想词不一样,则显示匹配结果 // 判断搜索词和联想词不一样,则显示匹配结果
if (!TextUtils.isEmpty(searchWord)&&!TextUtils.isEmpty(relatedWord)&&searchWord!=relatedWord){ if (!TextUtils.isEmpty(searchWord)&&!TextUtils.isEmpty(relatedWord)&&searchWord!=relatedWord){
cl_search_words.visibility = View.VISIBLE doctorList.add(ExpertServiceItem(true,searchWord,relatedWord))
val text = "根据匹配,为您推荐“${relatedWord}”相关词"
tv_search_related_word.text = setTextBold(text,relatedWord)
} }
v_loading.visibility = View.VISIBLE v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null) v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
...@@ -823,7 +811,13 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -823,7 +811,13 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
hasMore = false hasMore = false
doctorAdapter.hasMore = false doctorAdapter.hasMore = false
} }
doctorList.clear() if (doctorList.size>0){
val expertServiceItem = doctorList[0]
doctorList.clear()
doctorList.add(expertServiceItem)
}else{
doctorList.clear()
}
} }
if (data.size==0) { // data的长度为0的时候为最后一页 if (data.size==0) { // data的长度为0的时候为最后一页
...@@ -871,14 +865,23 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -871,14 +865,23 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
isDoSearch = false isDoSearch = false
isRecommend = false isRecommend = false
tv_reload.visibility = View.GONE if (doctorList.size==0||doctorList.size>0&&TextUtils.isEmpty(doctorList[0].related_word)){
tv_reload_hint.text = msg tv_reload.visibility = View.GONE
ll_network_error.visibility = View.VISIBLE tv_reload_hint.text = msg
iv_exception.setImageResource(R.drawable.platform_ico_img_zixun_empty) ll_network_error.visibility = View.VISIBLE
iv_exception.setImageResource(R.drawable.platform_ico_img_zixun_empty)
rvExperts.visibility = View.GONE rvExperts.visibility = View.GONE
dismissProgressDialog() dismissProgressDialog()
srlContainer.isRefreshing = false srlContainer.isRefreshing = false
}else{
doctorAdapter.notifyDataSetChanged()
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
}
} }
...@@ -963,7 +966,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -963,7 +966,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
ActionCountUtils.count(YDL_USER_CONSULT_SEARCH_CLICK) ActionCountUtils.count(YDL_USER_CONSULT_SEARCH_CLICK)
ARouter.getInstance() ARouter.getInstance()
.build("/consult/hot_search") .build("/consult/hot_search")
.withString(HOT_SEARCH_DOCTOR_NAME, allFilter.searchWord) .withString(HOT_SEARCH_DOCTOR_NAME, tv_search_content.text.toString())
.navigation() .navigation()
} }
} }
...@@ -1420,30 +1423,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1420,30 +1423,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
onScrollListener.resetState() onScrollListener.resetState()
getPresenter().mExtras=null getPresenter().mExtras=null
getPresenter().fetchListData(allFilter, getPresenter().mExtras) getPresenter().fetchListData(allFilter, getPresenter().mExtras)
doctorList.clear()
rvExperts.scrollToPosition(0) rvExperts.scrollToPosition(0)
} }
//执行搜索
private fun doSearch() {
image_scroll_top.visibility = View.GONE
hideSoftInput()
// keyWord = etSearch.text.toString()
// if (TextUtils.isEmpty(keyWord?.trim())) {
// ToastUtil.toastShort(this, "请输入搜索内容")
// return
// }
ActionCountUtils.count(
ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,
cateName ?: ""
)
isDoSearch = true
resetFilter()
refresh()
}
//重置所有筛选 //重置所有筛选
private fun resetFilter() { private fun resetFilter() {
allFilter.categories.clear() allFilter.categories.clear()
...@@ -1524,22 +1506,4 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres ...@@ -1524,22 +1506,4 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
mHandler=null mHandler=null
ConsultAssistantDialogUtils.INSTANCE.expertSearchResetStatus() ConsultAssistantDialogUtils.INSTANCE.expertSearchResetStatus()
} }
private fun setTextBold(text: String, content: String): SpannableStringBuilder {
return if (text.contains(content)) {
val s1 = text.split(content)[0]
val s2 = text.split(content)[1]
val spannableBuilder1 = SpannableStringBuilder(s1)
val spannableBuilder2 = SpannableStringBuilder(content)
spannableBuilder2.setSpan(
StyleSpan(Typeface.BOLD),
0,
content.length,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
)
spannableBuilder1.append(spannableBuilder2).append(SpannableStringBuilder(s2))
} else {
SpannableStringBuilder(text)
}
}
} }
...@@ -280,16 +280,6 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -280,16 +280,6 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
} }
rvExperts.addOnScrollListener(onScrollListener) rvExperts.addOnScrollListener(onScrollListener)
rvExperts.addOnScrollListener(YDLImageRecyclerOnScrollListener(activity)) rvExperts.addOnScrollListener(YDLImageRecyclerOnScrollListener(activity))
// etSearch.addTextChangedListener(object : TextWatcher {
// override fun afterTextChanged(s: Editable?) {}
//
// override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
//
// override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
//
// }
//
// })
image_scroll_top.setOnClickListener(this) image_scroll_top.setOnClickListener(this)
} }
...@@ -734,6 +724,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -734,6 +724,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
doctorAdapter.hasMore = false doctorAdapter.hasMore = false
} }
doctorList.clear() doctorList.clear()
// 加入头部数据并隐藏,否则点击事件position会错乱
doctorList.add(ExpertServiceItem(false,"",""))
} }
if (data.size==0) { // data的长度为0的时候为最后一页 if (data.size==0) { // data的长度为0的时候为最后一页
......
...@@ -10,13 +10,12 @@ import com.ydl.ydlcommon.modular.ModularServiceManager ...@@ -10,13 +10,12 @@ import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.base.SimplePresenter import com.ydl.ydlcommon.mvp.base.SimplePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils import com.ydl.ydlcommon.utils.RxLifecycleUtils
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.http.ExpertSearchDataManager import com.yidianling.consultant.http.ExpertSearchDataManager
import com.yidianling.consultant.model.SearchApi import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.model.bean.AllFilter import com.yidianling.consultant.model.bean.AllFilter
import com.yidianling.consultant.model.bean.Extras import com.yidianling.consultant.model.bean.Extras
import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
...@@ -158,16 +157,16 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -158,16 +157,16 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
// 其它 // 其它
if (allFilter.others.isNotEmpty()) { if (allFilter.others.isNotEmpty()) {
val gender = ArrayList<String?>() val gender = ArrayList<String?>()
val bookIngStatusList = ArrayList<String>() // val bookIngStatusList = ArrayList<String>()
allFilter.others.forEach { allFilter.others.forEach {
when (it.key1) { when (it.key1) {
"gender" -> { "gender" -> {
gender.add(it.value1) gender.add(it.value1)
} }
"booking_status" -> { // "booking_status" -> {
bookIngStatusList.add("1") // bookIngStatusList.add("1")
bookIngStatusList.add("2") // bookIngStatusList.add("2")
} // }
else -> { else -> {
filterMap[it.key1] = it.value1 filterMap[it.key1] = it.value1
} }
...@@ -178,11 +177,11 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -178,11 +177,11 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
genderMap["in"] = gender genderMap["in"] = gender
filterMap["gender"] = genderMap filterMap["gender"] = genderMap
} }
if (bookIngStatusList.size>0){ // if (bookIngStatusList.size>0){
val bookStatusMap = HashMap<String, Any>() // val bookStatusMap = HashMap<String, Any>()
bookStatusMap["in"] = bookIngStatusList // bookStatusMap["in"] = bookIngStatusList
filterMap["booking_status"] = bookStatusMap // filterMap["booking_status"] = bookStatusMap
} // }
} }
map["filter"] = filterMap map["filter"] = filterMap
...@@ -198,9 +197,9 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -198,9 +197,9 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
fieldsMap["doctor_name"] = true fieldsMap["doctor_name"] = true
fieldsMap["uid"] = true fieldsMap["uid"] = true
fieldsMap["chat_status"] = true fieldsMap["chat_status"] = true
fieldsMap["consult_status"] = true // fieldsMap["consult_status"] = true
fieldsMap["listen_status"] = true // fieldsMap["listen_status"] = true
fieldsMap["booking_status"] = true // fieldsMap["booking_status"] = true
fieldsMap["gender"] = true fieldsMap["gender"] = true
fieldsMap["years"] = true fieldsMap["years"] = true
fieldsMap["head"] = true fieldsMap["head"] = true
...@@ -221,6 +220,9 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -221,6 +220,9 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
fieldsMap["chat_btn_text"] = true fieldsMap["chat_btn_text"] = true
fieldsMap["feature_tags"] = true fieldsMap["feature_tags"] = true
fieldsMap["link_url"] = true fieldsMap["link_url"] = true
fieldsMap["open_chat_agency"] = true
fieldsMap["service_status"] = true
fieldsMap["is_free_today"] = true
map["fields"] = fieldsMap map["fields"] = fieldsMap
val optionsMap = HashMap<String, Any?>() val optionsMap = HashMap<String, Any?>()
...@@ -252,6 +254,7 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() { ...@@ -252,6 +254,7 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
} }
}, object : ThrowableConsumer() { }, object : ThrowableConsumer() {
override fun accept(msg: String) { override fun accept(msg: String) {
ToastUtil.toastShort(msg)
mView.fetchListFailed(msg) mView.fetchListFailed(msg)
} }
}) })
......
...@@ -19,8 +19,6 @@ import com.ydl.ydl_image.module.GlideApp ...@@ -19,8 +19,6 @@ import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydl_router.manager.YDLRouterParams import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.bean.StatusBarOptions import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.IYDLRouterConstant import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.* import com.ydl.ydlcommon.utils.*
...@@ -33,12 +31,9 @@ import com.yidianling.consultant.api.IConsultantService ...@@ -33,12 +31,9 @@ import com.yidianling.consultant.api.IConsultantService
import com.yidianling.consultant.bean.* import com.yidianling.consultant.bean.*
import com.yidianling.consultant.constants.ConsultBIConstants import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.contract.IHotSearchContract import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.http.ExpertSearchDataManager
import com.yidianling.consultant.modular.utils.ConsultAssistantEntryUtils import com.yidianling.consultant.modular.utils.ConsultAssistantEntryUtils
import com.yidianling.consultant.modular.utils.TempH5RouteUtils import com.yidianling.consultant.modular.utils.TempH5RouteUtils
import com.yidianling.consultant.presenter.HotSearchPresenterImpl import com.yidianling.consultant.presenter.HotSearchPresenterImpl
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.consultant_activity_hot_search.* import kotlinx.android.synthetic.main.consultant_activity_hot_search.*
import kotlinx.android.synthetic.main.consultant_item_expert_hot_search.view.* import kotlinx.android.synthetic.main.consultant_item_expert_hot_search.view.*
...@@ -63,6 +58,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -63,6 +58,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
private var dp42: Int = 0 private var dp42: Int = 0
override fun layoutResId(): Int { override fun layoutResId(): Int {
return R.layout.consultant_activity_hot_search return R.layout.consultant_activity_hot_search
} }
...@@ -100,7 +96,16 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -100,7 +96,16 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} }
etSearch.setOnEditorActionListener { _, actionId, _ -> etSearch.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) { if (actionId == EditorInfo.IME_ACTION_SEARCH) {
doSearch() // 搜索的关联词
var relatedWords = ""
if (searchSuggestList.isNotEmpty()&&searchSuggestList.size>0){
searchSuggestList[0].suggest_relations?.let {
if (it.size>0){
relatedWords = it[0]
}
}
}
doSearch(etSearch.text.toString(),relatedWords)
} }
true true
} }
...@@ -131,17 +136,24 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -131,17 +136,24 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
rv_search_words.layoutManager = LinearLayoutManager(this) rv_search_words.layoutManager = LinearLayoutManager(this)
rv_search_words.adapter = searchWordsAdapter rv_search_words.adapter = searchWordsAdapter
searchWordsAdapter.setOnItemClickListener { adapter, view, position -> searchWordsAdapter.setOnItemClickListener { adapter, view, position ->
// 搜索的关联词
var relatedWords = ""
if (searchSuggestList.isNotEmpty()&&searchSuggestList.size>0){
searchSuggestList[position].suggest_relations?.let {
relatedWords = it[0]
}
}
doSearch(searchSuggestList[position].suggest_content,relatedWords)
} }
etSearch.addTextChangedListener(object : TextWatcher { etSearch.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) { override fun afterTextChanged(s: Editable?) {
if (TextUtils.isEmpty(s)) { if (TextUtils.isEmpty(s)) {
iv_delete_icon.visibility = View.INVISIBLE iv_delete_icon.visibility = View.INVISIBLE
rv_search_words.visibility = View.GONE rv_search_words.visibility = View.GONE
getSearchWords("") getSearchWords("",false)
} else { } else {
iv_delete_icon.visibility = View.VISIBLE iv_delete_icon.visibility = View.VISIBLE
getSearchWords(s.toString()) getSearchWords(s.toString(),false)
} }
} }
...@@ -157,26 +169,40 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -157,26 +169,40 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
/** /**
* 获取搜索联想词 * 获取搜索联想词
* @param isClickWords 是否是点击历史搜索、热门搜索等进行搜索
*/ */
private fun getSearchWords(searchContent:String){ private fun getSearchWords(searchContent:String,isClickWords:Boolean){
if (!TextUtils.isEmpty(searchContent)){ if (!TextUtils.isEmpty(searchContent)){
mSearchContent = searchContent mSearchContent = searchContent
val map = HashMap<String, Any>() val map = HashMap<String, Any>()
map["content"] = searchContent map["content"] = searchContent
mPresenter.getSearchWords(map) mPresenter.getSearchWords(map,searchContent,isClickWords)
}else{ }else{
rv_search_words.visibility = View.GONE rv_search_words.visibility = View.GONE
} }
} }
override fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean) { override fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean) {
searchSuggestList.clear() if (isClickWords){
if (!searchWordsBean.search_suggests.isNullOrEmpty()){ // 搜索的关联词
rv_search_words.visibility = View.VISIBLE var relatedWords = ""
searchSuggestList.addAll(searchWordsBean.search_suggests) if (!searchWordsBean.search_suggests.isNullOrEmpty()&&searchWordsBean.search_suggests.size>0){
searchWordsAdapter.notifyDataAndSetSearchWord(mSearchContent) searchWordsBean.search_suggests[0].suggest_relations?.let {
if (it.size>0){
relatedWords = it[0]
}
}
}
doSearch(searchContent,relatedWords)
}else{ }else{
rv_search_words.visibility = View.GONE searchSuggestList.clear()
if (!searchWordsBean.search_suggests.isNullOrEmpty()){
rv_search_words.visibility = View.VISIBLE
searchSuggestList.addAll(searchWordsBean.search_suggests)
searchWordsAdapter.notifyDataAndSetSearchWord(mSearchContent)
}else{
rv_search_words.visibility = View.GONE
}
} }
} }
...@@ -220,8 +246,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -220,8 +246,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
.inflate(R.layout.consultant_item_expert_hot_search, flHotSearch, false) .inflate(R.layout.consultant_item_expert_hot_search, flHotSearch, false)
view.tvHotSearch.text = keywordData[index].keyword view.tvHotSearch.text = keywordData[index].keyword
view.setOnClickListener { view.setOnClickListener {
etSearch.setText(keywordData[index].keyword) getSearchWords(keywordData[index].keyword!!,true)
doSearch()
} }
flHotSearch.addView(view) flHotSearch.addView(view)
} }
...@@ -253,8 +278,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -253,8 +278,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} }
} }
view.setOnClickListener { view.setOnClickListener {
etSearch.setText(hotSearchExpert[index].name) getSearchWords(etSearch.text.toString(),true)
doSearch()
} }
flHotExpert.addView(view) flHotExpert.addView(view)
} }
...@@ -263,9 +287,6 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -263,9 +287,6 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
//刷新 banner //刷新 banner
private fun refreshBanner(focusList: MutableList<HotSearchFocusItemBean>?) { private fun refreshBanner(focusList: MutableList<HotSearchFocusItemBean>?) {
if (null == focusList) { if (null == focusList) {
// if (bannerList.isEmpty()) {
// bannerList.add("https://h2.yidianling.com/ct/list")
// }
card_view.visibility = View.GONE card_view.visibility = View.GONE
} }
if (null != focusList && focusList.isNotEmpty()) { if (null != focusList && focusList.isNotEmpty()) {
...@@ -319,8 +340,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -319,8 +340,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
break break
} }
view.setOnClickListener { view.setOnClickListener {
etSearch.setText(historyStr) getSearchWords(historyStr,true)
doSearch()
} }
fl_search_history.addView(view) fl_search_history.addView(view)
} }
...@@ -339,13 +359,13 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -339,13 +359,13 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
/** /**
* 搜索 * 搜索
*/ */
private fun doSearch() { private fun doSearch(searchWords:String,relatedWords:String) {
val view = this.currentFocus val view = this.currentFocus
if (view != null) { if (view != null) {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0) imm.hideSoftInputFromWindow(view.windowToken, 0)
} }
val searchWords = etSearch.text.toString()
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,searchWords) ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,searchWords)
if (!TextUtils.isEmpty(searchWords)) { if (!TextUtils.isEmpty(searchWords)) {
historyList.remove(searchWords) historyList.remove(searchWords)
...@@ -355,13 +375,6 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -355,13 +375,6 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
Gson().toJson(historyList) Gson().toJson(historyList)
) )
} }
// 搜索的关联词
var relatedWords = ""
if (searchSuggestList.isNotEmpty()){
searchSuggestList[0].suggest_relations?.let {
relatedWords = it[0]
}
}
ExpertSearchActivity.startSearch(this, searchWords,"14",relatedWords) ExpertSearchActivity.startSearch(this, searchWords,"14",relatedWords)
finish() finish()
} }
......
...@@ -31,7 +31,7 @@ class IHotSearchContract { ...@@ -31,7 +31,7 @@ class IHotSearchContract {
/** /**
* 联想词请求成功结果 * 联想词请求成功结果
*/ */
fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean) fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean)
} }
interface Presenter : IPresenter<View> { interface Presenter : IPresenter<View> {
...@@ -48,7 +48,7 @@ class IHotSearchContract { ...@@ -48,7 +48,7 @@ class IHotSearchContract {
/** /**
* 获取联想词 * 获取联想词
*/ */
fun getSearchWords(map:HashMap<String,Any>) fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean)
} }
interface Model : IModel { interface Model : IModel {
......
...@@ -95,18 +95,25 @@ data class ExpertServiceItem( ...@@ -95,18 +95,25 @@ data class ExpertServiceItem(
* 标签图片 * 标签图片
*/ */
val icons: ExpertSearchTagsIconBean?, val icons: ExpertSearchTagsIconBean?,
/** // /**
* 今日是否可约 // * 今日是否可约
*/ // */
val booking_status: Int, // val booking_status: Int,
/** // /**
* 咨询状态 1-待服务 2-服务中 // * 咨询状态 1-待服务 2-服务中
*/ // */
var consult_status: Int, // var consult_status: Int,
/** // /**
* 倾诉状态 1-待服务 2-服务中 // * 倾诉状态 1-待服务 2-服务中
*/ // */
var listen_status: Int, // var listen_status: Int,
var open_chat_agency:Int,
var service_status:Int,
var is_free_today:Int,
/** /**
* 私聊人数 * 私聊人数
*/ */
...@@ -131,8 +138,27 @@ data class ExpertServiceItem( ...@@ -131,8 +138,27 @@ data class ExpertServiceItem(
/** /**
* 新标签分类 * 新标签分类
*/ */
val feature_tags: ArrayList<FeatureTag>? val feature_tags: ArrayList<FeatureTag>?,
)
/**
* 是否是头部headView
*/
val is_head_view:Boolean=false,
/**
* 搜索词
*/
val search_content:String,
/**
* 联想词
*/
val related_word:String
) {
constructor(is_head_view: Boolean,search_content: String,related_word:String) : this("","","","","",
1,1,1,"",false,true,
1f,false,0,"","","",1f,1f,
null,null,1,1,1,1,
"","","","",null,is_head_view,search_content,related_word)
}
data class FeatureTag( data class FeatureTag(
val tag_id:String, val tag_id:String,
......
//package com.yidianling.consultant.model.bean
//
//import com.google.gson.annotations.SerializedName
//
//data class ServiceItem(
//
// @field:SerializedName("doctor_uid")
// val doctorUid: Int = 0,
//
// @field:SerializedName("city")
// val city: String? = null,
//
// @field:SerializedName("product_name")
// val productName: String? = null,
//
// @field:SerializedName("tags")
// val tags: List<String?> = ArrayList(),
//
// @field:SerializedName("uid")
// val uid: Int? = null,
//
// @field:SerializedName("doctor_id")
// val doctorId: Int? = null,
//
// @field:SerializedName("feedback_rate")
// val feedbackRate: String? = null,
//
// @field:SerializedName("doctor_head")
// val doctorHead: String? = null,
//
// @field:SerializedName("province")
// val province: String? = null,
//
//
// @field:SerializedName("doctor_name")
// val doctorName: String? = null,
//
// @field:SerializedName("m_url")
// val mUrl: String? = null,
//
// @field:SerializedName("h_url")
// val hUrl: String? = null,
//
// @field:SerializedName("is_online")
// val isOnline: Int = 0 //1在线,2离线
//)
\ No newline at end of file
//package com.yidianling.consultant.model.bean;
//
//import com.chad.library.adapter.base.entity.MultiItemEntity;
//
///**
// * Created by Ykai on 2022/5/18.
// */
//
//public class SortBean implements MultiItemEntity {
// public String name;
// int type;
// public boolean isVisible; // 是否显示
// public boolean isSelected; // 是否选中
//
//
// public SortBean(String name, int type){
// this.name = name;
// this.type = type;
// isVisible = true;
// }
//
// @Override
// public int getItemType() {
// return type;
// }
//}
...@@ -4,7 +4,6 @@ import android.annotation.SuppressLint ...@@ -4,7 +4,6 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.text.TextUtils import android.text.TextUtils
import com.google.gson.Gson import com.google.gson.Gson
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.mvp.base.BasePresenter import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils import com.ydl.ydlcommon.utils.RxLifecycleUtils
...@@ -17,7 +16,6 @@ import com.yidianling.consultant.model.HotSearchModelImpl ...@@ -17,7 +16,6 @@ import com.yidianling.consultant.model.HotSearchModelImpl
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/** /**
* @author yuanwai * @author yuanwai
...@@ -62,6 +60,7 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch ...@@ -62,6 +60,7 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch
/** /**
* 搜索页接口 * 搜索页接口
*/ */
@SuppressLint("CheckResult")
override fun searchData() { override fun searchData() {
mModel.searchData().map { it } mModel.searchData().map { it }
.filter { it != null } .filter { it != null }
...@@ -78,14 +77,14 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch ...@@ -78,14 +77,14 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
override fun getSearchWords(map:HashMap<String,Any>) { override fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean) {
mModel.getSearchWords(map) mModel.getSearchWords(map)
.debounce(500L, TimeUnit.MILLISECONDS) // .debounce(500L, TimeUnit.MILLISECONDS)
.compose(RxLifecycleUtils.bindToLifecycle(mView)) .compose(RxLifecycleUtils.bindToLifecycle(mView))
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer { .subscribe(Consumer {
mView.getSearchWordsSuccess(it) mView.getSearchWordsSuccess(it,searchContent,isClickWords)
}, object : ThrowableConsumer() { }, object : ThrowableConsumer() {
override fun accept(msg: String) { override fun accept(msg: String) {
ToastUtil.toastShort(msg) ToastUtil.toastShort(msg)
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_search_words"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="19dp"
android:paddingEnd="19dp"
android:visibility="gone"
>
<TextView
android:id="@+id/tv_search_related_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/platform_color_242424"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textSize="15sp"
android:fontFamily="sans-serif"
android:layout_marginTop="14dp"
android:includeFontPadding="false"
tools:text="根据匹配,为您推荐恋爱情感相关词" />
<TextView
android:id="@+id/tv_search_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_search_word"
app:layout_constraintBottom_toBottomOf="@id/tv_search_word"
android:textSize="15sp"
android:textColor="@color/platform_color_666666"
android:fontFamily="sans-serif"
android:includeFontPadding="false"
android:text="仍搜索" />
<TextView
android:id="@+id/tv_search_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/tv_search_tips"
app:layout_constraintTop_toBottomOf="@id/tv_search_related_word"
android:layout_marginTop="9dp"
android:layout_marginStart="6dp"
android:textSize="14sp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:textColor="@color/platform_color_242424"
android:includeFontPadding="false"
android:background="@drawable/consultant_stroke_ebebeb_solid_f9f9f9_r_4"
tools:text="恋爱情感"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
\ No newline at end of file
...@@ -82,65 +82,6 @@ ...@@ -82,65 +82,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="6dp" android:layout_height="6dp"
android:background="@drawable/consult_fillter_bg" /> android:background="@drawable/consult_fillter_bg" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_search_words"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="19dp"
android:paddingEnd="19dp"
android:visibility="gone"
>
<TextView
android:id="@+id/tv_search_related_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/platform_color_242424"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textSize="15sp"
android:fontFamily="sans-serif"
android:layout_marginTop="14dp"
android:includeFontPadding="false"
tools:text="根据匹配,为您推荐恋爱情感相关词" />
<TextView
android:id="@+id/tv_search_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_search_word"
app:layout_constraintBottom_toBottomOf="@id/tv_search_word"
android:textSize="15sp"
android:textColor="@color/platform_color_666666"
android:fontFamily="sans-serif"
android:includeFontPadding="false"
android:text="仍搜索" />
<TextView
android:id="@+id/tv_search_word"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@id/tv_search_tips"
app:layout_constraintTop_toBottomOf="@id/tv_search_related_word"
android:layout_marginTop="9dp"
android:layout_marginStart="6dp"
android:textSize="14sp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:textColor="@color/platform_color_242424"
android:includeFontPadding="false"
android:background="@drawable/consultant_stroke_ebebeb_solid_f9f9f9_r_4"
tools:text="恋爱情感"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- <View-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="1dp"-->
<!-- android:background="@color/platform_color_EBEBEB" />-->
</LinearLayout> </LinearLayout>
......
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