Commit e5e1c1df by 霍志良

feat:热门词修改

parent 5105a007
...@@ -41,10 +41,11 @@ import kotlinx.android.synthetic.main.consultant_activity_hot_search.* ...@@ -41,10 +41,11 @@ 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.*
@Route(path = "/consult/hot_search") @Route(path = "/consult/hot_search")
class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchContract.Presenter>(), IHotSearchContract.View { class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchContract.Presenter>(),
private lateinit var searchWordsAdapter:SearchWordsAdapter IHotSearchContract.View {
private lateinit var searchWordsAdapter: SearchWordsAdapter
private val searchSuggestList: ArrayList<SearchSuggestListBean> = ArrayList() private val searchSuggestList: ArrayList<SearchSuggestListBean> = ArrayList()
private var mSearchContent:String = "" private var mSearchContent: String = ""
private val CACHE_CONSULT_SEARCH_HISTORY_DATA = "cache_consult_search_history_data" private val CACHE_CONSULT_SEARCH_HISTORY_DATA = "cache_consult_search_history_data"
private val HOT_SEARCH_DOCTOR_NAME = "hot_search_doctor_name" private val HOT_SEARCH_DOCTOR_NAME = "hot_search_doctor_name"
private var historyList: FixSizeLinkedList<String> = FixSizeLinkedList(15) private var historyList: FixSizeLinkedList<String> = FixSizeLinkedList(15)
...@@ -91,7 +92,8 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -91,7 +92,8 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
private fun initViews() { private fun initViews() {
StatusBarUtils.statusBarLightMode(this) StatusBarUtils.statusBarLightMode(this)
maxWidth = (2 * RxDeviceTool.getScreenWidth(this@HotSearchActivity)) - RxImageTool.dip2px(60f) maxWidth =
(2 * RxDeviceTool.getScreenWidth(this@HotSearchActivity)) - RxImageTool.dip2px(60f)
dp42 = RxImageTool.dip2px(60f) dp42 = RxImageTool.dip2px(60f)
iv_delete_icon.setOnClickListener { iv_delete_icon.setOnClickListener {
...@@ -102,7 +104,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -102,7 +104,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
// 搜索的关联词 // 搜索的关联词
var relatedWords = "" var relatedWords = ""
var isRecommendWords = false var isRecommendWords = false
if (searchSuggestList.isNotEmpty()&&searchSuggestList.size>0) { if (searchSuggestList.isNotEmpty() && searchSuggestList.size > 0) {
if (searchSuggestList[0].suggest_relations.size > 0) { if (searchSuggestList[0].suggest_relations.size > 0) {
relatedWords = searchSuggestList[0].suggest_relations[0] relatedWords = searchSuggestList[0].suggest_relations[0]
isRecommendWords = true isRecommendWords = true
...@@ -116,12 +118,12 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -116,12 +118,12 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} else { } else {
doSearch(etSearch.text.toString(), relatedWords, isRecommendWords) doSearch(etSearch.text.toString(), relatedWords, isRecommendWords)
} }
}else{ } else {
val searchWords = etSearch.text.toString() val searchWords = etSearch.text.toString()
if (TextUtils.isEmpty(searchWords)){ if (TextUtils.isEmpty(searchWords)) {
doSearch(searchWords,"",isRecommendWords) doSearch(searchWords, "", isRecommendWords)
}else{ } else {
getSearchWords(etSearch.text.toString(),true) getSearchWords(etSearch.text.toString(), true)
} }
} }
} }
...@@ -137,8 +139,8 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -137,8 +139,8 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
val data = ModularServiceManager.provide(IConsultantService::class.java).getGuideImage(5) val data = ModularServiceManager.provide(IConsultantService::class.java).getGuideImage(5)
if (data?.size ?: 0 > 0) { if (data?.size ?: 0 > 0) {
val imageUrl= data?.get(0)?.pic val imageUrl = data?.get(0)?.pic
iv_daoyi_image.visibility=View.VISIBLE iv_daoyi_image.visibility = View.VISIBLE
GlideApp.with(mContext) GlideApp.with(mContext)
.load(imageUrl) .load(imageUrl)
...@@ -146,7 +148,11 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -146,7 +148,11 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
iv_daoyi_image.setOnClickListener { iv_daoyi_image.setOnClickListener {
LogUtil.e("跳转导医:location=${data?.get(0)!!.location},title=${data[0].title}") LogUtil.e("跳转导医:location=${data?.get(0)!!.location},title=${data[0].title}")
ConsultAssistantEntryUtils.jumpConsultAssistant(this, data[0].location.toInt(),"learning") ConsultAssistantEntryUtils.jumpConsultAssistant(
this,
data[0].location.toInt(),
"learning"
)
} }
} }
...@@ -190,10 +196,10 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -190,10 +196,10 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
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("",false) getSearchWords("", false)
} else { } else {
iv_delete_icon.visibility = View.VISIBLE iv_delete_icon.visibility = View.VISIBLE
getSearchWords(s.toString(),false) getSearchWords(s.toString(), false)
} }
} }
...@@ -212,19 +218,23 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -212,19 +218,23 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
* 获取搜索联想词 * 获取搜索联想词
* @param isClickWords 是否是点击历史搜索、热门搜索等进行搜索 * @param isClickWords 是否是点击历史搜索、热门搜索等进行搜索
*/ */
private fun getSearchWords(searchContent:String,isClickWords:Boolean){ 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,searchContent,isClickWords) mPresenter.getSearchWords(map, searchContent, isClickWords)
}else{ } else {
rv_search_words.visibility = View.GONE rv_search_words.visibility = View.GONE
} }
} }
override fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean) { override fun getSearchWordsSuccess(
if (isClickWords){ searchWordsBean: SearchWordsBean,
searchContent: String,
isClickWords: Boolean
) {
if (isClickWords) {
//判断 suggest_classify_types 有值则通过 jump_url跳转 //判断 suggest_classify_types 有值则通过 jump_url跳转
// 搜索的关联词 // 搜索的关联词
var relatedWords = "" var relatedWords = ""
...@@ -249,17 +259,23 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -249,17 +259,23 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} else { } else {
doSearch(searchContent, relatedWords, isRecommendWords) doSearch(searchContent, relatedWords, isRecommendWords)
} }
}else{ } else {
searchSuggestList.clear() searchSuggestList.clear()
if (!searchWordsBean.search_suggests.isNullOrEmpty()){ if (!searchWordsBean.search_suggests.isNullOrEmpty()) {
rv_search_words.visibility = View.VISIBLE rv_search_words.visibility = View.VISIBLE
searchSuggestList.addAll(searchWordsBean.search_suggests) searchSuggestList.addAll(searchWordsBean.search_suggests)
searchWordsAdapter.notifyDataAndSetSearchWord(mSearchContent) searchWordsAdapter.notifyDataAndSetSearchWord(mSearchContent)
// 埋点 // 埋点
val sign2 = searchSuggestList.joinToString(","){it.suggest_content} val sign2 = searchSuggestList.joinToString(",") { it.suggest_content }
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,ConsultBIConstants.POSITION_YDL_USER_ASSOCIATE_WORD_VISIT,searchContent,sign2,"app") ActionCountUtils.baiDuCountSign3(
}else{ ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,
ConsultBIConstants.POSITION_YDL_USER_ASSOCIATE_WORD_VISIT,
searchContent,
sign2,
"app"
)
} else {
rv_search_words.visibility = View.GONE rv_search_words.visibility = View.GONE
} }
} }
...@@ -344,7 +360,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -344,7 +360,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} }
} }
view.setOnClickListener { view.setOnClickListener {
getSearchWords(etSearch.text.toString(),true) getSearchWords(etSearch.text.toString(), true)
} }
flHotExpert.addView(view) flHotExpert.addView(view)
} }
...@@ -406,7 +422,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -406,7 +422,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
break break
} }
view.setOnClickListener { view.setOnClickListener {
getSearchWords(historyStr,true) getSearchWords(historyStr, true)
} }
fl_search_history.addView(view) fl_search_history.addView(view)
} }
...@@ -426,14 +442,14 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -426,14 +442,14 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
* 搜索 * 搜索
* @param isRecommendWords 是否是推荐词 * @param isRecommendWords 是否是推荐词
*/ */
private fun doSearch(searchWords:String,relatedWords:String,isRecommendWords:Boolean) { private fun doSearch(searchWords: String, relatedWords: String, isRecommendWords: Boolean) {
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)
} }
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)
historyList.add(searchWords) historyList.add(searchWords)
...@@ -442,7 +458,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon ...@@ -442,7 +458,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
Gson().toJson(historyList) Gson().toJson(historyList)
) )
} }
ExpertSearchActivity.startSearch(this, searchWords,"14",relatedWords,isRecommendWords) ExpertSearchActivity.startSearch(this, searchWords, "14", relatedWords, isRecommendWords)
finish() finish()
} }
......
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