Commit e5e1c1df by 霍志良

feat:热门词修改

parent 5105a007
......@@ -41,10 +41,11 @@ import kotlinx.android.synthetic.main.consultant_activity_hot_search.*
import kotlinx.android.synthetic.main.consultant_item_expert_hot_search.view.*
@Route(path = "/consult/hot_search")
class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchContract.Presenter>(), IHotSearchContract.View {
private lateinit var searchWordsAdapter:SearchWordsAdapter
class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchContract.Presenter>(),
IHotSearchContract.View {
private lateinit var searchWordsAdapter: SearchWordsAdapter
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 HOT_SEARCH_DOCTOR_NAME = "hot_search_doctor_name"
private var historyList: FixSizeLinkedList<String> = FixSizeLinkedList(15)
......@@ -91,7 +92,8 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
private fun initViews() {
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)
iv_delete_icon.setOnClickListener {
......@@ -102,7 +104,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
// 搜索的关联词
var relatedWords = ""
var isRecommendWords = false
if (searchSuggestList.isNotEmpty()&&searchSuggestList.size>0) {
if (searchSuggestList.isNotEmpty() && searchSuggestList.size > 0) {
if (searchSuggestList[0].suggest_relations.size > 0) {
relatedWords = searchSuggestList[0].suggest_relations[0]
isRecommendWords = true
......@@ -116,12 +118,12 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} else {
doSearch(etSearch.text.toString(), relatedWords, isRecommendWords)
}
}else{
} else {
val searchWords = etSearch.text.toString()
if (TextUtils.isEmpty(searchWords)){
doSearch(searchWords,"",isRecommendWords)
}else{
getSearchWords(etSearch.text.toString(),true)
if (TextUtils.isEmpty(searchWords)) {
doSearch(searchWords, "", isRecommendWords)
} else {
getSearchWords(etSearch.text.toString(), true)
}
}
}
......@@ -137,8 +139,8 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
val data = ModularServiceManager.provide(IConsultantService::class.java).getGuideImage(5)
if (data?.size ?: 0 > 0) {
val imageUrl= data?.get(0)?.pic
iv_daoyi_image.visibility=View.VISIBLE
val imageUrl = data?.get(0)?.pic
iv_daoyi_image.visibility = View.VISIBLE
GlideApp.with(mContext)
.load(imageUrl)
......@@ -146,7 +148,11 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
iv_daoyi_image.setOnClickListener {
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
if (TextUtils.isEmpty(s)) {
iv_delete_icon.visibility = View.INVISIBLE
rv_search_words.visibility = View.GONE
getSearchWords("",false)
getSearchWords("", false)
} else {
iv_delete_icon.visibility = View.VISIBLE
getSearchWords(s.toString(),false)
getSearchWords(s.toString(), false)
}
}
......@@ -212,19 +218,23 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
* 获取搜索联想词
* @param isClickWords 是否是点击历史搜索、热门搜索等进行搜索
*/
private fun getSearchWords(searchContent:String,isClickWords:Boolean){
if (!TextUtils.isEmpty(searchContent)){
private fun getSearchWords(searchContent: String, isClickWords: Boolean) {
if (!TextUtils.isEmpty(searchContent)) {
mSearchContent = searchContent
val map = HashMap<String, Any>()
map["content"] = searchContent
mPresenter.getSearchWords(map,searchContent,isClickWords)
}else{
mPresenter.getSearchWords(map, searchContent, isClickWords)
} else {
rv_search_words.visibility = View.GONE
}
}
override fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean) {
if (isClickWords){
override fun getSearchWordsSuccess(
searchWordsBean: SearchWordsBean,
searchContent: String,
isClickWords: Boolean
) {
if (isClickWords) {
//判断 suggest_classify_types 有值则通过 jump_url跳转
// 搜索的关联词
var relatedWords = ""
......@@ -249,17 +259,23 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
} else {
doSearch(searchContent, relatedWords, isRecommendWords)
}
}else{
} else {
searchSuggestList.clear()
if (!searchWordsBean.search_suggests.isNullOrEmpty()){
if (!searchWordsBean.search_suggests.isNullOrEmpty()) {
rv_search_words.visibility = View.VISIBLE
searchSuggestList.addAll(searchWordsBean.search_suggests)
searchWordsAdapter.notifyDataAndSetSearchWord(mSearchContent)
// 埋点
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")
}else{
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"
)
} else {
rv_search_words.visibility = View.GONE
}
}
......@@ -344,7 +360,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
}
view.setOnClickListener {
getSearchWords(etSearch.text.toString(),true)
getSearchWords(etSearch.text.toString(), true)
}
flHotExpert.addView(view)
}
......@@ -406,7 +422,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
break
}
view.setOnClickListener {
getSearchWords(historyStr,true)
getSearchWords(historyStr, true)
}
fl_search_history.addView(view)
}
......@@ -426,14 +442,14 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
* 搜索
* @param isRecommendWords 是否是推荐词
*/
private fun doSearch(searchWords:String,relatedWords:String,isRecommendWords:Boolean) {
private fun doSearch(searchWords: String, relatedWords: String, isRecommendWords: Boolean) {
val view = this.currentFocus
if (view != null) {
val imm = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
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)) {
historyList.remove(searchWords)
historyList.add(searchWords)
......@@ -442,7 +458,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
Gson().toJson(historyList)
)
}
ExpertSearchActivity.startSearch(this, searchWords,"14",relatedWords,isRecommendWords)
ExpertSearchActivity.startSearch(this, searchWords, "14", relatedWords, isRecommendWords)
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