Commit 2e5b358b by upwork.021

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

parent 1d79f603
......@@ -6,7 +6,7 @@ ext {
// -------------- 业务模块 --------------
//第三步 若干
"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-user" : "0.0.62.04",
"m-home" : "0.0.23.80",
......@@ -92,7 +92,7 @@ ext {
//第三步 若干
"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-user" : "0.0.62.04",
"m-home" : "0.0.23.41",
......
......@@ -9,10 +9,7 @@ import android.content.Context
import android.content.Intent
import android.graphics.Typeface
import android.os.Handler
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextUtils
import android.text.style.StyleSpan
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
......@@ -236,14 +233,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
onBackPressed()
}
doctorAdapter = ExpertSearchAdapter(this, this, doctorList)
rvExperts.adapter = doctorAdapter
val layoutManager = LinearLayoutManager(
this,
LinearLayoutManager.VERTICAL,
false
)
val layoutManager = LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
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) {
private var isBtnShow: Boolean = false
private var sIsScrolling = false
......@@ -333,19 +333,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
}
}
// rvExperts.addItemDecoration(ExpertItemDecoration(this))
rvExperts.addOnScrollListener(onScrollListener)
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)
// initStatus()
......@@ -414,10 +403,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
tv_search_content.text = searchWord
// 判断搜索词和联想词不一样,则显示匹配结果
if (!TextUtils.isEmpty(searchWord)&&!TextUtils.isEmpty(relatedWord)&&searchWord!=relatedWord){
cl_search_words.visibility = View.VISIBLE
val text = "根据匹配,为您推荐“${relatedWord}”相关词"
tv_search_related_word.text = setTextBold(text,relatedWord)
doctorList.add(ExpertServiceItem(true,searchWord,relatedWord))
}
v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
......@@ -823,7 +811,13 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
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的时候为最后一页
......@@ -871,14 +865,23 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
isDoSearch = false
isRecommend = false
tv_reload.visibility = View.GONE
tv_reload_hint.text = msg
ll_network_error.visibility = View.VISIBLE
iv_exception.setImageResource(R.drawable.platform_ico_img_zixun_empty)
if (doctorList.size==0||doctorList.size>0&&TextUtils.isEmpty(doctorList[0].related_word)){
tv_reload.visibility = View.GONE
tv_reload_hint.text = msg
ll_network_error.visibility = View.VISIBLE
iv_exception.setImageResource(R.drawable.platform_ico_img_zixun_empty)
rvExperts.visibility = View.GONE
dismissProgressDialog()
srlContainer.isRefreshing = false
rvExperts.visibility = View.GONE
dismissProgressDialog()
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
ActionCountUtils.count(YDL_USER_CONSULT_SEARCH_CLICK)
ARouter.getInstance()
.build("/consult/hot_search")
.withString(HOT_SEARCH_DOCTOR_NAME, allFilter.searchWord)
.withString(HOT_SEARCH_DOCTOR_NAME, tv_search_content.text.toString())
.navigation()
}
}
......@@ -1420,30 +1423,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
onScrollListener.resetState()
getPresenter().mExtras=null
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
doctorList.clear()
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() {
allFilter.categories.clear()
......@@ -1524,22 +1506,4 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
mHandler=null
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
}
rvExperts.addOnScrollListener(onScrollListener)
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)
}
......@@ -734,6 +724,8 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
doctorAdapter.hasMore = false
}
doctorList.clear()
// 加入头部数据并隐藏,否则点击事件position会错乱
doctorList.add(ExpertServiceItem(false,"",""))
}
if (data.size==0) { // data的长度为0的时候为最后一页
......
......@@ -10,13 +10,12 @@ import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.base.SimplePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.http.ExpertSearchDataManager
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.model.bean.AllFilter
import com.yidianling.consultant.model.bean.Extras
import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
......@@ -158,16 +157,16 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
// 其它
if (allFilter.others.isNotEmpty()) {
val gender = ArrayList<String?>()
val bookIngStatusList = ArrayList<String>()
// val bookIngStatusList = ArrayList<String>()
allFilter.others.forEach {
when (it.key1) {
"gender" -> {
gender.add(it.value1)
}
"booking_status" -> {
bookIngStatusList.add("1")
bookIngStatusList.add("2")
}
// "booking_status" -> {
// bookIngStatusList.add("1")
// bookIngStatusList.add("2")
// }
else -> {
filterMap[it.key1] = it.value1
}
......@@ -178,11 +177,11 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
genderMap["in"] = gender
filterMap["gender"] = genderMap
}
if (bookIngStatusList.size>0){
val bookStatusMap = HashMap<String, Any>()
bookStatusMap["in"] = bookIngStatusList
filterMap["booking_status"] = bookStatusMap
}
// if (bookIngStatusList.size>0){
// val bookStatusMap = HashMap<String, Any>()
// bookStatusMap["in"] = bookIngStatusList
// filterMap["booking_status"] = bookStatusMap
// }
}
map["filter"] = filterMap
......@@ -198,9 +197,9 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
fieldsMap["doctor_name"] = true
fieldsMap["uid"] = true
fieldsMap["chat_status"] = true
fieldsMap["consult_status"] = true
fieldsMap["listen_status"] = true
fieldsMap["booking_status"] = true
// fieldsMap["consult_status"] = true
// fieldsMap["listen_status"] = true
// fieldsMap["booking_status"] = true
fieldsMap["gender"] = true
fieldsMap["years"] = true
fieldsMap["head"] = true
......@@ -221,6 +220,9 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
fieldsMap["chat_btn_text"] = true
fieldsMap["feature_tags"] = true
fieldsMap["link_url"] = true
fieldsMap["open_chat_agency"] = true
fieldsMap["service_status"] = true
fieldsMap["is_free_today"] = true
map["fields"] = fieldsMap
val optionsMap = HashMap<String, Any?>()
......@@ -252,6 +254,7 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
}
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
mView.fetchListFailed(msg)
}
})
......
......@@ -19,8 +19,6 @@ import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydl_router.manager.YDLRouterParams
import com.ydl.ydlcommon.base.BaseMvpActivity
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.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.*
......@@ -33,12 +31,9 @@ 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.http.ExpertSearchDataManager
import com.yidianling.consultant.modular.utils.ConsultAssistantEntryUtils
import com.yidianling.consultant.modular.utils.TempH5RouteUtils
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_item_expert_hot_search.view.*
......@@ -63,6 +58,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
private var dp42: Int = 0
override fun layoutResId(): Int {
return R.layout.consultant_activity_hot_search
}
......@@ -100,7 +96,16 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
etSearch.setOnEditorActionListener { _, actionId, _ ->
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
}
......@@ -131,17 +136,24 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
rv_search_words.layoutManager = LinearLayoutManager(this)
rv_search_words.adapter = searchWordsAdapter
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 {
override fun afterTextChanged(s: Editable?) {
if (TextUtils.isEmpty(s)) {
iv_delete_icon.visibility = View.INVISIBLE
rv_search_words.visibility = View.GONE
getSearchWords("")
getSearchWords("",false)
} else {
iv_delete_icon.visibility = View.VISIBLE
getSearchWords(s.toString())
getSearchWords(s.toString(),false)
}
}
......@@ -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)){
mSearchContent = searchContent
val map = HashMap<String, Any>()
map["content"] = searchContent
mPresenter.getSearchWords(map)
mPresenter.getSearchWords(map,searchContent,isClickWords)
}else{
rv_search_words.visibility = View.GONE
}
}
override fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean) {
searchSuggestList.clear()
if (!searchWordsBean.search_suggests.isNullOrEmpty()){
rv_search_words.visibility = View.VISIBLE
searchSuggestList.addAll(searchWordsBean.search_suggests)
searchWordsAdapter.notifyDataAndSetSearchWord(mSearchContent)
override fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean) {
if (isClickWords){
// 搜索的关联词
var relatedWords = ""
if (!searchWordsBean.search_suggests.isNullOrEmpty()&&searchWordsBean.search_suggests.size>0){
searchWordsBean.search_suggests[0].suggest_relations?.let {
if (it.size>0){
relatedWords = it[0]
}
}
}
doSearch(searchContent,relatedWords)
}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
.inflate(R.layout.consultant_item_expert_hot_search, flHotSearch, false)
view.tvHotSearch.text = keywordData[index].keyword
view.setOnClickListener {
etSearch.setText(keywordData[index].keyword)
doSearch()
getSearchWords(keywordData[index].keyword!!,true)
}
flHotSearch.addView(view)
}
......@@ -253,8 +278,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
}
view.setOnClickListener {
etSearch.setText(hotSearchExpert[index].name)
doSearch()
getSearchWords(etSearch.text.toString(),true)
}
flHotExpert.addView(view)
}
......@@ -263,9 +287,6 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
//刷新 banner
private fun refreshBanner(focusList: MutableList<HotSearchFocusItemBean>?) {
if (null == focusList) {
// if (bannerList.isEmpty()) {
// bannerList.add("https://h2.yidianling.com/ct/list")
// }
card_view.visibility = View.GONE
}
if (null != focusList && focusList.isNotEmpty()) {
......@@ -319,8 +340,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
break
}
view.setOnClickListener {
etSearch.setText(historyStr)
doSearch()
getSearchWords(historyStr,true)
}
fl_search_history.addView(view)
}
......@@ -339,13 +359,13 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
/**
* 搜索
*/
private fun doSearch() {
private fun doSearch(searchWords:String,relatedWords:String) {
val view = this.currentFocus
if (view != null) {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.hideSoftInputFromWindow(view.windowToken, 0)
}
val searchWords = etSearch.text.toString()
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,searchWords)
if (!TextUtils.isEmpty(searchWords)) {
historyList.remove(searchWords)
......@@ -355,13 +375,6 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
Gson().toJson(historyList)
)
}
// 搜索的关联词
var relatedWords = ""
if (searchSuggestList.isNotEmpty()){
searchSuggestList[0].suggest_relations?.let {
relatedWords = it[0]
}
}
ExpertSearchActivity.startSearch(this, searchWords,"14",relatedWords)
finish()
}
......
......@@ -2,14 +2,18 @@ package com.yidianling.consultant.adapter
import android.annotation.SuppressLint
import android.content.Context
import androidx.core.content.ContextCompat
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import android.graphics.Typeface
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextUtils
import android.text.style.StyleSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.ydl_image.config.SimpleImageOpConfiger
......@@ -19,7 +23,6 @@ import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.URLUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.consultant.ExpertSearchActivity
import com.yidianling.consultant.IExpertSearchView
import com.yidianling.consultant.R
import com.yidianling.consultant.constants.ConsultBIConstants
......@@ -27,11 +30,13 @@ import com.yidianling.consultant.model.bean.ExpertServiceItem
import com.yidianling.consultant.modular.utils.TempH5RouteUtils
import com.yidianling.consultant.router.ConsultantIn
import kotlinx.android.synthetic.main.consultant_expert_search_feedbackrate.view.*
import kotlinx.android.synthetic.main.consultant_expert_search_header_view.view.*
import kotlinx.android.synthetic.main.consultant_expert_search_item_view.view.*
import kotlinx.android.synthetic.main.consultant_expert_search_products_item.view.*
import kotlinx.android.synthetic.main.consultant_item_empty.view.*
import kotlinx.android.synthetic.main.consultant_item_footer.view.*
import kotlinx.android.synthetic.main.consultant_item_tag.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.*
import java.math.BigDecimal
/**
......@@ -44,25 +49,63 @@ class ExpertSearchAdapter(
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
companion object {
const val HEADER_VIEW = 3
const val NORMAL_VIEW = 0
const val FOOT_VIEW = 1
const val EMPTY_VIEW = 2
}
interface OnClickLister {
fun onClick(searchWords:String)
}
private lateinit var mOnClickLister: OnClickLister
fun setOnClickLister(lister: OnClickLister) {
mOnClickLister = lister
}
//记录当前选择主题的id
var cateId: String?=null
var cateId: String? = null
var hasMore = true
var pageIndex: Int = 0
private var clickCount=0 // 搜索结果提示标签点击次数
fun setEntrance( pageIndex: Int) {
fun setEntrance(pageIndex: Int) {
this.pageIndex = pageIndex
}
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is NormalViewHolder) {
if (holder is HeaderViewHolder) { // 搜索结果提示头部
if (listData.size>0){
if (listData[0].is_head_view){
if (clickCount==0){
holder.clSearchWords.visibility = View.VISIBLE
var text = "根据匹配,为您推荐“${listData[0].related_word}”相关词"
holder.tvSearchRelatedWord.text = setTextBold(text,listData[0].related_word)
holder.tvSearchWord.text = listData[0].search_content
holder.tvSearchWord.setOnClickListener {
mOnClickLister.onClick(holder.tvSearchWord.text.toString())
++clickCount
if (clickCount==1){
text = "以下是“${listData[0].search_content}”的搜索结果"
holder.tvSearchRelatedWord.text = setTextBold(text,listData[0].search_content)
holder.tvSearchTips.text = "你要找的是不是"
holder.tvSearchWord.text = listData[0].related_word
}else if (clickCount==2){ // 第二次点击搜索标签隐藏搜索匹配结果提示
listData.removeAt(0)
}
}
}
}else {
holder.clSearchWords.visibility = View.GONE
// listData.removeAt(0)
}
}
} else if (holder is NormalViewHolder) {
val itemBean = listData[position]
//头像
val headConfig = SimpleImageOpConfiger()
......@@ -79,7 +122,7 @@ class ExpertSearchAdapter(
holder.tvName.text = itemBean.doctor_name
//服务中
if (itemBean.consult_status==2 || itemBean.listen_status==2) {
if (itemBean.open_chat_agency == 2 && itemBean.service_status == 2) {
holder.imgHead_online_server.visibility = View.VISIBLE
holder.chat_people_in_question.visibility = View.GONE
holder.imgHead_online.visibility = View.GONE
......@@ -100,7 +143,7 @@ class ExpertSearchAdapter(
}
//可预约
holder.imgHead_online_server.visibility = View.GONE
if (itemBean.booking_status <4) {
if (itemBean.is_free_today== 1) {
holder.imgHead_online.visibility = View.VISIBLE
} else {
holder.imgHead_online.visibility = View.GONE
......@@ -140,7 +183,7 @@ class ExpertSearchAdapter(
holder.imgFightEpidemicIcon.visibility = View.VISIBLE
}
if(itemBean.joinActivity==true ){
if (itemBean.joinActivity == true) {
//活动图标
if (!TextUtils.isEmpty(itemBean.activityImg)) {
holder.imgActivity.visibility = View.VISIBLE
......@@ -148,7 +191,7 @@ class ExpertSearchAdapter(
} else {
holder.imgActivity.visibility = View.GONE
}
}else{
} else {
holder.imgActivity.visibility = View.GONE
}
......@@ -183,7 +226,7 @@ class ExpertSearchAdapter(
holder.imgActivity.visibility = View.GONE
}
//新驻图标
if (itemBean.is_new_enter!=null&&itemBean.is_new_enter!!) {
if (itemBean.is_new_enter != null && itemBean.is_new_enter!!) {
if (null != itemBean.icons && !TextUtils.isEmpty(itemBean.icons.new_enter_icon)) {
expertSearchView.showImage(
itemBean.icons.new_enter_icon,
......@@ -228,22 +271,33 @@ class ExpertSearchAdapter(
//咨询师标签
holder.ll_tags.removeAllViews()
itemBean.feature_tags?.let {
if (it.isNotEmpty()){
for (tag in itemBean.feature_tags){
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_tag, holder.ll_tags, false)
if (it.isNotEmpty()) {
for (tag in itemBean.feature_tags) {
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_tag, holder.ll_tags, false)
tag.tag_name.let { name ->
if (name.length>4){
view.tvTag.text = "${name.substring(0,4)}…"
}else{
if (name.length > 4) {
view.tvTag.text = "${name.substring(0, 4)}…"
} else {
view.tvTag.text = name
}
}
if (tag.is_highlight){
if (tag.is_highlight) {
view.tvTag.setBackgroundResource(R.drawable.consultant_bg_radius_line_eb892c)
view.tvTag.setTextColor(ContextCompat.getColor(context,R.color.color_EB892C))
}else{
view.tvTag.setTextColor(
ContextCompat.getColor(
context,
R.color.color_EB892C
)
)
} else {
view.tvTag.setBackgroundResource(R.drawable.consultant_bg_radius_line_gray_1)
view.tvTag.setTextColor(ContextCompat.getColor(context,R.color.platform_color_666666))
view.tvTag.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_color_666666
)
)
}
holder.ll_tags.addView(view)
}
......@@ -261,7 +315,12 @@ class ExpertSearchAdapter(
R.color.platform_but_text_color
)
)
holder.tvChat.setTextColor(ContextCompat.getColor(context,R.color.platform_but_text_color))
holder.tvChat.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_but_text_color
)
)
holder.tvChat.background =
ContextCompat.getDrawable(context, R.drawable.consultant_expert_search_chat)
} else {
......@@ -279,7 +338,8 @@ class ExpertSearchAdapter(
}
//服务时长
val durationStringBuffer = StringBuffer()
holder.tvSaleDurationForMonth.text = durationStringBuffer.append(itemBean.sum_service_time.toInt()).append("").toString()
holder.tvSaleDurationForMonth.text =
durationStringBuffer.append(itemBean.sum_service_time.toInt()).append("").toString()
//价格
val price = BigDecimal(itemBean.min_price)
// 去掉末尾无用的.00
......@@ -316,8 +376,6 @@ class ExpertSearchAdapter(
}
}
}
} else if (holder is FooterViewHolder) {
LogUtil.e("${listData.size}")
LogUtil.e("${hasMore}")
......@@ -325,29 +383,35 @@ class ExpertSearchAdapter(
holder.itemView.visibility = View.VISIBLE
holder.pbLoading.visibility = View.VISIBLE
holder.tvHint.text = context.getString(R.string.consultant_loading)
} else{
} else {
holder.pbLoading.visibility = View.GONE
holder.tvHint.text = context.getString(R.string.platform_no_more)
}
}
}
override fun getItemCount(): Int = listData.size + 1
override fun getItemCount(): Int =
// if (listData.size < ExpertSearchActivity.PAGE_SIZE && hasMore) {
// listData.size
// } else {
// listData.size + 1
// }
if (listData.size==1) {
listData.size
} else {
listData.size + 1
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder =
when (viewType) {
HEADER_VIEW -> {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_expert_search_header_view, parent, false)
HeaderViewHolder(view)
}
NORMAL_VIEW -> {
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_expert_search_item_view, parent, false)
NormalViewHolder(view)
}
FOOT_VIEW -> {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_footer, parent, false)
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_footer, parent, false)
FooterViewHolder(view)
}
else -> {
......@@ -357,64 +421,96 @@ class ExpertSearchAdapter(
}
}
override fun getItemViewType(position: Int): Int = when {
position < listData.size -> NORMAL_VIEW
!hasMore && listData.size == 0 -> EMPTY_VIEW
else -> FOOT_VIEW
}
override fun getItemViewType(position: Int): Int =
when {
position==0 ->{
HEADER_VIEW
}
position>0&&position < listData.size -> {
NORMAL_VIEW
}
!hasMore && listData.size == 0 -> {
EMPTY_VIEW
}
else -> FOOT_VIEW
}
inner class NormalViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
//头像
val imgHead = itemView.imgHead!!
val cv_head_view = itemView.cv_head_view!!
//专家姓名
val tvName = itemView.tvName!!
//活动图标
val imgActivity = itemView.img_activity!!
//优质图标
val imgAbilityLevel = itemView.imgAbilityLevel!!
//公益图标
val imgServiceFree = itemView.imgServiceFree!!
//新驻图标
val imgNewEnter = itemView.imgNewEnter!!
//荣誉标签
val ll_honor_layout = itemView.ll_honor_layout!!
//好评率
val ll_feedbackRate = itemView.ll_feedbackRate!!
//xxx人点评
val tv_zixunOrderNum = itemView.tv_zixunOrderNum!!
//咨询师简介
val tvTeamCertifications = itemView.tvTeamCertifications!!
//咨询师标签
val ll_tags = itemView.ll_tags!!
//帮助人数
val tvOrderNum = itemView.tvOrderNum!!
//帮助人数文案
val tvOrderNumContent = itemView.tvOrderNumContent
//服务时长
val tvSaleDurationForMonth = itemView.tvSaleDurationForMonth!!
//月售时长文案
val tvSaleDurationForMonthContent = itemView.tvSaleDurationForMonthContent
//价格
val tvPrice = itemView.tvPrice!!
val tvPriceContent = itemView.tvPriceContent!!
val tv_money_symbol = itemView.tv_money_symbol!!
//服务套餐
val ll_products = itemView.ll_products!!
//私聊按钮
val tvChat = itemView.tvChat!!
//个人铭言整个布局
val group_desc = itemView.group_desc!!
//个人铭言
val tvDesc = itemView.tvDesc!!
//省市
val tvCity = itemView.tvCity!!
//今日是否可约
val imgHead_online = itemView.imgHead_online!!
//服务中(咨询中或者聆听中)
val imgHead_online_server = itemView.imgHead_online_server!!
//多少人在问询
val chat_people_in_question = itemView.people_in_question!!
// 抗疫先锋图标
val imgFightEpidemicIcon = itemView.img_fightEpidemicIcon
......@@ -431,7 +527,13 @@ class ExpertSearchAdapter(
TempH5RouteUtils.tempH5Route(linkUrl)
// 埋点
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,ConsultBIConstants.ConsultEvent.POSITION_CONSULT_COUNSELOR_CARD_CLICK,itemBean.id?:"","app","")
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_CONSULT_COUNSELOR_CARD_CLICK,
itemBean.id ?: "",
"app",
""
)
}
}
......@@ -450,7 +552,7 @@ class ExpertSearchAdapter(
)
}
//判断是否已登录
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(context,true)) {
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(context, true)) {
return@setOnClickListener
}
......@@ -467,6 +569,13 @@ class ExpertSearchAdapter(
}
}
inner class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val clSearchWords = itemView.cl_search_words
val tvSearchRelatedWord = itemView.tv_search_related_word
val tvSearchTips = itemView.tv_search_tips
val tvSearchWord = itemView.tv_search_word
}
inner class FooterViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val pbLoading = itemView.pbLoading!!
val tvHint = itemView.tvHint!!
......@@ -482,4 +591,22 @@ class ExpertSearchAdapter(
}
}
}
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)
}
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ class IHotSearchContract {
/**
* 联想词请求成功结果
*/
fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean)
fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean)
}
interface Presenter : IPresenter<View> {
......@@ -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 {
......
......@@ -95,18 +95,25 @@ data class ExpertServiceItem(
* 标签图片
*/
val icons: ExpertSearchTagsIconBean?,
/**
* 今日是否可约
*/
val booking_status: Int,
/**
* 咨询状态 1-待服务 2-服务中
*/
var consult_status: Int,
/**
* 倾诉状态 1-待服务 2-服务中
*/
var listen_status: Int,
// /**
// * 今日是否可约
// */
// val booking_status: Int,
// /**
// * 咨询状态 1-待服务 2-服务中
// */
// var consult_status: Int,
// /**
// * 倾诉状态 1-待服务 2-服务中
// */
// 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(
/**
* 新标签分类
*/
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(
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
import android.content.Context
import android.text.TextUtils
import com.google.gson.Gson
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils
......@@ -17,7 +16,6 @@ import com.yidianling.consultant.model.HotSearchModelImpl
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
import java.util.concurrent.TimeUnit
/**
* @author yuanwai
......@@ -62,6 +60,7 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch
/**
* 搜索页接口
*/
@SuppressLint("CheckResult")
override fun searchData() {
mModel.searchData().map { it }
.filter { it != null }
......@@ -78,14 +77,14 @@ class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearch
}
@SuppressLint("CheckResult")
override fun getSearchWords(map:HashMap<String,Any>) {
override fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean) {
mModel.getSearchWords(map)
.debounce(500L, TimeUnit.MILLISECONDS)
// .debounce(500L, TimeUnit.MILLISECONDS)
.compose(RxLifecycleUtils.bindToLifecycle(mView))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.getSearchWordsSuccess(it)
mView.getSearchWordsSuccess(it,searchContent,isClickWords)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
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 @@
android:layout_width="match_parent"
android:layout_height="6dp"
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>
......
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