Commit 3dd1ce7c by fengquan

fix: code review

parent a231a39b
......@@ -38,10 +38,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)
......@@ -88,7 +89,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 {
......@@ -99,21 +101,21 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
// 搜索的关联词
var relatedWords = ""
var isRecommendWords = false
if (searchSuggestList.isNotEmpty()&&searchSuggestList.size>0){
if (searchSuggestList[0].suggest_relations.size>0){
if (searchSuggestList.isNotEmpty() && searchSuggestList.size > 0) {
if (searchSuggestList[0].suggest_relations.size > 0) {
relatedWords = searchSuggestList[0].suggest_relations[0]
isRecommendWords = true
}
if (TextUtils.isEmpty(relatedWords)&&!TextUtils.isEmpty(searchSuggestList[0].suggest_content)){
if (TextUtils.isEmpty(relatedWords) && !TextUtils.isEmpty(searchSuggestList[0].suggest_content)) {
relatedWords = searchSuggestList[0].suggest_content
}
doSearch(etSearch.text.toString(),relatedWords,isRecommendWords)
}else{
doSearch(etSearch.text.toString(), relatedWords, isRecommendWords)
} 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)
}
}
}
......@@ -129,8 +131,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)
......@@ -138,7 +140,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"
)
}
}
......@@ -149,29 +155,35 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
// 搜索的关联词
var relatedWords = ""
var isRecommendWords = false
if (searchSuggestList.isNotEmpty()&&searchSuggestList.size>0){
if (searchSuggestList[position].suggest_relations.size>0){
if (searchSuggestList.isNotEmpty() && searchSuggestList.size > 0) {
if (searchSuggestList[position].suggest_relations.size > 0) {
relatedWords = searchSuggestList[position].suggest_relations[0]
isRecommendWords = true
}
if (TextUtils.isEmpty(relatedWords)&&!TextUtils.isEmpty(searchSuggestList[position].suggest_content)){
if (TextUtils.isEmpty(relatedWords) && !TextUtils.isEmpty(searchSuggestList[position].suggest_content)) {
relatedWords = searchSuggestList[position].suggest_content
}
}
doSearch(searchSuggestList[position].suggest_content,relatedWords,isRecommendWords)
doSearch(searchSuggestList[position].suggest_content, relatedWords, isRecommendWords)
// 埋点
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,ConsultBIConstants.POSITION_YDL_USER_ASSOCIATE_WORD_CLICK,etSearch.text.toString(),searchSuggestList[position].suggest_content,"app")
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,
ConsultBIConstants.POSITION_YDL_USER_ASSOCIATE_WORD_CLICK,
etSearch.text.toString(),
searchSuggestList[position].suggest_content,
"app"
)
}
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("",false)
getSearchWords("", false)
} else {
iv_delete_icon.visibility = View.VISIBLE
getSearchWords(s.toString(),false)
getSearchWords(s.toString(), false)
}
}
......@@ -190,43 +202,53 @@ 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) {
// 搜索的关联词
var relatedWords = ""
var isRecommendWords = false
if (!searchWordsBean.search_suggests.isNullOrEmpty()&&searchWordsBean.search_suggests.size>0){
if (searchWordsBean.search_suggests[0].suggest_relations.size>0){
if (!searchWordsBean.search_suggests.isNullOrEmpty() && searchWordsBean.search_suggests.size > 0) {
if (searchWordsBean.search_suggests[0].suggest_relations.size > 0) {
relatedWords = searchWordsBean.search_suggests[0].suggest_relations[0]
isRecommendWords = true
}
if (TextUtils.isEmpty(relatedWords)&&!TextUtils.isEmpty(searchWordsBean.search_suggests[0].suggest_content)){
if (TextUtils.isEmpty(relatedWords) && !TextUtils.isEmpty(searchWordsBean.search_suggests[0].suggest_content)) {
relatedWords = searchWordsBean.search_suggests[0].suggest_content
}
}
doSearch(searchContent,relatedWords,isRecommendWords)
}else{
doSearch(searchContent, relatedWords, isRecommendWords)
} 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
}
}
......@@ -272,7 +294,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 {
getSearchWords(keywordData[index].keyword!!,true)
getSearchWords(keywordData[index].keyword!!, true)
}
flHotSearch.addView(view)
}
......@@ -304,7 +326,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
}
view.setOnClickListener {
getSearchWords(hotSearchExpert[index].name!!,true)
getSearchWords(hotSearchExpert[index].name!!, true)
}
flHotExpert.addView(view)
}
......@@ -366,7 +388,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
break
}
view.setOnClickListener {
getSearchWords(historyStr,true)
getSearchWords(historyStr, true)
}
fl_search_history.addView(view)
}
......@@ -386,14 +408,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)
......@@ -402,7 +424,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()
}
......
......@@ -37,7 +37,11 @@ import kotlin.math.roundToInt
* 筛选弹窗
* Created by zqk on 17-9-15.
*/
class FilterPopupWindow(private val context: Context, private val filterData: Filters, private val tempFilter: AllFilter) : PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
class FilterPopupWindow(
private val context: Context,
private val filterData: Filters,
private val tempFilter: AllFilter
) : PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
private val mDisposableList = CompositeDisposable()
......@@ -157,12 +161,12 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
showTypeViews[1].isSelected = true
for (v in enquiryViews) {
v.isSelected = false
val textView:TextView = v.findViewById(R.id.tvFilterName)
val ivIcon:ImageView = v.findViewById(R.id.iv_consultant_method)
val textView: TextView = v.findViewById(R.id.tvFilterName)
val ivIcon: ImageView = v.findViewById(R.id.iv_consultant_method)
textView.paint.isFakeBoldText = false
tempFilter.enquiries.forEach {
if (textView.text.toString() == it.value){
if (textView.text.toString() == it.value) {
Glide.with(context)
.load(it.unCheckUrl)
.into(ivIcon)
......@@ -176,7 +180,7 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
v.paint.isFakeBoldText = false
}
}
for (v in goodAtViews){
for (v in goodAtViews) {
v.isSelected = false
v.paint.isFakeBoldText = false
}
......@@ -333,6 +337,7 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
fun addSubscription(disposable: Disposable) {
mDisposableList.add(disposable)
}
/**
* 其他选择
* */
......@@ -421,13 +426,13 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
if (text == "展开") {
view.tv_crowd_open.text = "收起"
view.iv_crowd_open.setImageResource(R.drawable.ic_crowd_close)
for (i in 20 until goodAtViews.size){
for (i in 20 until goodAtViews.size) {
goodAtViews[i].visibility = View.VISIBLE
}
} else {
view.tv_crowd_open.text = "展开"
view.iv_crowd_open.setImageResource(R.drawable.ic_crowd_open)
for (i in 20 until goodAtViews.size){
for (i in 20 until goodAtViews.size) {
goodAtViews[i].visibility = View.GONE
}
}
......@@ -460,7 +465,7 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
}
}
if (index>19){
if (index > 19) {
textView.visibility = View.GONE
}
goodAtViews.add(textView)
......@@ -468,6 +473,7 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
}
}
/**
* 年龄
* */
......@@ -508,6 +514,7 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
view.flAge.addView(textView)
}
}
/**
* 学历
* */
......@@ -553,8 +560,8 @@ class FilterPopupWindow(private val context: Context, private val filterData: Fi
val mWidth = (popWidth - RxImageTool.dp2px(52f)) / enquirySize
for ((index, enquiry) in filterData.enquiry.withIndex()) {
val llLayout = View.inflate(context, R.layout.consultant_method_item_filter, null)
val textView:TextView = llLayout.findViewById(R.id.tvFilterName)
val ivIcon:ImageView = llLayout.findViewById(R.id.iv_consultant_method)
val textView: TextView = llLayout.findViewById(R.id.tvFilterName)
val ivIcon: ImageView = llLayout.findViewById(R.id.iv_consultant_method)
val params = FrameLayout.LayoutParams(mWidth, RxImageTool.dp2px(36f))
val marginNum = RxImageTool.dp2px(5f)
params.setMargins(
......
......@@ -137,7 +137,7 @@ public class MembersActivity extends BaseActivity implements View.OnClickListene
initListeners();
// initDatas();
setTabSelection(0);
StatusBarUtils.Companion.setCustomStatusView(this,members_title_rel,true);
StatusBarUtils.Companion.setCustomStatusViewForMembers(this,members_title_rel,true);
}
private void initEvent() {
......
......@@ -1092,6 +1092,20 @@ class StatusBarUtils {
setTransparentForImageView(context, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(context)
params.height = RxImageTool.dp2px(48f) + statusBarHeight
statusView.setPadding(0, statusBarHeight, 0, 0)
if (isDarkMode) {
statusBarLightMode(context)
}
}
/**
* 适配 One Plus手机顶部返回按钮被截取问题
*/
fun setCustomStatusViewForMembers(context: Activity,statusView:View,isDarkMode:Boolean = false) {
val params = statusView.layoutParams
setTransparentForImageView(context, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(context)
params.height = RxImageTool.dp2px(48f) + statusBarHeight
statusView.setPadding(0, statusBarHeight - 25, 0, 0)
if (isDarkMode) {
statusBarLightMode(context)
......
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