Commit a58adebe by 刘鹏

Merge branch 'feature/yk_sort' into 'd/v_sort'

Feature/yk sort

See merge request app_android_lib/YDL-Component!138
parents a5d2d185 342290e2
......@@ -188,12 +188,7 @@ dependencies {
implementation(rootProject.ext.dependencies["espresso-core"])
implementation(rootProject.ext.dependencies["okhttp3"])
// TPNS SDK 主工程依赖包
// implementation 'com.tencent.liteav:LiteAVSDK_TRTC:latest.release'
if (true) {
//开发模式
implementation fileTree(dir: 'aars', include: ['*.aar'])
implementation project(':m-user')
implementation modularPublication('com.ydl:m-user-api')
......@@ -202,50 +197,26 @@ dependencies {
api project(':m-consultant')
implementation modularPublication('com.ydl:m-consultant-api')
api project(':m-tests')
api project(':m-home')
api project(':m-confide')
implementation project(':ydl-flutter-base')
api(project(':ydl-platform')) {
transitive = true
}
implementation project(':ydl-webview')
implementation project(':ydl-media')
implementation project(':m-muse')
implementation project(':m-im')
implementation modularPublication('com.ydl:m-im-api')
implementation project(':m-dynamic')
implementation project(':m-course')
//文章模块
implementation project(':m-article')
implementation project(':m-audioim')
implementation modularPublication('com.ydl:m-audioim-api')
implementation project(':m-fm')
implementation modularPublication('com.ydl:m-fm-api')
implementation project(':ydl-tuicore')
} else {
//发布模式
api 'com.ydl:m-user-module-ydl:0.0.6'
api rootProject.ext.dependencies["ydl-webview"]
api rootProject.ext.dependencies["ydl-m-user-api"]
api rootProject.ext.dependencies["ydl-m-fm-api"]
api rootProject.ext.dependencies["m-article"]
api(rootProject.ext.dependencies["ydl-platform"]) {
transitive = true
}
api(rootProject.ext.dependencies["ydl-tuicalling"]) {
transitive = true
}
}
implementation rootProject.ext.dependencies["retrofit-url-manager"]
kapt 'com.alibaba:arouter-compiler:1.2.2'
......
......@@ -21,9 +21,9 @@ import java.util.List;
public final class DemoGlobalConfig implements IConfigModule {
String APP_DOMAIN = "https://api.github.com/";
// public static String appEnv = YDLConstants.ENV_AUTO_TEST;
// public static String appEnv = YDLConstants.ENV_TEST;
public static String appEnv = YDLConstants.ENV_TEST;
// public static String appEnv = YDLConstants.ENV_NEW_TEST;//配置未上传到maven库
public static String appEnv = YDLConstants.ENV_PROD;
// public static String appEnv = YDLConstants.ENV_PROD;
@Override
public void injectAppLifecycle(@NotNull Context context, @NotNull List<IAppLifecycles> lifecycles) {
lifecycles.add(new DemoAppLifecycles());
......
......@@ -6,10 +6,10 @@ ext {
// -------------- 业务模块 --------------
//第三步 若干
"m-confide" : "0.0.49.72",
"m-consultant" : "0.0.60.21",
"m-consultant" : "0.0.60.61",
"m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04",
"m-home" : "0.0.23.44",
"m-home" : "0.0.23.80",
"m-im" : "0.0.21.33",
"m-dynamic" : "0.0.7.37",
"m-article" : "0.0.0.10",
......@@ -27,7 +27,7 @@ ext {
"m-muse-api" : "0.0.1",
"m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.19",
"m-home-api" : "0.0.4.2",
"m-home-api" : "0.0.4.4",
"m-im-api" : "0.0.12.24",
"m-dynamic-api" : "0.0.3.71",
//-------------- 功能组件 --------------
......@@ -35,7 +35,7 @@ ext {
//mdt 组件
"ydl-tuicore" : "0.0.22",
//第一步
"ydl-platform" : "0.0.40.97",
"ydl-platform" : "0.0.41.25",
//第二步 若干
"ydl-webview" : "0.0.38.62",
......@@ -46,7 +46,7 @@ ext {
//以下 几乎不会动
"router" : "0.0.1",
"ydl-net" : "0.0.3.93",
"ydl-net" : "0.0.3.94",
"ydl-utils" : "0.0.3.3",
]
ydl_app = [
......@@ -92,7 +92,7 @@ ext {
//第三步 若干
"m-confide" : "0.0.49.72",
"m-consultant" : "0.0.60.21",
"m-consultant" : "0.0.60.61",
"m-fm" : "0.0.30.08",
"m-user" : "0.0.62.04",
"m-home" : "0.0.23.41",
......@@ -112,7 +112,7 @@ ext {
"m-muse-api" : "0.0.1",
"m-tests-api" : "0.0.2",
"m-user-api" : "0.0.10.19",
"m-home-api" : "0.0.4.2",
"m-home-api" : "0.0.4.4",
"m-im-api" : "0.0.12.24",
"m-dynamic-api" : "0.0.3.71",
//-------------- 功能组件 --------------
......@@ -130,7 +130,7 @@ ext {
//以下 几乎不会动
"router" : "0.0.1",
"ydl-net" : "0.0.3.93",
"ydl-net" : "0.0.3.94",
"ydl-utils" : "0.0.3.3",
]
......
......@@ -68,7 +68,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
kapt 'com.alibaba:arouter-compiler:1.2.2'
implementation rootProject.ext.dependencies["BaseRecyclerViewAdapterHelper"]
api rootProject.ext.dependencies["ydl-user-router"]
if (rootProject.ext.dev_mode){
//开发时使用
......
......@@ -8,9 +8,8 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Typeface
import android.os.Build
import android.os.Handler
import android.text.TextUtils
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import android.view.inputmethod.InputMethodManager
......@@ -34,12 +33,10 @@ import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.bean.StatusBarOptions
import com.ydl.ydlcommon.ui.LogoLoadingView
import com.ydl.ydlcommon.utils.BuryPointUtils
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.adapter.ExpertSearchAdapter
......@@ -94,7 +91,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun initDataAndEvent() {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE or WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
initViews()
initData(intent)
initData(intent, false)
rl_hot_fix_for_huawei.visibility = View.VISIBLE
}
......@@ -111,6 +108,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
const val HOT_SEARCH_DOCTOR_NAME = "hot_search_doctor_name"
private const val EXTRA_IS_SHOW_HOT = "isInitShowHot"
private const val EXTRA_SEARCH_WORD = "searchWord"
private const val EXTRA_RELATED_WORD = "related_word"
private const val EXTRA_IS_RECCOMMEND_WORD = "is_reccommend_word"
private const val EXTRA_IS_FROM_SPLASH = "isFromSplash"
private const val FILTER_STATUS_NORMAL = 0 //默认筛选状态
private const val FILTER_STATUS_FILTERED = 1 //非默认筛选状态
......@@ -147,9 +146,24 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
context.startActivity(intent)
}
fun startSearch(context: Context, searchWord: String?) {
/**
* 搜索页面过来的
* @param sign2为14 仅用于埋点
* @param relatedWord 搜索内容的关联词
* @param isRecommendWords 是否是推荐词
*/
fun startSearch(
context: Context,
searchWord: String?,
sign2: String,
relatedWord: String,
isRecommendWords: Boolean
) {
val intent = Intent(context, ExpertSearchActivity::class.java)
intent.putExtra(EXTRA_SEARCH_WORD, searchWord)
intent.putExtra(EXTRA_RELATED_WORD, relatedWord)
intent.putExtra(EXTRA_IS_RECCOMMEND_WORD, isRecommendWords)
intent.putExtra("sign2", sign2)
context.startActivity(intent)
}
......@@ -177,8 +191,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
private val allFilter = AllFilter() //当前筛选
private val tempFilter = AllFilter() //临时筛选,未确认状态
private var curPage = 1
private val doctorList = ArrayList<DoctorServiceItem>()
private val serviceList = ArrayList<DoctorServiceItem>()
private val doctorList = ArrayList<ExpertServiceItem>()
private var hasMore = true
private var initCategory = "0"
private var initShowType: Int = 1
......@@ -188,11 +201,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
private var isFromSplash = false
private val props1 = JSONObject() //筛选标题埋点参数
private var fromPageType: Int = 1 //从哪个页面跳转过来的
private val fromPages = arrayOf("首页", "搜索页面", "在线专家")
private var isRecommend = false //埋点数据
private var keyWord: String? = null //埋点数据
private var cateName: String? = null
private var mSign2: String = "" // 用于搜索页面进来的埋点参数
private var isDoSearch: Boolean = false //埋点判断是否通过搜索进入埋点的
private val bannerList = ArrayList<String>()
private var hasSelectedArea = false //是否选择过地区
private var hasSelectedSort = false //是否选择过排序
......@@ -226,26 +238,21 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
initNetLossView()
// etSearch.setOnEditorActionListener { _, actionId, _ ->
// if (actionId == EditorInfo.IME_ACTION_SEARCH) {
// doSearch()
// }
// true
// }
// etSearch.setOnClickListener { appbar_layout.setExpanded(false) }
// etSearch.setOnFocusChangeListener { view, b -> if (b) appbar_layout.setExpanded(false) }
btn_back.setOnClickListener {
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
......@@ -276,10 +283,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
override fun onScrollTop() {
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator =
val alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
val scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
val scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
val animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() {
......@@ -295,10 +302,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
if (isBtnShow) {
return
}
var alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f)
var animator =
val alpha = PropertyValuesHolder.ofFloat("alpha", 0f, 1f)
val scaleX = PropertyValuesHolder.ofFloat("scaleX", 0f, 1f)
val scaleY = PropertyValuesHolder.ofFloat("scaleY", 0f, 1f)
val animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() {
......@@ -314,10 +321,10 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
if (!isBtnShow) {
return
}
var alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
var scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
var scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
var animator =
val alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f)
val scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 0f)
val scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f)
val animator =
ObjectAnimator.ofPropertyValuesHolder(image_scroll_top, alpha, scaleX, scaleY)
.setDuration(200)
animator.addListener(object : AnimatorListenerAdapter() {
......@@ -331,24 +338,12 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun onLoadMore(page: Int, totalItemsCount: Int, view: RecyclerView?) {
if (hasMore) {
curPage++
getPresenter().fetchListData(allFilter, curPage)
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
}
}
}
// 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()
......@@ -374,61 +369,78 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun localData() {
}
override fun updateCache(showType: Int, searchBean: ExpertSearchBean) {
}
//路由传递过来的参数
private fun getRouterParam() {
if (null != intent && intent.hasExtra("routerParam")) {
val params = intent.getStringExtra("routerParam")
val paramsJson = JSONObject(params)
initCategory = paramsJson.getString("cateId")
keyWord = paramsJson.getString("cateTitle")
cateName = paramsJson.getString("cateTitle")
mSign2 = cateName!!
initShowType = paramsJson.getString("showType").toInt()
}
}
private fun initData(mIntent: Intent) {
private fun initData(mIntent: Intent, isRefresh: Boolean) {
fromPageType = mIntent.getIntExtra(EXTRA_FROM_PAGE, -1)
initCategory = mIntent.getStringExtra(EXTRA_CATEGORY) ?: ""
initShowType = mIntent.getIntExtra(EXTRA_SHOW_TYPE, 0)
tv_search_content.text = mIntent.getStringExtra(EXTRA_SEARCH_WORD)
keyWord = mIntent.getStringExtra(EXTRA_CATEGORY_NAME) ?: ""
val relatedWord = mIntent.getStringExtra(EXTRA_RELATED_WORD) // 搜索内容的联想词
val searchWord = mIntent.getStringExtra(EXTRA_SEARCH_WORD)
val isRecommendWords = mIntent.getBooleanExtra(EXTRA_IS_RECCOMMEND_WORD, false)
if (!TextUtils.isEmpty(relatedWord)) { // 判断搜索内容的联想词为空,则用搜索词进行搜索
allFilter.searchWord = relatedWord
} else {
allFilter.searchWord = searchWord
}
mSign2 = mIntent.getStringExtra("sign2") ?: ""
getRouterParam()
allFilter.showType.key = initShowType
val cat = CateItem()
cat.cateId = initCategory
allFilter.categories.clear()
allFilter.categories.add(cat)
if (!TextUtils.isEmpty(initCategory)&&initCategory!="0") {
allFilter.categoryId2List.add(initCategory)
}
if (!TextUtils.isEmpty(cateName)) {
tvSubject.text = cateName
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
}
getPresenter().fetchListHead()
//加载本地缓存数据
getPresenter().localData(initShowType)
if (isRefresh) {
refresh(false)
}
tv_search_content.text = searchWord
// 判断搜索词和联想词不一样,则显示匹配结果
LogUtil.e("searchWord:${searchWord}")
LogUtil.e("relatedWord:${relatedWord}")
if (!TextUtils.isEmpty(searchWord) && !TextUtils.isEmpty(relatedWord) && searchWord != relatedWord) {
if (doctorList.size > 0 && doctorList[0].is_head_view) {
doctorList[0] = ExpertServiceItem(true, searchWord, relatedWord)
} else if (doctorList.size > 0) {
doctorList.add(0, ExpertServiceItem(true, searchWord, relatedWord))
} else {
doctorList.add(ExpertServiceItem(true, searchWord, relatedWord))
}
} else {
if (doctorList.size > 0 && doctorList[0].is_head_view) {
doctorList.removeAt(0)
}
}
v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
doctorAdapter.clickCount = 0
doctorAdapter.setIsRecommendWords(isRecommendWords)
doctorAdapter.setEntrance(1)
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
initData(intent!!)
initData(intent!!, true)
}
/**
* 初始化状态栏位置
*/
private fun initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
StatusBarUtils.setTransparentForImageView(this, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(this)
val lp1 = title_layout.layoutParams as LinearLayout.LayoutParams
lp1.height = (RxImageTool.dp2px(48f) + statusBarHeight)
title_layout.setPadding(0, statusBarHeight, 0, 0)
}
}
//返回键处理,热门搜索如果可见,则隐藏,来自启动页,则打开主界面
override fun onBackPressed() {
......@@ -443,34 +455,61 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun onHeadFetched(headData: HeadData?) {
//头部数据获取到后初始化筛选数据
this.headData = headData
if (initCategory != "0") {
if (headData?.cates != null) {
for (cate in headData.cates) {
if (cate.cateId == initCategory) {
allFilter.categories.clear()
allFilter.categories.add(cate)
if (allFilter.categories.size == 1 && !"全部".equals(allFilter.categories[0].cateName)) {
//显示选中标题
tvSubject.text = allFilter.categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
}
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
break
}
}
}
initCategory = "0"
} else {
allFilter.categories.clear()
allFilter.categories.add(headData?.cates?.get(0) ?: CateItem())
}
allFilter.reorder = headData?.reorder?.get(0) ?: ReorderItem()
allFilter.showType = headData?.filters?.showType?.get(initShowType) ?: ShowTypeItem()
if (headData?.highlighter?.size ?: 0 > 0) {
headData?.let { it ->
// allFilter.reorder = it.reorder[0]
allFilter.showType = it.filters.showType[initShowType]
if (it.highlighter.size > 0) {
//设置热门搜索
initHotViews(lin_filter2, headData!!.highlighter)
initHotViews(lin_filter2, it.highlighter)
}
it.cates[0].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.childList.add(childrenBean)
}
it.cates[1].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.stressList.add(childrenBean)
}
it.cates[2].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.loveEmotionList.add(childrenBean)
}
it.cates[3].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.marriedFamilyList.add(childrenBean)
}
it.cates[4].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.personalGrowthList.add(childrenBean)
}
it.cates[5].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.interpersonalRelationshipList.add(childrenBean)
}
it.cates[6].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.careerDevelopmentList.add(childrenBean)
}
it.cates[7].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.mentalHealthList.add(childrenBean)
}
}
}
......@@ -481,9 +520,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
if (view.childCount > 0) {
return
}
val popWidth = RxDeviceTool.getScreenWidth(mContext)
val mWidth = (popWidth - RxImageTool.dp2px(10f)) / hotData.size
for ((index, hot) in hotData!!.withIndex()) {
for (hot in hotData) {
val tv =
View.inflate(mContext, R.layout.consultant_item_filter_online, null) as TextView
val textView = tv.tvFree
......@@ -502,6 +539,14 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
dealHotSelect(hot, true)
textView.isSelected = true
textView.paint.isFakeBoldText = true
// 埋点
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_CHOICE_FILTER_CLICK,
hot.value!!,
"app",
""
)
}
filterLabelSet()
//开始筛选数据
......@@ -528,36 +573,37 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
private fun dealHotSelect(hotData: HighlighterItem, isAdd: Boolean) {
when (hotData.type) {
"1" -> {
if (headData?.cates!!.size > 0) {
for (bean in headData?.cates!!) {
if (TextUtils.equals(hotData.id, bean.cateId.toString())) {
if (isAdd) {
if (allFilter.categories.size == 1 && allFilter.categories[0].cateId == "0") {
allFilter.categories.clear()
}
allFilter.categories.add(bean)
// if (headData?.cates!!.size > 0) {
// for (bean in headData?.cates!!) {
// if (TextUtils.equals(hotData.id, bean.cateId.toString())) {
// if (isAdd) {
// if (allFilter.categories.size == 1 && allFilter.categories[0].cateId == "0") {
// allFilter.categories.clear()
// }
// allFilter.categories.add(bean)
// updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
// } else {
// allFilter.categories.remove(bean)
// if (allFilter.categories.size == 0) {
// allFilter.categories.add(headData?.cates?.get(0) ?: CateItem())
// updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
// }
// }
// }
// }
// if (allFilter.categories.size == 1 && "全部" != allFilter.categories[0].cateName) {
// //显示选中标题
// tvSubject.text = allFilter.categories[0].cateName
// } else {
// //显示主标题
// tvSubject.text = "主题"
// }
// }
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
allFilter.categories.remove(bean)
if (allFilter.categories.size == 0) {
allFilter.categories.add(headData?.cates?.get(0) ?: CateItem())
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
}
}
}
}
if (allFilter.categories.size == 1 && "全部" != allFilter.categories[0].cateName) {
//显示选中标题
tvSubject.text = allFilter.categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
}
}
}
"2" -> {//省
if (headData?.region!!.size > 0) {
var bean = RegionItem()
val bean = RegionItem()
if (isAdd) {
//热门中如果选择过地区、要把其他已选中的置位未选中
if (hasSelectedArea) {
......@@ -764,7 +810,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//用于侧滑筛选过来更新快捷筛选选中状态
private fun updateOtherViews(otherdata: List<OtherItem>) {
private fun updateOtherViews(otherData: List<OtherItem>) {
if (lin_filter2.childCount > 0) {
//清空选中
for (i in 0.until(lin_filter2.childCount)) {
......@@ -773,7 +819,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
textView.paint.isFakeBoldText = false
}
//重置选中状态
for ((index, other) in otherdata.withIndex()) {
for (other in otherData) {
for (i in 0 until lin_filter2.childCount) {
val textView = lin_filter2.getChildAt(i) as TextView
if (textView.text == other.value) {
......@@ -785,89 +831,62 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
}
//服务列表数据获取到后的回调
override fun onServiceListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
) {
LogUtil.d("onServiceListFetched")
// if (rvExperts.adapter != serviceAdapter) {
// rvExperts.adapter = serviceAdapter
// }
if (page == 1) {
if (fromPageType != -1 && isDoSearch) {
// LogUtil.d("keyword: " + keyWord + " isRecommend: " + isRecommend + " hasResult: " + (data.size > 0 && data != null ?: false) + " location: " + fromPages[fromPageType])
}
serviceList.clear()
hasMore = true
// serviceAdapter.hasMore = true
}
if (fromPageType == -1) {
bury(keyWord ?: "", data.size > 0, isRecommend, "首页分类")
} else {
bury(keyWord ?: "", data.size > 0, isRecommend, fromPages[fromPageType])
}
if (page >= totalPage) {
hasMore = false
// serviceAdapter.hasMore = false
}
serviceList.addAll(data)
// serviceAdapter.notifyDataSetChanged()
isRecommend = false
isDoSearch = false
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
dismissProgressDialog()
srlContainer.isRefreshing = false
}
//专家列表数据获取到后的回调
/**
* 获取专家列表数据
*/
override fun onDoctorListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
data: MutableList<ExpertServiceItem>,
extras: Extras?,
curPage: Int
) {
LogUtil.d("onDoctorListFetched")
if (rvExperts.adapter != doctorAdapter) {
rvExperts.adapter = doctorAdapter
}
LogUtil.d("data size " + data.size)
if (page == 1) {
if (fromPageType != -1 && isDoSearch) {
// LogUtil.d("keyword: " + keyWord + " isRecommend: " + isRecommend + " hasResult: " + (data.size > 0 && data != null ?: false) + " location: " + fromPages[fromPageType])
}
doctorList.clear()
doctorAdapter.hasMore = true
// 如果是第一页
if (curPage == 1) {
if (data.size >= 10) {
hasMore = true
}
if (fromPageType == -1) {
bury(keyWord ?: "", data != null && data.size > 0, isRecommend, "首页分类")
doctorAdapter.hasMore = true
} else {
bury(keyWord ?: "", data != null && data.size > 0, isRecommend, fromPages[fromPageType])
}
if (page >= totalPage) {
hasMore = false
doctorAdapter.hasMore = false
}
if (doctorList.size > 0 && doctorList[0].is_head_view) {
val expertServiceItem = doctorList[0]
doctorList.clear()
doctorList.add(expertServiceItem)
} else {
doctorList.clear()
}
}
if (data.size == 0) { // data的长度为0的时候为最后一页
hasMore = false
doctorAdapter.hasMore = false
} else {
doctorList.addAll(data)
}
doctorAdapter.notifyDataSetChanged()
isDoSearch = false
isRecommend = false
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
dismissProgressDialog()
srlContainer.isRefreshing = false
// 埋点
val sign1 = data.joinToString(",") { it.id }
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.POSITION_CONSULT_COUNSELOR_LIST_PAGE_VISIT,
sign1,
mSign2,
"app"
)
}
override fun fetchListFailed(msg: String?) {
......@@ -893,6 +912,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
isDoSearch = false
isRecommend = false
if (doctorList.size > 0 && doctorList[0].is_head_view) {
val expertServiceItem = doctorList[0]
doctorList.clear()
doctorList.add(expertServiceItem)
doctorAdapter.notifyDataSetChanged()
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
} else {
tv_reload.visibility = View.GONE
tv_reload_hint.text = msg
ll_network_error.visibility = View.VISIBLE
......@@ -903,6 +933,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
srlContainer.isRefreshing = false
}
}
override fun fetchFailed(msg: String?) {
isDoSearch = false
isRecommend = false
......@@ -938,7 +970,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showSubjectPopupWindow()
}, 300);
}, 300)
}
R.id.tvArea -> {
......@@ -947,7 +979,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showAreaPopupWindow()
}, 300);
}, 300)
}
R.id.tvSort -> {
......@@ -956,7 +988,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showSortPopupWindow()
}, 300);
}, 300)
}
R.id.tvFilter -> {
......@@ -965,7 +997,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showFilterPopupWindow()
}, 300);
}, 300)
}
R.id.tv_guide -> {
......@@ -1001,7 +1033,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//显示筛选弹窗
private fun showFilterPopupWindow() {
// tempFilter.searchWord = etSearch.text.toString()
tempFilter.categories.clear()
tempFilter.categories.addAll(allFilter.categories)
tempFilter.reorder = allFilter.reorder
......@@ -1027,7 +1058,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
if (headData?.filters != null) {
val filterPopupWindow = FilterPopupWindow(this, headData?.filters!!, tempFilter)
filterPopupWindow.setOnDismissListener {
// viewDim.visibility = View.INVISIBLE
viewDim.visibility = View.INVISIBLE
viewDim_filter.visibility = View.GONE
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.title.size > 0 || !TextUtils.isEmpty(
allFilter.priceRanges?.minPrice
......@@ -1040,12 +1071,11 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list", true)
}
filterPopupWindow.isClippingEnabled = false
filterPopupWindow.showAtLocation(viewSep2.rootView, Gravity.TOP + Gravity.RIGHT, 0, 0)
filterPopupWindow.showAsDropDown(viewSep2)
ConsultAssistantDialogUtils.INSTANCE.hideAssistantActivity()
filterPopupWindow.onFilterConfirmListener = this
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
// viewDim.visibility = View.VISIBLE
viewDim_filter.visibility = View.VISIBLE
viewDim.visibility = View.VISIBLE
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
......@@ -1055,21 +1085,35 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//筛选确认回调
override fun onFilterConfirmed() {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
LogUtil.d("filter: " + tempFilter.showType.value + ","
LogUtil.d(
"filter: " + tempFilter.showType.value + ","
+ tempFilter.enquiries.map { it.value }.joinToString(",") + ","
+ tempFilter.ages.map { it.value }.joinToString(",") + ","
+ tempFilter.others.map { it.value }.joinToString(",")+ ","
+ tempFilter.doctorEdu.map { it.value }.joinToString(","))
+ tempFilter.others.map { it.value }.joinToString(",") + ","
+ tempFilter.doctorEdu.map { it.value }.joinToString(",")
)
props1.put(
"filtrate_second",
tempFilter.showType.value + ","
+ tempFilter.enquiries.map { it.value }.joinToString(",") + ","
+ tempFilter.ages.map { it.value }.joinToString(",") + ","
+ tempFilter.others.map { it.value }.joinToString(",") +","
+ tempFilter.others.map { it.value }.joinToString(",") + ","
+ tempFilter.doctorEdu.map { it.value }.joinToString(",")
)
BuryPointUtils.buryPoint("Filtrate", props1)
// 埋点
if (tempFilter.specialityCrowd.size > 0) {
val sign1 = tempFilter.specialityCrowd.joinToString(",") { it.value!! }
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_FILTER_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_GOODAT_CROWD_CLICK,
sign1,
"app",
""
)
}
allFilter.showType = tempFilter.showType
allFilter.enquiries.clear()
......@@ -1188,22 +1232,30 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
private fun filterLabelSet() {
if ((allFilter.others.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.enquiries.size + allFilter.title.size + allFilter.specialityCrowd.size) == 1) {
var text: String? = ""
if (allFilter.others.size == 1) {
when {
allFilter.others.size == 1 -> {
text = allFilter.others[0].value
} else if (allFilter.ages.size == 1) {
}
allFilter.ages.size == 1 -> {
text = allFilter.ages[0].value
} else if (allFilter.enquiries.size == 1) {
}
allFilter.enquiries.size == 1 -> {
text = allFilter.enquiries[0].value
} else if (allFilter.title.size == 1) {
}
allFilter.title.size == 1 -> {
text = allFilter.title[0].value
} else if (allFilter.specialityCrowd.size == 1) {
}
allFilter.specialityCrowd.size == 1 -> {
text = allFilter.specialityCrowd[0].value
}else if(allFilter.doctorEdu.size == 1){
}
allFilter.doctorEdu.size == 1 -> {
//学历
text = allFilter.doctorEdu[0].value
} else {
}
else -> {
text = "筛选"
}
}
if (text?.length ?: 0 > 4) {
tvFilter.text = text?.substring(0, 3) + "..."
} else {
......@@ -1249,13 +1301,17 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
?: ""
)
if (sortItem.value.equals("综合排序")) {
when {
sortItem.value.equals("综合排序") -> {
tvSort.text = "排序"
} else if (sortItem.value?.length ?: 0 > 4) {
}
sortItem.value?.length ?: 0 > 4 -> {
tvSort.text = sortItem.value?.substring(0, 3) + "..."
} else {
}
else -> {
tvSort.text = sortItem.value
}
}
//判断排序选中,判断热门筛选中是否也有该排序
if (headData!!.highlighter.size > 0) {
......@@ -1366,31 +1422,26 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
}
private var categoryPopup: CategoryPopupWindow? = null
private var mHandler: Handler? = null
//显示主题弹窗
/**
* 显示主题弹窗
*/
private fun showSubjectPopupWindow() {
tempFilter.categories.clear()
tempFilter.categories.addAll(allFilter.categories)
val categories = headData?.cates
if (categories != null) {
categoryPopup = CategoryPopupWindow(this, categories, tempFilter.categories)
categoryPopup!!.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
if (allFilter.categories.size > 1 || (allFilter.categories.size == 1 && allFilter.categories[0] != headData!!.cates[0])) {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
val categoryPopup = CategoryPopupWindow(this, allFilter)
mHandler = Handler()
mHandler!!.post {
categoryPopup.updateData()
}
categoryPopup.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
ConsultAssistantDialogUtils.INSTANCE.fitRequest(this, "doctor_list", true)
}
categoryPopup!!.onSubjectsSelectedListener = this
categoryPopup!!.showAsDropDown(viewSep2)
ConsultAssistantDialogUtils.INSTANCE.hideAssistantActivity()
categoryPopup.onSubjectsSelectedListener = this
categoryPopup.showAsDropDown(viewSep2)
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_OPEN)
viewDim.visibility = View.VISIBLE
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
}
}
/**
......@@ -1398,58 +1449,24 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
*
* 新增逻辑:当主题选择后,需要判断热门筛选中是否也有该主题,如果有,也需要同步更新选中状态
*/
override fun onCategoriesSelected(categories: ArrayList<CateItem>) {
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_THEME_CLICK,
categories.map { it.cateName }.joinToString("|")
)
if (categories.size == 1 && "全部" != categories[0].cateName) {
//显示选中标题
tvSubject.text = categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
}
//判断主题选中,判断热门筛选中是否也有该主题
Executors.newCachedThreadPool().execute {
if (headData!!.highlighter.size > 0) {
for (index in 0.until(headData!!.highlighter.size)) {
if (headData!!.highlighter[index].type == "1") {
var textview = lin_filter2.getChildAt(index) as TextView
this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in categories) {
if (TextUtils.equals(
bean.cateName,
headData!!.highlighter[index].value
override fun onCategoriesSelected(signLit: ArrayList<String>) {
if (signLit.isNotEmpty()) {
val sign1 = signLit.joinToString(",") { it }
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_TWO_CATEGORY_CLICK,
sign1,
"app",
""
)
) {
this@ExpertSearchActivity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
}
break
}
}
}
}
}
}
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_OPEN)
// LogUtil.d("theme callback: " + categories.map { it.cateName }.joinToString(","))
// props1.put("filtrate_second", categories.map { it.cateName }.joinToString(","))
// BuryPointUtils.buryPoint("Filtrate", props1)
allFilter.categories.clear()
allFilter.categories.addAll(categories)
refresh()
if (categories.size == 1) {
doctorAdapter?.cateId = "${categories[0].cateId}"
if (allFilter.categoryId2List.size > 0 || allFilter.categoryId3List.size > 0) {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
doctorAdapter?.cateId = ""
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
}
refresh()
}
override fun onRefresh() {
......@@ -1460,38 +1477,12 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
//刷新列表
private fun refresh(isShowRefresh: Boolean? = true) {
srlContainer.isRefreshing = isShowRefresh!!
val key = tv_search_content.text.toString()
if (!TextUtils.isEmpty(key.trim())) {
allFilter.searchWord = key.trim()
} else {
allFilter.searchWord = null
}
curPage = 1
onScrollListener.resetState()
getPresenter().fetchListData(allFilter, curPage)
getPresenter().mExtras = null
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
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,
keyWord ?: ""
)
isDoSearch = true
resetFilter()
refresh()
}
//重置所有筛选
private fun resetFilter() {
allFilter.categories.clear()
......@@ -1560,17 +1551,6 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
}
}
/**
* 事件埋点
*/
fun bury(keyworks: String, isResult: Boolean, isRecommend: Boolean, location: String) {
BuryPointUtils.getInstance().createMap()
.put("keyWord", keyworks)
.put("hasResult", isResult)
.put("isRecommend", isRecommend)
.put("location", location)
.burryPoint("search")
}
override fun onResume() {
super.onResume()
......@@ -1580,6 +1560,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
override fun onDestroy() {
super.onDestroy()
mHandler = null
ConsultAssistantDialogUtils.INSTANCE.expertSearchResetStatus()
}
}
......@@ -6,7 +6,7 @@ import android.animation.ObjectAnimator
import android.animation.PropertyValuesHolder
import android.content.Context
import android.graphics.Typeface
import android.os.Build
import android.os.Handler
import android.text.TextUtils
import android.view.View
import android.view.inputmethod.InputMethodManager
......@@ -37,7 +37,6 @@ import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.ydl.ydlcommon.view.listener.EndlessRecyclerViewScrollListener
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.adapter.ExpertSearchAdapter
......@@ -53,6 +52,8 @@ import com.yidianling.consultant.ui.view.CategoryPopupWindow
import com.yidianling.consultant.ui.view.FilterPopupWindow
import com.yidianling.consultant.ui.view.SortPopupWindow
import com.yidianling.consultant.ui.view.topView.RecommendListView
import com.yidianling.home.api.event.HomeModuleTabEvent
import de.greenrobot.event.EventBus
import kotlinx.android.synthetic.main.consultant_activity_expert_search_list.*
import kotlinx.android.synthetic.main.consultant_item_filter_online.view.*
import kotlinx.android.synthetic.main.consultant_layout_search_content.*
......@@ -67,14 +68,16 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
SwipeRefreshLayout.OnRefreshListener {
private lateinit var mContext: Context
private lateinit var mActivity: FragmentActivity
var startTime =0L
var endTime =0L
var startTime = 0L
var endTime = 0L
private var mIdssign1: String = "" // 列表埋点咨询师列表id拼接参数
override fun layoutResId(): Int {
return R.layout.consultant_activity_expert_search_list
}
override fun initDataAndEvent() {
EventBus.getDefault().register(this)
mContext = requireContext()
mActivity = requireActivity()
val statusBarHeight = StatusBarUtils.getStatusBarHeight(mContext)
......@@ -122,10 +125,6 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
YDLImageCacheManager.showImage(activity, url, imgView, width, heigh, ops)
}
}
//
// override fun getStatusViewOptions(): StatusBarOptions {
// return StatusBarOptions(true,true)
// }
companion object {
const val EXTRA_CATEGORY = "category"
......@@ -147,22 +146,15 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
private val allFilter = AllFilter() //当前筛选
private val tempFilter = AllFilter() //临时筛选,未确认状态
private var curPage = 1
private val doctorList = ArrayList<DoctorServiceItem>()
private val serviceList = ArrayList<DoctorServiceItem>()
private val doctorList = ArrayList<ExpertServiceItem>()
private var hasMore = true
private var initCategory = "0"
private var initShowType: Int = 0
private lateinit var doctorAdapter: ExpertSearchAdapter
private lateinit var onScrollListener: EndlessRecyclerViewScrollListener
private var headData: HeadData? = null //筛选数据
private val props1 = JSONObject() //筛选标题埋点参数
private var fromPageType: Int = 0 //从哪个页面跳转过来的
private val fromPages = arrayOf("首页", "搜索页面", "在线专家")
private var isRecommend = false //埋点数据
private var keyWord: String? = null //埋点数据
private var isDoSearch: Boolean = false //埋点判断是否通过搜索进入埋点的
private val bannerList = ArrayList<String>()
private var hasSelectedArea = false //是否选择过地区
private var hasSelectedSort = false //是否选择过排序
......@@ -200,18 +192,6 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
srlContainer.isEnabled = i >= 0
})
// etSearch.setOnEditorActionListener { _, actionId, _ ->
// if (actionId == EditorInfo.IME_ACTION_SEARCH) {
// doSearch()
// }
// true
// }
// etSearch.setOnClickListener { appbar_layout.setExpanded(false) }
// etSearch.setOnFocusChangeListener { view, b -> if (b) appbar_layout.setExpanded(false) }
// btn_back.setOnClickListener {
// onBackPressed()
// }
doctorAdapter = ExpertSearchAdapter(mContext, this, doctorList)
rvExperts.adapter = doctorAdapter
......@@ -295,38 +275,28 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
override fun onLoadMore(page: Int, totalItemsCount: Int, view: RecyclerView?) {
if (hasMore) {
curPage++
getPresenter().fetchListData(allFilter, curPage)
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
}
}
}
// rvExperts.addItemDecoration(ExpertItemDecoration(this))
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)
// initStatus()
}
override fun setUserVisibleHint(isVisibleToUser: Boolean) {
super.setUserVisibleHint(isVisibleToUser)
if (isVisibleToUser && isResumed) {
startTime=System.currentTimeMillis()
startTime = System.currentTimeMillis()
showConsultAssistantDialog()
} else {
hideConsultAssistantDialog()
if (startTime!=0L){
endTime=System.currentTimeMillis()
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.YDL_USER_CONSULT_PAGE_STAY_VISIT,(endTime-startTime).toString())
if (startTime != 0L) {
endTime = System.currentTimeMillis()
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.YDL_USER_CONSULT_PAGE_STAY_VISIT,
(endTime - startTime).toString()
)
}
}
if (isVisibleToUser && isResumed) {
......@@ -359,21 +329,13 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
override fun localData() {
}
override fun updateCache(showType: Int, searchBean: ExpertSearchBean) {
}
private fun initData() {
allFilter.showType.key = initShowType
val cat = CateItem()
cat.cateId = initCategory
allFilter.categories.clear()
allFilter.categories.add(cat)
getPresenter().fetchListHead()
//加载本地缓存数据
getPresenter().localData(initShowType)
//refresh(false)
v_loading.visibility = View.VISIBLE
v_loading.setViewType(LogoLoadingView.TYPE_LOADING, null)
......@@ -382,51 +344,66 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
/**
* 初始化状态栏位置
* 获取所有的筛选选项数据
*/
private fun initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
StatusBarUtils.setTransparentForImageView(mActivity, null)
val statusBarHeight = StatusBarUtils.getStatusBarHeight(mContext)
val lp1 = title_layout.layoutParams as LinearLayout.LayoutParams
lp1.height = (RxImageTool.dp2px(48f) + statusBarHeight)
title_layout.setPadding(0, statusBarHeight, 0, 0)
}
}
//筛选数据获取后回调
override fun onHeadFetched(headData: HeadData?) {
//头部数据获取到后初始化筛选数据
this.headData = headData
if (initCategory != "0") {
if (headData?.cates != null) {
for (cate in headData.cates) {
if (cate.cateId == initCategory) {
allFilter.categories.clear()
allFilter.categories.add(cate)
if (allFilter.categories.size == 1 && !"全部".equals(allFilter.categories[0].cateName)) {
//显示选中标题
tvSubject.text = allFilter.categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
}
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
break
}
}
}
initCategory = "0"
} else {
allFilter.categories.clear()
allFilter.categories.add(headData?.cates?.get(0) ?: CateItem())
}
allFilter.reorder = headData?.reorder?.get(0) ?: ReorderItem()
allFilter.showType = headData?.filters?.showType?.get(initShowType) ?: ShowTypeItem()
if (headData?.highlighter?.size ?: 0 > 0) {
headData?.let { it ->
// allFilter.reorder = it.reorder[0]
allFilter.showType = it.filters.showType[initShowType]
if (it.highlighter.size > 0) {
//设置热门搜索
initHotViews(lin_filter2, headData!!.highlighter)
initHotViews(lin_filter2, it.highlighter)
}
it.cates[0].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.childList.add(childrenBean)
}
it.cates[1].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.stressList.add(childrenBean)
}
it.cates[2].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.loveEmotionList.add(childrenBean)
}
it.cates[3].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.marriedFamilyList.add(childrenBean)
}
it.cates[4].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.personalGrowthList.add(childrenBean)
}
it.cates[5].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.interpersonalRelationshipList.add(childrenBean)
}
it.cates[6].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.careerDevelopmentList.add(childrenBean)
}
it.cates[7].children?.forEachIndexed { index, children ->
val type = if (children.cate_name.length > 4) 2 else 1
val childrenBean =
ChildrenBean(children.cate_name, children.cate_id, index <= 12, type)
allFilter.mentalHealthList.add(childrenBean)
}
}
}
......@@ -437,9 +414,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
if (view.childCount > 0) {
return
}
val popWidth = RxDeviceTool.getScreenWidth(context)
val mWidth = (popWidth - RxImageTool.dp2px(10f)) / hotData.size
for ((index, hot) in hotData!!.withIndex()) {
for (hot in hotData) {
val tv = View.inflate(context, R.layout.consultant_item_filter_online, null) as TextView
val textView = tv.tvFree
val params = LinearLayout.LayoutParams(0, RxImageTool.dp2px(22f))
......@@ -457,6 +432,14 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
dealHotSelect(hot, true)
textView.isSelected = true
textView.paint.isFakeBoldText = true
// 埋点
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_CHOICE_FILTER_CLICK,
hot.value!!,
"app",
""
)
}
filterLabelSet()
//开始筛选数据
......@@ -483,32 +466,31 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
private fun dealHotSelect(hotData: HighlighterItem, isAdd: Boolean) {
when (hotData.type) {
"1" -> {
if (headData?.cates!!.size > 0) {
for (bean in headData?.cates!!) {
if (TextUtils.equals(hotData.id, bean.cateId.toString())) {
if (isAdd) {
if (allFilter.categories.size == 1 && allFilter.categories[0].cateId == "0") {
allFilter.categories.clear()
}
allFilter.categories.add(bean)
// if (headData?.cates!!.size > 0) {
// for (bean in headData?.cates!!) {
// if (TextUtils.equals(hotData.id, bean.cateId.toString())) {
// if (isAdd) {
// if (allFilter.categories.size == 1 && allFilter.categories[0].cateId == "0") {
// allFilter.categories.clear()
// }
// updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
// } else {
// allFilter.categories.remove(bean)
// if (allFilter.categories.size == 0) {
// updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
// }
// }
// }
// }
// if (allFilter.categories.size == 1 && "全部" != allFilter.categories[0].cateName) {
// //显示选中标题
// tvSubject.text = allFilter.categories[0].cateName
// } else {
// //显示主标题
// tvSubject.text = "主题"
// }
// }
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
allFilter.categories.remove(bean)
if (allFilter.categories.size == 0) {
allFilter.categories.add(headData?.cates?.get(0) ?: CateItem())
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
}
}
}
}
if (allFilter.categories.size == 1 && "全部" != allFilter.categories[0].cateName) {
//显示选中标题
tvSubject.text = allFilter.categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
}
}
}
"2" -> {//省
if (headData?.region!!.size > 0) {
......@@ -599,7 +581,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
}
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size+allFilter.doctorEdu.size + allFilter.title.size+allFilter.specialityCrowd.size > 0) {
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.title.size + allFilter.specialityCrowd.size > 0) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
......@@ -619,7 +601,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
}
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size+allFilter.specialityCrowd.size > 0) {
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size + allFilter.specialityCrowd.size > 0) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
......@@ -639,7 +621,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
}
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size+allFilter.specialityCrowd.size > 0) {
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size + allFilter.specialityCrowd.size > 0) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
......@@ -659,7 +641,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
}
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size+allFilter.specialityCrowd.size > 0) {
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.title.size + allFilter.specialityCrowd.size > 0) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
......@@ -719,7 +701,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//用于侧滑筛选过来更新快捷筛选选中状态
private fun updateOtherViews(otherdata: List<OtherItem>) {
private fun updateOtherViews(otherData: List<OtherItem>) {
if (lin_filter2.childCount > 0) {
//清空选中
for (i in 0.until(lin_filter2.childCount)) {
......@@ -728,7 +710,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
textView.paint.isFakeBoldText = false
}
//重置选中状态
for ((index, other) in otherdata.withIndex()) {
for (other in otherData) {
for (i in 0 until lin_filter2.childCount) {
val textView = lin_filter2.getChildAt(i) as TextView
if (textView.text == other.value) {
......@@ -740,98 +722,64 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
//服务列表数据获取到后的回调
override fun onServiceListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
) {
LogUtil.d("onServiceListFetched")
// if (rvExperts.adapter != serviceAdapter) {
// rvExperts.adapter = serviceAdapter
// }
if (page == 1) {
if (fromPageType != -1 && isDoSearch) {
// LogUtil.d("keyword: " + keyWord + " isRecommend: " + isRecommend + " hasResult: " + (data.size > 0 && data != null ?: false) + " location: " + fromPages[fromPageType])
}
serviceList.clear()
hasMore = true
// serviceAdapter.hasMore = true
}
if (fromPageType == -1) {
bury(keyWord ?: "", data.size > 0, isRecommend, "首页分类")
} else {
bury(keyWord ?: "", data.size > 0, isRecommend, fromPages[fromPageType])
}
if (page >= totalPage) {
hasMore = false
// serviceAdapter.hasMore = false
}
serviceList.addAll(data)
// serviceAdapter.notifyDataSetChanged()
isRecommend = false
isDoSearch = false
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
srlContainer.isRefreshing = false
}
//专家列表数据获取到后的回调
/**
* 获取专家列表数据
*/
override fun onDoctorListFetched(
data: MutableList<DoctorServiceItem>,
page: Int,
totalPage: Int
data: MutableList<ExpertServiceItem>,
extras: Extras?,
curPage: Int
) {
LogUtil.d("onDoctorListFetched")
if (rvExperts.adapter != doctorAdapter) {
rvExperts.adapter = doctorAdapter
}
LogUtil.d("data size " + data.size)
if (page == 1) {
if (fromPageType != -1 && isDoSearch) {
// LogUtil.d("keyword: " + keyWord + " isRecommend: " + isRecommend + " hasResult: " + (data.size > 0 && data != null ?: false) + " location: " + fromPages[fromPageType])
}
doctorList.clear()
doctorAdapter.hasMore = true
// 如果是第一页
if (curPage == 1) {
if (data.size >= 10) {
hasMore = true
}
if (fromPageType == -1) {
bury(keyWord ?: "", data != null && data.size > 0, isRecommend, "首页分类")
doctorAdapter.hasMore = true
} else {
bury(keyWord ?: "", data != null && data.size > 0, isRecommend, fromPages[fromPageType])
}
if (page >= totalPage) {
hasMore = false
doctorAdapter.hasMore = false
}
doctorList.addAll(data)
//咨询师列表去除重复数据start
var linkedHashSet=LinkedHashSet(doctorList)
doctorList.clear()
doctorList.addAll(linkedHashSet)
//咨询师列表去除重复数据end
}
if (data.size == 0) { // data的长度为0的时候为最后一页
hasMore = false
doctorAdapter.hasMore = false
} else {
doctorList.addAll(data)
}
doctorAdapter.notifyDataSetChanged()
isDoSearch = false
isRecommend = false
v_loading.visibility = View.GONE
ll_network_error.visibility = View.GONE
rvExperts.visibility = View.VISIBLE
srlContainer.isRefreshing = false
// 埋点
mIdssign1 = data.joinToString(",") { it.id }
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.POSITION_CONSULT_COUNSELOR_LIST_PAGE_VISIT,
mIdssign1,
sign2,
"app"
)
}
override fun fetchListFailed(msg: String?) {
isDoSearch = false
isRecommend = false
if (curPage == 1) {
if (getPresenter().mExtras == null) {
v_loading.setViewType(
LogoLoadingView.TYPE_NET_LOSS,
getString(R.string.consultant_reload_hint)
......@@ -892,7 +840,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showSubjectPopupWindow()
}, 300);
}, 300)
}
R.id.tvArea -> {
......@@ -901,7 +849,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showAreaPopupWindow()
}, 300);
}, 300)
}
R.id.tvSort -> {
......@@ -910,7 +858,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showSortPopupWindow()
}, 300);
}, 300)
}
R.id.tvFilter -> {
......@@ -919,7 +867,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
showFilterPopupWindow()
}, 300);
}, 300)
}
R.id.tv_guide -> {
......@@ -954,7 +902,6 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//显示筛选弹窗
private fun showFilterPopupWindow() {
// tempFilter.searchWord = etSearch.text.toString()
tempFilter.categories.clear()
tempFilter.categories.addAll(allFilter.categories)
tempFilter.reorder = allFilter.reorder
......@@ -982,7 +929,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
filterPopupWindow.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
viewDim_filter.visibility = View.GONE
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.title.size+allFilter.specialityCrowd.size > 0 || !TextUtils.isEmpty(
if (allFilter.others.size + allFilter.enquiries.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.title.size + allFilter.specialityCrowd.size > 0 || !TextUtils.isEmpty(
allFilter.priceRanges?.minPrice
) || !TextUtils.isEmpty(allFilter.priceRanges?.maxPrice)
) {
......@@ -1007,15 +954,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//筛选确认回调
override fun onFilterConfirmed() {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_OPEN)
LogUtil.d(
"filter: " + tempFilter.showType.value + "," + tempFilter.enquiries.map { it.value }
.joinToString(
","
) + "," + tempFilter.ages.map { it.value }
.joinToString(",") + "," + tempFilter.others.map { it.value }.joinToString(
","
)
)
props1.put(
"filtrate_second",
tempFilter.showType.value + ","
......@@ -1026,6 +965,18 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
)
BuryPointUtils.buryPoint("Filtrate", props1)
// 埋点
if (tempFilter.specialityCrowd.size > 0) {
val sign1 = tempFilter.specialityCrowd.joinToString(",") { it.value!! }
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_FILTER_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_GOODAT_CROWD_CLICK,
sign1,
"app",
""
)
}
allFilter.showType = tempFilter.showType
allFilter.enquiries.clear()
......@@ -1142,7 +1093,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//筛选标题显示处理
private fun filterLabelSet() {
if ((allFilter.others.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.enquiries.size + allFilter.title.size+allFilter.specialityCrowd.size) == 1) {
if ((allFilter.others.size + allFilter.ages.size + allFilter.doctorEdu.size + allFilter.enquiries.size + allFilter.title.size + allFilter.specialityCrowd.size) == 1) {
var text: String? = ""
when {
allFilter.others.size == 1 -> {
......@@ -1157,10 +1108,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
allFilter.title.size == 1 -> {
text = allFilter.title[0].value
}
allFilter.specialityCrowd.size==1 -> {
allFilter.specialityCrowd.size == 1 -> {
text = allFilter.specialityCrowd[0].value
}
allFilter.doctorEdu.size==1 -> {
allFilter.doctorEdu.size == 1 -> {
text = allFilter.doctorEdu[0].value
}
else -> {
......@@ -1212,19 +1163,23 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
?: ""
)
if (sortItem.value.equals("综合排序")) {
when {
sortItem.value.equals("综合排序") -> {
tvSort.text = "排序"
} else if (sortItem.value?.length ?: 0 > 4) {
}
sortItem.value?.length ?: 0 > 4 -> {
tvSort.text = sortItem.value?.substring(0, 3) + "..."
} else {
}
else -> {
tvSort.text = sortItem.value
}
}
//判断排序选中,判断热门筛选中是否也有该排序
if (headData!!.highlighter.size > 0) {
for (index in 0.until(headData!!.highlighter.size)) {
if (headData!!.highlighter[index].type == "3") {
var textview = lin_filter2.getChildAt(index) as TextView
val textview = lin_filter2.getChildAt(index) as TextView
if (TextUtils.equals(sortItem.value, headData!!.highlighter[index].value)) {
textview.isSelected = true
textview.paint.isFakeBoldText = true
......@@ -1250,7 +1205,12 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
//显示地区弹窗
private fun showAreaPopupWindow() {
if (headData?.region != null) {
val regionPopupWindow = AreaPopupWindow(mActivity, headData?.region ?: ArrayList(), allFilter.region, allFilter.sub)
val regionPopupWindow = AreaPopupWindow(
mActivity,
headData?.region ?: ArrayList(),
allFilter.region,
allFilter.sub
)
regionPopupWindow.showAsDropDown(viewSep2)
viewDim.visibility = View.VISIBLE
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
......@@ -1268,7 +1228,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
allFilter.region = region
allFilter.sub = sub
if ( TextUtils.isEmpty(region.code) && TextUtils.isEmpty(sub.code)) {
if (TextUtils.isEmpty(region.code) && TextUtils.isEmpty(sub.code)) {
tvArea.text = "地区"
} else if (!TextUtils.isEmpty(region.code) && !TextUtils.isEmpty(sub.code)) {
if (region.value?.length ?: 0 > 4) {
......@@ -1326,93 +1286,50 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
private var categoryPopup: CategoryPopupWindow? = null
private var mHandler: Handler? = null
//显示主题弹窗
/**
* 显示八大类弹窗
*/
private fun showSubjectPopupWindow() {
tempFilter.categories.clear()
tempFilter.categories.addAll(allFilter.categories)
val categories = headData?.cates
if (categories != null) {
categoryPopup = CategoryPopupWindow(mActivity, categories, tempFilter.categories)
categoryPopup!!.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
if (allFilter.categories.size > 1 || (allFilter.categories.size == 1 && allFilter.categories[0] != headData!!.cates[0])) {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
val categoryPopup = CategoryPopupWindow(mActivity, allFilter)
mHandler = Handler()
mHandler!!.post {
categoryPopup.updateData()
}
categoryPopup.setOnDismissListener {
viewDim.visibility = View.INVISIBLE
showConsultAssistantDialog()
}
categoryPopup!!.onSubjectsSelectedListener = this
categoryPopup!!.showAsDropDown(viewSep2)
hideConsultAssistantDialog()
categoryPopup.onSubjectsSelectedListener = this
categoryPopup.showAsDropDown(viewSep2)
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_OPEN)
viewDim.visibility = View.VISIBLE
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
}
}
/**
* 主题选择确认回调
*
* 新增逻辑:当主题选择后,需要判断热门筛选中是否也有该主题,如果有,也需要同步更新选中状态
*/
override fun onCategoriesSelected(categories: ArrayList<CateItem>) {
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_THEME_CLICK,
categories.map { it.cateName }.joinToString("|")
override fun onCategoriesSelected(signLit: ArrayList<String>) {
if (signLit.isNotEmpty()) {
val sign1 = signLit.joinToString(",") { it }
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_TWO_CATEGORY_CLICK,
sign1,
"app",
""
)
if (categories.size == 1 && "全部" != categories[0].cateName) {
//显示选中标题
tvSubject.text = categories[0].cateName
} else {
//显示主标题
tvSubject.text = "主题"
}
//如果是亲自教育类别----->点击咨询顾问---会跳转到一个只是亲自教育的导医队列中
//判断主题选中,判断热门筛选中是否也有该主题
Executors.newCachedThreadPool().execute {
if (headData!!.highlighter.size > 0) {
for (index in 0.until(headData!!.highlighter.size)) {
if (headData!!.highlighter[index].type == "1") {
val textview = lin_filter2.getChildAt(index) as TextView
mActivity.runOnUiThread {
textview.isSelected = false
textview.paint.isFakeBoldText = false
}
for (bean in categories) {
if (TextUtils.equals(
bean.cateName,
headData!!.highlighter[index].value
)
) {
mActivity.runOnUiThread {
textview.isSelected = true
textview.paint.isFakeBoldText = true
}
break
}
}
}
}
}
}
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_OPEN)
// LogUtil.d("theme callback: " + categories.map { it.cateName }.joinToString(","))
// props1.put("filtrate_second", categories.map { it.cateName }.joinToString(","))
// BuryPointUtils.buryPoint("Filtrate", props1)
allFilter.categories.clear()
allFilter.categories.addAll(categories)
refresh()
if (categories.size == 1) {
doctorAdapter.cateId = "${categories[0].cateId}"
if (allFilter.categoryId2List.size > 0 || allFilter.categoryId3List.size > 0) {
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_FILTERED)
} else {
doctorAdapter.cateId = ""
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
}
refresh()
}
override fun onRefresh() {
......@@ -1421,6 +1338,27 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
/**
* EventBus从首页某个位置点击事件传递
* sign 仅用于埋点事件统计
*/
private var sign2 = ""
fun onEvent(event: HomeModuleTabEvent) {
if (!TextUtils.isEmpty(event.sign)) {
sign2 = event.sign
// 埋点
if (!TextUtils.isEmpty(mIdssign1)) {
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.POSITION_CONSULT_COUNSELOR_LIST_PAGE_VISIT,
mIdssign1,
sign2,
"app"
)
}
}
}
//刷新列表
private fun refresh(isShowRefresh: Boolean? = true) {
srlContainer.isRefreshing = isShowRefresh!!
......@@ -1430,55 +1368,12 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
} else {
allFilter.searchWord = null
}
curPage = 1
onScrollListener.resetState()
getPresenter().fetchListData(allFilter, curPage)
getPresenter().mExtras = null
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
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,
keyWord ?: ""
)
isDoSearch = true
resetFilter()
refresh()
}
//重置所有筛选
private fun resetFilter() {
allFilter.categories.clear()
allFilter.categories.add(headData?.cates?.get(0) ?: CateItem())
allFilter.reorder = headData?.reorder?.get(0) ?: ReorderItem()
allFilter.region = RegionItem()
allFilter.sub = SubItem()
allFilter.enquiries.clear()
allFilter.ages.clear()
allFilter.others.clear()
updateFilterTextViewStatus(tvSubject, FILTER_STATUS_NORMAL)
updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL)
updateFilterTextViewStatus(tvSort, FILTER_STATUS_NORMAL)
if (headData != null) {
if (allFilter.showType != headData!!.filters.showType[1]) {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_FILTERED)
} else {
updateFilterTextViewStatus(tvFilter, FILTER_STATUS_NORMAL)
}
}
}
//设置筛选点击按钮状态
private fun updateFilterTextViewStatus(tv: TextView, status: Int) {
when (status) {
......@@ -1523,27 +1418,17 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
}
/**
* 事件埋点
*/
fun bury(keyworks: String, isResult: Boolean, isRecommend: Boolean, location: String) {
BuryPointUtils.getInstance().createMap()
.put("keyWord", keyworks)
.put("hasResult", isResult)
.put("isRecommend", isRecommend)
.put("location", location)
.burryPoint("search")
}
override fun onResume() {
super.onResume()
refresh(false)
ActionCountUtils.count(ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_PAGE_VISIT)
ActionCountUtils.count("daoyi_advertisement_page|daoyi_advertisement_visit","6")
ActionCountUtils.count("daoyi_advertisement_page|daoyi_advertisement_visit", "6")
}
override fun onDestroy() {
super.onDestroy()
EventBus.getDefault().unregister(this)
mHandler = null
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
}
}
......@@ -2,20 +2,21 @@ package com.yidianling.consultant
import android.annotation.SuppressLint
import android.text.TextUtils
import com.google.gson.Gson
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.mvp.base.SimplePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import com.ydl.ydlcommon.utils.YDLAsyncUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.ydl.ydlcommon.utils.remind.HttpErrorUtils
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.ExpertSearchBean
import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
import com.yidianling.consultant.model.bean.Extras
import com.yidianling.user.api.service.IUserService
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
......@@ -24,6 +25,7 @@ import io.reactivex.schedulers.Schedulers
* 专家搜索页Presenter
*/
class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
var mExtras: Extras? =null // 用于分页
@SuppressLint("CheckResult")
fun fetchListHead() {
......@@ -41,150 +43,218 @@ class ExpertSearchPresenter : SimplePresenter<IExpertSearchView>() {
})
}
/**
* 加载缓存
*/
fun localData(showType: Int) {
YDLAsyncUtils.asyncAsResult(object : YDLAsyncUtils.AsyncObjecyerResult {
override fun doAsyncAction(): Any {
return when (showType) {
0 -> {//按专家
YDLCacheUtils.getDoctorListData()
}
1 -> {//按服务
YDLCacheUtils.getServerListData()
}
else -> {
YDLCacheUtils.getServerListData()
}
}
}
override fun asyncResult(`object`: Any?) {
//如果没有缓存数据,显示加载框
if (`object` !is String || TextUtils.isEmpty(`object`)) {
mView.showRefreshLayout()
}
@SuppressLint("CheckResult")
fun fetchListData(allFilter: AllFilter, extras: Extras?) {
//是否亲子教育字段
// ConsultAssistantDialogUtils.REALATION_EDUCATION = allFilter.categories.size == 1 && allFilter.categories[0].cateId == "23"
if (`object` is String) {
val gson = Gson()
val bean =
gson.fromJson<ExpertSearchBean>(`object`, ExpertSearchBean::class.java)
// val bean = gson.fromJson<ExpertSearchBean>(`object`, object : TypeToken<ExpertSearchBean>() {}.type)
if (bean?.list != null) {
when (showType) {
0 -> {
mView.onDoctorListFetched(bean.list, 1, 1)
}
1 -> {
mView.onServiceListFetched(bean.list, 1, 1)
}
else -> {
mView.onServiceListFetched(bean.list, 1, 1)
}
val map = HashMap<String, Any>()
// filter
val filterMap = HashMap<String, Any?>()
// 搜索词
if (!TextUtils.isEmpty(allFilter.searchWord)){
filterMap["__keywords"] = allFilter.searchWord
}
val categoryList = ArrayList<Any>()
// 八大类一级标签
if (allFilter.categoryId2List.size>0){
val categoryMap2 = HashMap<String, Any>()
val categoryIdMap2 = HashMap<String, Any>()
categoryIdMap2["in"] = allFilter.categoryId2List
categoryMap2["product_cates.category_id2"] = categoryIdMap2
categoryList.add(categoryMap2)
}
// 八大类二级标签
if (allFilter.categoryId3List.size>0){
val categoryMap3 = HashMap<String, Any>()
val categoryIdMap3 = HashMap<String, Any>()
categoryIdMap3["in"] = allFilter.categoryId3List
categoryMap3["product_cates.category_id3"] = categoryIdMap3
categoryList.add(categoryMap3)
}
if (categoryList.size>0){
filterMap["__or"] = categoryList
}
// 主题
if (allFilter.categories.size>0) {
val categories = ArrayList<String?>()
allFilter.categories.forEach {
categories.add(it.cateId)
}
val categoriesMap = HashMap<String, Any>()
categoriesMap["in"] = categories
filterMap["tags.tag_id"] = categoriesMap
}
// 地区
if (allFilter.region.value == "海外") {
filterMap["country_code"] = allFilter.sub.code
} else{
if (allFilter.region.code != null) {
filterMap["province_code"] = allFilter.region.code
}
if (allFilter.sub.code != null) {
filterMap["city_code"] = allFilter.sub.code
}
}
// 咨询方式
if (allFilter.enquiries.isNotEmpty()) {
val way = ArrayList<Int>()
allFilter.enquiries.forEach {
way.add(it.key)
}
})
val wayMap = HashMap<String, Any>()
wayMap["in"] = way
filterMap["service_type_list.service_type"] = wayMap
}
fun updateCache(showType: Int, searchBean: ExpertSearchBean) {
val gson = Gson()
val json = gson.toJson(searchBean)
when (showType) {
0 -> {
YDLCacheUtils.saveDoctorListData(json)
// 服务均价
if (allFilter.priceRanges != null) {
val avgPriceMap = HashMap<String, Any?>()
avgPriceMap["gte"] = allFilter.priceRanges?.minPrice
avgPriceMap["lte"] = allFilter.priceRanges?.maxPrice
filterMap["avg_price"] = avgPriceMap
}
1 -> {
YDLCacheUtils.saveServerListData(json)
// 年龄
if (allFilter.ages.isNotEmpty()) {
val age = ArrayList<Int>()
allFilter.ages.forEach {
age.add(it.key)
}
val ageMap = HashMap<String, Any>()
ageMap["in"] = age
filterMap["years"] = ageMap
}
// 资质
if (allFilter.title.isNotEmpty()) {
val title = ArrayList<String?>()
allFilter.title.forEach {
title.add(it.key)
}
@SuppressLint("CheckResult")
fun fetchListData(allFilter: AllFilter, page: Int) {
//是否亲子教育字段
ConsultAssistantDialogUtils.REALATION_EDUCATION =
allFilter.categories.size == 1 && allFilter.categories[0].cateId == "23"
var showType = 0
val sb = StringBuffer()
sb.append("searchWord=")
.append(if (TextUtils.isEmpty(allFilter.searchWord)) "" else allFilter.searchWord)
if (allFilter.categories.isNotEmpty()) {
var categorys = allFilter.categories.map { it.cateId }.joinToString(",")
if ("0" == categorys) {
categorys = ""
}
sb.append("&directionTags=").append(categorys)
}
if (allFilter.region.value == "海外"||allFilter.region.value=="全国") {
sb.append("&country=").append(allFilter.sub.code)
} else{
if (allFilter.region.code != null) {
sb.append("&province=").append(allFilter.region.code)
val titleMap = HashMap<String, Any>()
titleMap["in"] = title
filterMap["titles.title"] = titleMap
}
if (allFilter.sub.code != null) {
sb.append("&city=").append(allFilter.sub.code)
// 擅长人群
if (allFilter.specialityCrowd.isNotEmpty()) {
val specialityCrowd = ArrayList<String?>()
allFilter.specialityCrowd.forEach {
specialityCrowd.add(it.key)
}
val specialityCrowdMap = HashMap<String, Any>()
specialityCrowdMap["in"] = specialityCrowdMap
filterMap["doctor_tag_list.list.tag_id"] = specialityCrowdMap
}
if (allFilter.reorder.key != null) {
sb.append("&reorder=").append(allFilter.reorder.key)
// 学历
if (allFilter.doctorEdu.isNotEmpty()) {
val edu = ArrayList<Int?>()
allFilter.doctorEdu.forEach {
edu.add(it.key)
}
if (allFilter.enquiries.isNotEmpty()) {
sb.append("&enquirys=").append(allFilter.enquiries.map { it.key }.joinToString(","))
val eduMap = HashMap<String, Any>()
eduMap["in"] = edu
filterMap["edu"] = eduMap
}
if (allFilter.ages.isNotEmpty()) {
sb.append("&ages=").append(allFilter.ages.map { it.key }.joinToString(","))
// 其它
if (allFilter.others.isNotEmpty()) {
val gender = 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")
// }
else -> {
filterMap[it.key1] = it.value1
}
if (allFilter.doctorEdu.isNotEmpty()) {
sb.append("&edus=").append(allFilter.doctorEdu.map { it.key }.joinToString(","))
}
// 擅长人群拼接
if (allFilter.specialityCrowd.isNotEmpty()) {
sb.append("&crowdsTags=")
.append(allFilter.specialityCrowd.map { it.key }.joinToString(","))
}
if (allFilter.others.isNotEmpty()) {
sb.append("&others=").append(allFilter.others.map { it.key }.joinToString(","))
if (gender.size>0){
val genderMap = HashMap<String, Any>()
genderMap["in"] = gender
filterMap["gender"] = genderMap
}
// if (allFilter.showType.key != null) {
// showType = allFilter.showType.key!!
// sb.append("&showType=").append(allFilter.showType.key!!)
// if (bookIngStatusList.size>0){
// val bookStatusMap = HashMap<String, Any>()
// bookStatusMap["in"] = bookIngStatusList
// filterMap["booking_status"] = bookStatusMap
// }
if (allFilter.title.isNotEmpty()) {
sb.append("&title=").append(allFilter.title.map { it.key }.joinToString(","))
}
if (allFilter.priceRanges != null) {
sb.append("&minPrice=").append(allFilter.priceRanges?.minPrice)
sb.append("&maxPrice=").append(allFilter.priceRanges?.maxPrice)
}
sb.append("&page=").append(page)
ExpertSearchDataManager.getHttp().searchDoctor(sb.toString())
map["filter"] = filterMap
// sorts
if (allFilter.reorder.key != null) {
val sortsMap = HashMap<String, Any>()
sortsMap[allFilter.reorder.key1] = allFilter.reorder.value1
map["sorts"] = sortsMap
}
// fields
val fieldsMap = HashMap<String, Any>()
fieldsMap["doctor_id"] = true
fieldsMap["doctor_name"] = true
fieldsMap["uid"] = true
fieldsMap["chat_status"] = true
// fieldsMap["consult_status"] = true
// fieldsMap["listen_status"] = true
// fieldsMap["booking_status"] = true
fieldsMap["gender"] = true
fieldsMap["years"] = true
fieldsMap["head"] = true
fieldsMap["edu"] = true
fieldsMap["province"] = true
fieldsMap["city"] = true
fieldsMap["evaluation_average_score"] = true
fieldsMap["evaluate_num"] = true
fieldsMap["min_price"] = true
fieldsMap["title"] = true
fieldsMap["famous_remark"] = true
fieldsMap["help_num"] = true
fieldsMap["p30d_sold_hour"] = true
fieldsMap["sum_service_time"] = true
fieldsMap["has_servicefree_consult"] = true
fieldsMap["is_new_enter"] = true
fieldsMap["chat_num"] = true
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?>()
optionsMap["search_scene_id"] = "doctor_main_search"
optionsMap["uid"] = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid
optionsMap["ffrom"] = PlatformDataManager.getRam().getChannelName()
optionsMap["version"]= RxAppTool.getAppVersionName(BaseApp.getApp())
optionsMap["os_type"]= 2
if (extras!=null){
optionsMap["extras"] = extras
}
map["options"] = optionsMap
ExpertSearchDataManager.getHttp()
.getExpertList(map)
.compose(RxLifecycleUtils.bindToLifecycle(mView))
.compose(RxUtils.resultJavaData())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
if (null != it.list && it.list.isNotEmpty()) {
// if (showType == 0) {
// mView.onDoctorListFetched(it.list!!, page, it.pages)
// } else {
// mView.onServiceListFetched(it.list!!, page, it.pages)
// }
mView.onDoctorListFetched(it.list, page, it.pages)
//更新缓存 只更新第一页的缓存
if (page == 1) {
updateCache(showType, it)
}
} else {
// 当前页数
val curPage = (it.skip/it.limit)+1
if (curPage==1&&it.objects.size==0){
mView.fetchListEmpty("没有搜到相关信息,换个关键词看看吧")
}else{
mExtras = it.extras
mView.onDoctorListFetched(it.objects, mExtras,curPage)
}
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
mView.fetchListFailed(msg)
}
})
......
......@@ -11,31 +11,24 @@ import android.view.WindowManager
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.ydl.ydl_image.config.ISimpleImageOpConfig
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager
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.modular.ModularServiceManager
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.FixSizeLinkedList
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.SharedPreferencesEditor
import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.*
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.view.banner.GlideImageLoader
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.adapter.SearchWordsAdapter
import com.yidianling.consultant.api.IConsultantService
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.HotSearchFocusItemBean
import com.yidianling.consultant.bean.HotSearchKeyWordDataBean
import com.yidianling.consultant.bean.HotSearchPopularDoctorBean
import com.yidianling.consultant.bean.*
import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.modular.utils.ConsultAssistantEntryUtils
......@@ -45,9 +38,10 @@ 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 {
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 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)
......@@ -64,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
}
......@@ -84,7 +79,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
private fun getDataFromIntent() {
var doctorName = intent.getStringExtra(HOT_SEARCH_DOCTOR_NAME)
val doctorName = intent.getStringExtra(HOT_SEARCH_DOCTOR_NAME)
if (!TextUtils.isEmpty(doctorName)) {
etSearch.setText(doctorName)
iv_delete_icon.visibility = View.VISIBLE
......@@ -92,18 +87,35 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
private fun initViews() {
StatusBarUtils.statusBarLightMode(this)
maxWidth = (2 * RxDeviceTool.getScreenWidth(this@HotSearchActivity)) - RxImageTool.dip2px(60f)
dp42 = RxImageTool.dip2px(60f)
iv_delete_icon.setOnClickListener {
etSearch.setText("")
}
etSearch.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
doSearch()
// 搜索的关联词
var relatedWords = ""
var isRecommendWords = false
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)){
relatedWords = searchSuggestList[0].suggest_content
}
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)
}
true
}
etSearch.setOnEditorActionListener { _, actionId, _ ->
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
doSearch()
}
true
}
......@@ -126,18 +138,42 @@ 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?.get(0)!!.location.toInt(),"learning")
ConsultAssistantEntryUtils.jumpConsultAssistant(this, data[0].location.toInt(),"learning")
}
}
searchWordsAdapter = SearchWordsAdapter(searchSuggestList)
rv_search_words.layoutManager = LinearLayoutManager(this)
rv_search_words.adapter = searchWordsAdapter
searchWordsAdapter.setOnItemClickListener { adapter, view, position ->
// 搜索的关联词
var relatedWords = ""
var isRecommendWords = false
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)){
relatedWords = searchSuggestList[position].suggest_content
}
}
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")
}
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)
} else {
iv_delete_icon.visibility = View.VISIBLE
getSearchWords(s.toString(),false)
}
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
......@@ -147,10 +183,53 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
})
StatusBarUtils.statusBarLightMode(this)
maxWidth =
(2 * RxDeviceTool.getScreenWidth(this@HotSearchActivity)) - RxImageTool.dip2px(60f)
dp42 = RxImageTool.dip2px(60f)
}
/**
* 获取搜索联想词
* @param isClickWords 是否是点击历史搜索、热门搜索等进行搜索
*/
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{
rv_search_words.visibility = View.GONE
}
}
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){
relatedWords = searchWordsBean.search_suggests[0].suggest_relations[0]
isRecommendWords = true
}
if (TextUtils.isEmpty(relatedWords)&&!TextUtils.isEmpty(searchWordsBean.search_suggests[0].suggest_content)){
relatedWords = searchWordsBean.search_suggests[0].suggest_content
}
}
doSearch(searchContent,relatedWords,isRecommendWords)
}else{
searchSuggestList.clear()
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{
rv_search_words.visibility = View.GONE
}
}
}
private fun initData() {
......@@ -179,6 +258,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
refreshBanner(null)
}
//刷新 热门搜索
private fun refreshHotSearchData(keywordData: MutableList<HotSearchKeyWordDataBean>?) {
if (null == keywordData || keywordData.isEmpty()) {
......@@ -192,8 +272,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)
}
......@@ -225,8 +304,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
}
}
view.setOnClickListener {
etSearch.setText(hotSearchExpert[index].name)
doSearch()
getSearchWords(etSearch.text.toString(),true)
}
flHotExpert.addView(view)
}
......@@ -235,9 +313,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()) {
......@@ -291,8 +366,7 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
break
}
view.setOnClickListener {
etSearch.setText(historyStr)
doSearch()
getSearchWords(historyStr,true)
}
fl_search_history.addView(view)
}
......@@ -308,32 +382,28 @@ class HotSearchActivity : BaseMvpActivity<IHotSearchContract.View, IHotSearchCon
return rect.width()//文字宽
}
//执行搜索
private fun doSearch() {
/**
* 搜索
* @param isRecommendWords 是否是推荐词
*/
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)
}
val keyWord = etSearch.text.toString()
// if (TextUtils.isEmpty(keyWord.trim())) {
// ToastUtil.toastShort("请输入搜索内容")
// return
// }
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,keyWord)
if (!TextUtils.isEmpty(keyWord)) {
historyList.remove(keyWord)
historyList.add(keyWord)
ActionCountUtils.count(ConsultBIConstants.UserMainEvent.YDL_USER_SEARCH_CLICK,searchWords)
if (!TextUtils.isEmpty(searchWords)) {
historyList.remove(searchWords)
historyList.add(searchWords)
SharedPreferencesEditor.putString(
CACHE_CONSULT_SEARCH_HISTORY_DATA,
Gson().toJson(historyList)
)
}
ExpertSearchActivity.startSearch(this, keyWord)
this.finish()
ExpertSearchActivity.startSearch(this, searchWords,"14",relatedWords,isRecommendWords)
finish()
}
override fun onDestroy() {
......
......@@ -3,23 +3,20 @@ package com.yidianling.consultant
import android.widget.ImageView
import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.consultant.model.bean.DoctorServiceItem
import com.yidianling.consultant.model.bean.ExpertBannerBean
import com.yidianling.consultant.model.bean.ExpertSearchBean
import com.yidianling.consultant.model.bean.ExpertServiceItem
import com.yidianling.consultant.model.bean.Extras
import com.yidianling.consultant.model.bean.HeadData
/**
* Created by zqk on 17-9-19.
*/
interface IExpertSearchView : IView {
fun onServiceListFetched(data: MutableList<DoctorServiceItem>, page: Int, totalPage: Int)
fun showRefreshLayout()
fun localData()
fun updateCache(showType: Int,searchBean: ExpertSearchBean)
fun onHeadFetched(headData: HeadData?)
fun onDoctorListFetched(data: MutableList<DoctorServiceItem>, page: Int,totalPage : Int)
fun onDoctorListFetched(data: MutableList<ExpertServiceItem>, extras: Extras?,curPage:Int)
fun fetchFailed(msg: String?)
fun fetchListFailed(msg: String?)
fun fetchListEmpty(msg: String?)
......
......@@ -32,7 +32,7 @@ class CategoryRecyclerViewAdapter(private val context: Context, private val cate
override fun getItemCount(): Int = categories.size
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val tvSubjectName: TextView = itemView.tvSubjectName
val tvSubjectName: TextView = itemView.tv_sort_name
init {
itemView.setOnClickListener {
......
......@@ -2,35 +2,42 @@ 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
import com.ydl.ydl_image.module.GlideApp
import com.ydl.ydlcommon.base.config.HttpConfig
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
import com.yidianling.consultant.model.bean.DoctorServiceItem
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_activity_hot_search.*
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
/**
......@@ -39,29 +46,89 @@ import java.math.BigDecimal
class ExpertSearchAdapter(
private val context: Context,
private val expertSearchView: IExpertSearchView,
private val listData: ArrayList<DoctorServiceItem>
private val listData: ArrayList<ExpertServiceItem>
) : 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 hasMore = true
var pageIndex: Int = 0
var clickCount=0 // 搜索结果提示标签点击次数
var mIsRecommendWords = false // 是否是推荐词
fun setEntrance( pageIndex: Int) {
fun setEntrance(pageIndex: Int) {
this.pageIndex = pageIndex
}
fun setIsRecommendWords(isRecommend:Boolean){
mIsRecommendWords = isRecommend
}
@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
// 埋点
if (mIsRecommendWords){
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,"ydl_user_map_word_visit",listData[0].search_content,listData[0].related_word,"app")
}else{
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,"ydl_user_correction_word_visit",listData[0].search_content,listData[0].related_word,"app")
}
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
// 埋点
if (mIsRecommendWords){
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,"ydl_user_map_inputword_click",listData[0].related_word,listData[0].search_content,"app")
}else{
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,"ydl_user_correction_inputword_click",listData[0].related_word,listData[0].search_content,"app")
}
}else if (clickCount==2){ // 第二次点击搜索标签隐藏搜索匹配结果提示
// 埋点
if (mIsRecommendWords){
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,"ydl_user_map_recommendword_click",listData[0].search_content,listData[0].related_word,"app")
}else{
ActionCountUtils.baiDuCountSign3(ConsultBIConstants.PART_ID_YDL_USER_MAIN_PAGE,"ydl_user_correction_recommendword_click",listData[0].search_content,listData[0].related_word,"app")
}
listData.removeAt(0)
clickCount = 0 // 点击两次后重置为0
}
}
}
}
}
} else if (holder is NormalViewHolder) {
val itemBean = listData[position]
//头像
val headConfig = SimpleImageOpConfiger()
......@@ -75,23 +142,23 @@ class ExpertSearchAdapter(
headConfig
)
//姓名
holder.tvName.text = itemBean.name
holder.tvName.text = itemBean.doctor_name
//服务中
if (itemBean.inConsult || itemBean.isListening) {
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
} else {
//不是服务中且问询人数大于0
when {
itemBean.chatNum > 5 -> {
itemBean.chat_num > 5 -> {
holder.chat_people_in_question.visibility = View.VISIBLE
holder.chat_people_in_question.text = "多人在问询"
}
itemBean.chatNum > 0 -> {
itemBean.chat_num > 0 -> {
holder.chat_people_in_question.visibility = View.VISIBLE
holder.chat_people_in_question.text = "${itemBean.chatNum}人在问询"
holder.chat_people_in_question.text = "${itemBean.chat_num}人在问询"
}
else -> {
holder.chat_people_in_question.visibility = View.GONE
......@@ -99,7 +166,7 @@ class ExpertSearchAdapter(
}
//可预约
holder.imgHead_online_server.visibility = View.GONE
if (itemBean.isTodayFree == true) {
if (itemBean.is_free_today== 1) {
holder.imgHead_online.visibility = View.VISIBLE
} else {
holder.imgHead_online.visibility = View.GONE
......@@ -115,10 +182,10 @@ class ExpertSearchAdapter(
}
//公益图标,不与其他图标冲突
if (1 == itemBean.hasServiceFree) {
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.serviceFreeIcon)) {
if (1 == itemBean.has_servicefree_consult) {
if (null != itemBean.icons && !TextUtils.isEmpty(itemBean.icons.service_free_icon)) {
expertSearchView.showImage(
itemBean.tagsIcon.serviceFreeIcon,
itemBean.icons.service_free_icon,
holder.imgServiceFree
)
} else {
......@@ -133,13 +200,13 @@ class ExpertSearchAdapter(
}
// 展示了抗疫,就不展示其他标签
if (itemBean.fightEpidemicIconShow) {
itemBean.tagsIcon?.fightEpidemicIcon?.let {
GlideApp.with(context).load(itemBean.tagsIcon?.fightEpidemicIcon)
itemBean.icons?.fight_epidemic_icon?.let {
GlideApp.with(context).load(itemBean.icons?.fight_epidemic_icon)
.into(holder.imgFightEpidemicIcon)
holder.imgFightEpidemicIcon.visibility = View.VISIBLE
}
if(itemBean.joinActivity==true ){
if (itemBean.joinActivity == true) {
//活动图标
if (!TextUtils.isEmpty(itemBean.activityImg)) {
holder.imgActivity.visibility = View.VISIBLE
......@@ -147,7 +214,7 @@ class ExpertSearchAdapter(
} else {
holder.imgActivity.visibility = View.GONE
}
}else{
} else {
holder.imgActivity.visibility = View.GONE
}
......@@ -182,10 +249,10 @@ class ExpertSearchAdapter(
holder.imgActivity.visibility = View.GONE
}
//新驻图标
if (itemBean.isNewEnter) {
if (null != itemBean.tagsIcon && !TextUtils.isEmpty(itemBean.tagsIcon.newEnterIcon)) {
if (itemBean.is_new_enter != null && itemBean.is_new_enter!!) {
if (null != itemBean.icons && !TextUtils.isEmpty(itemBean.icons.new_enter_icon)) {
expertSearchView.showImage(
itemBean.tagsIcon.newEnterIcon,
itemBean.icons.new_enter_icon,
holder.imgNewEnter
)
} else {
......@@ -206,10 +273,10 @@ class ExpertSearchAdapter(
holder.ll_feedbackRate,
false
)
if (itemBean.feedbackRate >= num) {
if (itemBean.evaluation_average_score >= num) {
(view.imgRate as ImageView).background =
context.resources.getDrawable(R.drawable.consultant_expert_search_full_star)
} else if (itemBean.feedbackRate < num && itemBean.feedbackRate > num - 1) {
} else if (itemBean.evaluation_average_score < num && itemBean.evaluation_average_score > num - 1) {
(view.imgRate as ImageView).background =
context.resources.getDrawable(R.drawable.consultant_expert_search_half_star)
} else {
......@@ -221,28 +288,39 @@ class ExpertSearchAdapter(
//XXX人点评
val numSb = StringBuffer()
holder.tv_zixunOrderNum.text =
numSb.append(itemBean.zixunOrderNum).append("").toString()
numSb.append(itemBean.evaluate_num).append("").toString()
//咨询师简介
holder.tvTeamCertifications.text = itemBean.teamCertifications
holder.tvTeamCertifications.text = itemBean.title
//咨询师标签
holder.ll_tags.removeAllViews()
itemBean.tagList?.let {
if (it.isNotEmpty()){
for (tag in itemBean.tagList){
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_tag, holder.ll_tags, false)
tag.tagName?.let { name ->
if (name.length>4){
view.tvTag.text = "${name.substring(0,4)}…"
}else{
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)
tag.tag_name.let { name ->
if (name.length > 4) {
view.tvTag.text = "${name.substring(0, 4)}…"
} else {
view.tvTag.text = name
}
}
if (tag.isHigh==1){
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_E0E0E0))
view.tvTag.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_color_666666
)
)
}
holder.ll_tags.addView(view)
}
......@@ -250,9 +328,9 @@ class ExpertSearchAdapter(
}
//帮助人数
val orderUser = StringBuffer()
holder.tvOrderNum.text = orderUser.append(itemBean.zixunOrderUser).append("").toString()
holder.tvOrderNum.text = orderUser.append(itemBean.help_num).append("").toString()
//私聊文案
if (TextUtils.isEmpty(itemBean.chatBtnText)) {
if (TextUtils.isEmpty(itemBean.chat_btn_text)) {
holder.tvChat.text = "私聊"
holder.tvChat.setTextColor(
ContextCompat.getColor(
......@@ -260,11 +338,16 @@ 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 {
holder.tvChat.text = itemBean.chatBtnText
holder.tvChat.text = itemBean.chat_btn_text
holder.tvChat.setTextColor(
ContextCompat.getColor(
context,
......@@ -279,35 +362,35 @@ class ExpertSearchAdapter(
//服务时长
val durationStringBuffer = StringBuffer()
holder.tvSaleDurationForMonth.text =
durationStringBuffer.append(itemBean.allSaleDuration.toInt()).append("").toString()
durationStringBuffer.append(itemBean.sum_service_time.toInt()).append("").toString()
//价格
val price = BigDecimal(itemBean.minBookingPrice)
// 去掉末尾无用的.00
val price = BigDecimal(itemBean.min_price)
// 去掉末尾无用的.00
holder.tvPrice.text = price.stripTrailingZeros().toPlainString()
//套餐
holder.ll_products.removeAllViews()
if (null != itemBean.products && !itemBean.products.isEmpty()) {
for (item in itemBean.products) {
if (null != itemBean.doctor_products && itemBean.doctor_products.isNotEmpty()) {
for (item in itemBean.doctor_products) {
val view = LayoutInflater.from(context).inflate(
R.layout.consultant_expert_search_products_item,
holder.ll_tags,
false
)
when (item.isPackage) {
1 -> {
when (item.product_type) {
"1" -> {
view.tvTitle.text = "单次"
view.tvTitle.setTextColor(context.resources.getColor(R.color.platform_color_1DA1F2))
view.tvTitle.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_single)
view.tvContent.text = item.name
view.tvContent.text = item.product_name
holder.ll_products.addView(view)
}
2 -> {
"2" -> {
view.tvTitle.text = "套餐"
view.tvTitle.setTextColor(context.resources.getColor(R.color.consultant_color_FF9500))
view.tvTitle.background =
context.resources.getDrawable(R.drawable.consultant_expert_search_menu)
view.tvContent.text = item.name
view.tvContent.text = item.product_name
holder.ll_products.addView(view)
}
else -> {
......@@ -316,9 +399,9 @@ class ExpertSearchAdapter(
}
}
}
} else if (holder is FooterViewHolder) {
LogUtil.e("${listData.size}")
LogUtil.e("${hasMore}")
if (hasMore) {
holder.itemView.visibility = View.VISIBLE
holder.pbLoading.visibility = View.VISIBLE
......@@ -331,7 +414,8 @@ class ExpertSearchAdapter(
}
override fun getItemCount(): Int =
if (listData.size < ExpertSearchActivity.PAGE_SIZE && hasMore) {
// if (listData.size < ExpertSearchActivity.PAGE_SIZE && hasMore) {
if (listData.size==1) {
listData.size
} else {
listData.size + 1
......@@ -339,6 +423,10 @@ class ExpertSearchAdapter(
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)
......@@ -356,9 +444,17 @@ class ExpertSearchAdapter(
}
}
override fun getItemViewType(position: Int): Int = when {
position < listData.size -> NORMAL_VIEW
!hasMore && listData.size == 0 -> EMPTY_VIEW
override fun getItemViewType(position: Int): Int =
when {
position==0&&listData.size>0&&listData[0].is_head_view ->{
HEADER_VIEW
}
position < listData.size -> {
NORMAL_VIEW
}
!hasMore && listData.size == 0 -> {
EMPTY_VIEW
}
else -> FOOT_VIEW
}
......@@ -366,54 +462,78 @@ class ExpertSearchAdapter(
//头像
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
......@@ -422,25 +542,21 @@ class ExpertSearchAdapter(
//跳转专家主页
if (adapterPosition != RecyclerView.NO_POSITION) {
val itemBean = listData[adapterPosition]
var linkUrl = itemBean.linkUrl
var linkUrl = itemBean.link_url
if (!TextUtils.isEmpty(cateId)) {
linkUrl = URLUtils.appendParmas(linkUrl, "cateId", cateId)
}
TempH5RouteUtils.tempH5Route(linkUrl)
if (pageIndex == 0) {
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_DOCTOR_CLICK,
itemBean.doctorId ?: ""
// 埋点
ActionCountUtils.baiDuCountSign3(
ConsultBIConstants.PART_ID_CONSULT_COUNSELOR_LIST_PAGE,
ConsultBIConstants.ConsultEvent.POSITION_CONSULT_COUNSELOR_CARD_CLICK,
itemBean.id ?: "",
"app",
""
)
} else {
ActionCountUtils.count(
ConsultBIConstants.ConsultSearchListEvent.APP_CONSULT_SEARCH_LIST_CONSULT_ITEM_CLICK,
itemBean.doctorId ?: ""
)
}
TempH5RouteUtils.tempH5Route(linkUrl)
}
}
......@@ -450,16 +566,16 @@ class ExpertSearchAdapter(
if (pageIndex == 0) {
ActionCountUtils.count(
ConsultBIConstants.ConsultEvent.APP_CONSULT_LIST_CHAT_CLICK,
doctor.doctorId ?: ""
doctor.id ?: ""
)
} else {
ActionCountUtils.count(
ConsultBIConstants.ConsultSearchListEvent.APP_CONSULT_SEARCH_LIST_CHAT_CLICK,
doctor.doctorId ?: ""
doctor.id ?: ""
)
}
//判断是否已登录
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(context,true)) {
if (!ConsultantIn.getUserImpl().loginByOneKeyLogin(context, true)) {
return@setOnClickListener
}
......@@ -476,6 +592,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!!
......@@ -491,4 +614,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
package com.yidianling.consultant.adapter
import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yidianling.consultant.R
import com.yidianling.consultant.bean.SearchSuggestListBean
/**
* Created by Ykai on 2022/5/30.
*/
class SearchWordsAdapter(data: List<SearchSuggestListBean>) : BaseQuickAdapter<SearchSuggestListBean, BaseViewHolder>(R.layout.consultant_item_search_words,data) {
private var mSearchWord:String = ""
override fun convert(holder: BaseViewHolder, item: SearchSuggestListBean) {
val tvSearchWords = holder.getView<TextView>(R.id.tv_search_words)
tvSearchWords.text = setWordsStyle(item.suggest_content,mSearchWord)
}
fun notifyDataAndSetSearchWord(searchWord: String){
mSearchWord = searchWord
notifyDataSetChanged()
}
private fun setWordsStyle(words:String,searchWord:String):SpannableString{
val spannableString = SpannableString(words)
if (words.contains(searchWord)){
val startIndex = words.indexOf(searchWord)
val endIndex = startIndex+searchWord.length
spannableString.setSpan(ForegroundColorSpan(ContextCompat.getColor(mContext,R.color.platform_main_theme)), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
return spannableString
}
}
\ No newline at end of file
package com.yidianling.consultant.adapter
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.yidianling.consultant.R
import com.yidianling.consultant.model.bean.ChildrenBean
/**
* Created by Ykai on 2022/5/18.
*/
class SortAdapter(data: List<ChildrenBean>) : BaseMultiItemQuickAdapter<ChildrenBean, BaseViewHolder>(data) {
var isVisible = false
init {
addItemType(1, R.layout.consultant_item_sort1)
addItemType(2, R.layout.consultant_item_sort2)
}
override fun convert(holder: BaseViewHolder, item: ChildrenBean) {
when(holder.itemViewType){
1 ->{
holder.setGone(R.id.ll_sort_item,item.isVisible)
holder.setText(R.id.tv_sort_name, item.cate_name)
holder.getView<TextView>(R.id.tv_sort_name).isSelected = item.isSelected
if (item.isSelected){
holder.setTextColor(R.id.tv_sort_name,ContextCompat.getColor(mContext,R.color.platform_main_theme))
}else{
holder.setTextColor(R.id.tv_sort_name,ContextCompat.getColor(mContext,R.color.platform_color_242424))
}
}
2->{
holder.setGone(R.id.ll_sort_item,item.isVisible)
holder.setText(R.id.tv_sort_name, item.cate_name)
holder.getView<TextView>(R.id.tv_sort_name).isSelected = item.isSelected
if (item.isSelected){
holder.setTextColor(R.id.tv_sort_name,ContextCompat.getColor(mContext,R.color.platform_main_theme))
}else{
holder.setTextColor(R.id.tv_sort_name,ContextCompat.getColor(mContext,R.color.platform_color_242424))
}
}
}
}
/**
* 设置大于第12个之后的标签全部显示
*/
fun setAllVisible(){
mData.forEach { bean ->
bean.isVisible = true
}
notifyDataSetChanged()
isVisible = true
}
/**
* 设置大于第12个之后的标签全部隐藏
*/
fun setGone(){
mData.forEachIndexed { index, bean ->
if (index>12){
bean.isVisible = false
}
}
notifyDataSetChanged()
isVisible = false
}
}
\ No newline at end of file
......@@ -31,7 +31,7 @@ class SortRecyclerViewAdapter(private val context: Context,
val item = sortItems[position]
holder.tvSort.text = item.value
if (item.key == selectedSort.key) {
holder.tvSort.setTypeface(Typeface.DEFAULT_BOLD)
holder.tvSort.typeface = Typeface.DEFAULT_BOLD
holder.tvSort.setTextColor(ContextCompat.getColor(context, R.color.platform_main_theme))
// holder.ivCheck.visibility = View.VISIBLE
}
......
......@@ -11,8 +11,8 @@ data class ExpertSearchProductsBean(
/**
* 1.单次/2.套餐
*/
val isPackage : Int?,
val product_type: String?,
/**
* 套餐名称
*/
val name : String?)
\ No newline at end of file
val product_name : String?)
\ No newline at end of file
......@@ -11,16 +11,16 @@ data class ExpertSearchTagsIconBean(
/**
* 优质图标
*/
val abilityLevelIcon : String?,
val ability_level_icon : String?,
/**
* 公益图标
*/
val serviceFreeIcon : String?,
val service_free_icon : String?,
/**
* 新入驻图标
*/
val newEnterIcon : String?,
val new_enter_icon : String?,
/**
* 抗疫先锋图标地址
*/
var fightEpidemicIcon: String? = null)
\ No newline at end of file
var fight_epidemic_icon: String? = null)
\ No newline at end of file
package com.yidianling.consultant.bean
/**
* Created by Ykai on 2022/5/30.
*/
data class SearchWordsBean(
val search_suggests:ArrayList<SearchSuggestListBean>?
)
data class SearchSuggestListBean(
val id:String,
val score:String,
val suggest_content:String,
val suggest_relations:ArrayList<String>,
val search_count: Int,
val suggest_classify_types:ArrayList<String>,
val mapping_classify_type_exist:Boolean
)
\ No newline at end of file
......@@ -19,7 +19,12 @@ class ConsultBIConstants {
const val POSITION_CONSULT_FILTER_RESET_CLICK = "consult_filter_reset_click" //重置
const val POSITION_CONSULT_FILTER_CHECKOUT_CLICK = "consult_filter_checkoutallconsultants_click" //查看XXX位咨询师
const val POSITION_DAOYI_ADVERTISEMENT_CLICK="daoyi_advertisement_page|daoyi_advertisement_click"
const val POSITION_DAOYI_ADVERTISEMENT_VISIT="daoyi_advertisement_page|daoyi_advertisement_visit"
const val PART_ID_CONSULT_COUNSELOR_LIST_PAGE="consult_counselor_list_page" // 咨询师列表页面浏览part_id
const val PART_ID_YDL_USER_MAIN_PAGE="ydl_user_main_page" // 联想词part_id
const val POSITION_CONSULT_COUNSELOR_LIST_PAGE_VISIT="consult_counselor_list_page_visit" // 咨询师列表页面浏览position
const val POSITION_YDL_USER_ASSOCIATE_WORD_VISIT="ydl_user_associate_word_visit" // 联想词曝光position
const val POSITION_YDL_USER_ASSOCIATE_WORD_CLICK="ydl_user_associate_word_click" // 联想词点击position
}
//====================APP咨询列表页(app_consult_list_page)====================
......@@ -51,6 +56,10 @@ class ConsultBIConstants {
const val YDL_USER_CONSULT_TYPE_CLICK: String =
APP_CONSULT_LIST_PAGE + "ydl_user_consult_type_click"//咨询师顶部ICON 厌学专题、限时特惠、精神心理
const val POSITION_CONSULT_COUNSELOR_CARD_CLICK="consult_counselor_card_click" // 咨询师列表点击position
const val POSITION_CHOICE_FILTER_CLICK="choice_filter_click" // 热门点击项position
const val POSITION_TWO_CATEGORY_CLICK="two_category_click" // 八大类标签选择埋点
const val POSITION_GOODAT_CROWD_CLICK="goodat_crowd_click" // 擅长人群埋点
}
}
class ConsultSearchListEvent {
......@@ -69,8 +78,7 @@ class ConsultBIConstants {
class UserMainEvent {
companion object {
private const val YDL_USER_MAIN_PAGE: String =
"ydl_user_main_page|"//壹点灵用户版首页 partId
private const val YDL_USER_MAIN_PAGE: String = "ydl_user_main_page|"//壹点灵用户版首页 partId
const val YDL_USER_SEARCH_CLICK: String =
YDL_USER_MAIN_PAGE + "ydl_user_search_click" //搜索栏
......
......@@ -5,6 +5,7 @@ import com.ydl.ydlcommon.mvp.base.IModel
import com.ydl.ydlcommon.mvp.base.IPresenter
import com.ydl.ydlcommon.mvp.base.IView
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import io.reactivex.Observable
/**
......@@ -26,6 +27,11 @@ class IHotSearchContract {
* 请求失败
*/
fun requestFail()
/**
* 联想词请求成功结果
*/
fun getSearchWordsSuccess(searchWordsBean: SearchWordsBean,searchContent:String,isClickWords:Boolean)
}
interface Presenter : IPresenter<View> {
......@@ -38,6 +44,11 @@ class IHotSearchContract {
* 搜索页接口请求
*/
fun searchData()
/**
* 获取联想词
*/
fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean)
}
interface Model : IModel {
......@@ -45,5 +56,10 @@ class IHotSearchContract {
* 搜索页接口
*/
fun searchData(): Observable<HotSearchBean>
/**
* 获取到联想词
*/
fun getSearchWords(map:HashMap<String,Any>): Observable<SearchWordsBean>
}
}
\ No newline at end of file
......@@ -5,8 +5,7 @@ import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.consultant.bean.ExpertSearchTopShowBean
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.model.bean.ExpertBannerBean
import com.yidianling.consultant.model.bean.ExpertSearchBean
import com.yidianling.consultant.model.bean.ExpertBean
import io.reactivex.Observable
/**
......@@ -45,9 +44,13 @@ class ExpertSearchHttpImpl : IExpertSearchHttp {
return searchApi!!
}
override fun searchDoctor(params: String?): Observable<BaseAPIResponse<ExpertSearchBean>> {
return getSearchApi().searchDoctorService(HttpConfig.JAVA_BASE_URL+ "doctor/nlist?"+params)
// override fun searchDoctor(params: String?): Observable<BaseAPIResponse<ExpertSearchBean>> {
// return getSearchApi().searchDoctorService(HttpConfig.JAVA_BASE_URL+ "doctor/nlist?"+params)
//
// }
override fun getExpertList(map: Map<String, Any>): Observable<BaseAPIResponse<ExpertBean>> {
return getSearchApi().getExpertList(map)
}
override fun getBigShotData(): Observable<BaseAPIResponse<ExpertSearchTopShowBean>> {
......
......@@ -2,8 +2,8 @@ package com.yidianling.consultant.http
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.consultant.bean.ExpertSearchTopShowBean
import com.yidianling.consultant.model.bean.ExpertBannerBean
import com.yidianling.consultant.model.bean.ExpertSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.model.bean.ExpertBean
import io.reactivex.Observable
/**
......@@ -17,7 +17,17 @@ interface IExpertSearchHttp{
/**
* 专家搜索页请求
*/
fun searchDoctor(params : String?): Observable<BaseAPIResponse<ExpertSearchBean>>
// fun searchDoctor(params : String?): Observable<BaseAPIResponse<ExpertSearchBean>>
/**
* 获取搜索联想词
*/
// fun getSearchWords(map:Map<String,Any>): Observable<BaseAPIResponse<SearchWordsBean>>
/**
* 获取专家列表
*/
fun getExpertList(map:Map<String,Any>): Observable<BaseAPIResponse<ExpertBean>>
/**
* 获取当前筛选条件结果数
......
......@@ -4,6 +4,7 @@ import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.http.ExpertSearchParam
import com.yidianling.consultant.model.SearchApi
import io.reactivex.Observable
......@@ -46,4 +47,8 @@ class HotSearchHttpImpl : IHotSearchHttp {
getSearchApi().searchPage()
}
}
override fun getSearchWords(map: HashMap<String, Any>): Observable<BaseAPIResponse<SearchWordsBean>> {
return getSearchApi().getSearchWords(map)
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.yidianling.consultant.http.hotsearch
import com.ydl.ydlcommon.data.http.BaseAPIResponse
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import io.reactivex.Observable
/**
......@@ -13,7 +14,12 @@ import io.reactivex.Observable
*/
interface IHotSearchHttp{
/**
* 测评首页请求
* 搜索页请求
*/
fun searchData(): Observable<BaseAPIResponse<HotSearchBean>>
/**
* 搜索联想词请求
*/
fun getSearchWords(map:HashMap<String,Any>): Observable<BaseAPIResponse<SearchWordsBean>>
}
\ No newline at end of file
package com.yidianling.consultant.layoutmanager;
import android.graphics.Rect;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Ykai on 2022/2/21.
* 流式布局layoutManager
*/
public class FlowLayoutManager extends RecyclerView.LayoutManager {
private static final String TAG = FlowLayoutManager.class.getSimpleName();
final FlowLayoutManager self = this;
protected int width, height;
private int left, top, right;
//最大容器的宽度
private int usedMaxWidth;
//竖直方向上的偏移量
private int verticalScrollOffset = 0;
public int getTotalHeight() {
return totalHeight;
}
//计算显示的内容的高度
protected int totalHeight = 0;
private Row row = new Row();
private List<Row> lineRows = new ArrayList<>();
//保存所有的Item的上下左右的偏移量信息
private SparseArray<Rect> allItemFrames = new SparseArray<>();
public FlowLayoutManager() {
//设置主动测量规则,适应recyclerView高度为wrap_content
setAutoMeasureEnabled(true);
}
//每个item的定义
public class Item {
int useHeight;
View view;
public void setRect(Rect rect) {
this.rect = rect;
}
Rect rect;
public Item(int useHeight, View view, Rect rect) {
this.useHeight = useHeight;
this.view = view;
this.rect = rect;
}
}
//行信息的定义
public class Row {
public void setCuTop(float cuTop) {
this.cuTop = cuTop;
}
public void setMaxHeight(float maxHeight) {
this.maxHeight = maxHeight;
}
//每一行的头部坐标
float cuTop;
//每一行需要占据的最大高度
float maxHeight;
//每一行存储的item
List<Item> views = new ArrayList<>();
public void addViews(Item view) {
views.add(view);
}
}
@Override
public RecyclerView.LayoutParams generateDefaultLayoutParams() {
return new RecyclerView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
//该方法主要用来获取每一个item在屏幕上占据的位置
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
Log.d(TAG, "onLayoutChildren");
totalHeight = 0;
int cuLineTop = top;
//当前行使用的宽度
int cuLineWidth = 0;
int itemLeft;
int itemTop;
int maxHeightItem = 0;
row = new Row();
lineRows.clear();
allItemFrames.clear();
removeAllViews();
if (getItemCount() == 0) {
detachAndScrapAttachedViews(recycler);
verticalScrollOffset = 0;
return;
}
if (getChildCount() == 0 && state.isPreLayout()) {
return;
}
//onLayoutChildren方法在RecyclerView 初始化时 会执行两遍
detachAndScrapAttachedViews(recycler);
if (getChildCount() == 0) {
width = getWidth();
height = getHeight();
left = getPaddingLeft();
right = getPaddingRight();
top = getPaddingTop();
usedMaxWidth = width - left - right;
}
for (int i = 0; i < getItemCount(); i++) {
Log.d(TAG, "index:" + i);
View childAt = recycler.getViewForPosition(i);
if (View.GONE == childAt.getVisibility()) {
continue;
}
measureChildWithMargins(childAt, 0, 0);
int childWidth = getDecoratedMeasuredWidth(childAt);
int childHeight = getDecoratedMeasuredHeight(childAt);
int childUseWidth = childWidth;
int childUseHeight = childHeight;
//如果加上当前的item还小于最大的宽度的话
if (cuLineWidth + childUseWidth <= usedMaxWidth) {
itemLeft = left + cuLineWidth;
itemTop = cuLineTop;
Rect frame = allItemFrames.get(i);
if (frame == null) {
frame = new Rect();
}
frame.set(itemLeft, itemTop, itemLeft + childWidth, itemTop + childHeight);
allItemFrames.put(i, frame);
cuLineWidth += childUseWidth;
maxHeightItem = Math.max(maxHeightItem, childUseHeight);
row.addViews(new Item(childUseHeight, childAt, frame));
} else {
//换行
formatAboveRow();
cuLineTop += maxHeightItem;
totalHeight += maxHeightItem;
itemTop = cuLineTop;
itemLeft = left;
Rect frame = allItemFrames.get(i);
if (frame == null) {
frame = new Rect();
}
frame.set(itemLeft, itemTop, itemLeft + childWidth, itemTop + childHeight);
allItemFrames.put(i, frame);
cuLineWidth = childUseWidth;
maxHeightItem = childUseHeight;
row.addViews(new Item(childUseHeight, childAt, frame));
}
row.setCuTop(cuLineTop);
row.setMaxHeight(maxHeightItem);
//不要忘了最后一行进行刷新下布局
if (i == getItemCount() - 1) {
formatAboveRow();
totalHeight += maxHeightItem;
}
}
totalHeight = Math.max(totalHeight, getVerticalSpace());
Log.d(TAG, "onLayoutChildren totalHeight:" + totalHeight);
fillLayout(recycler, state);
}
//对出现在屏幕上的item进行展示,超出屏幕的item回收到缓存中
private void fillLayout(RecyclerView.Recycler recycler, RecyclerView.State state) {
if (state.isPreLayout() || getItemCount() == 0) { // 跳过preLayout,preLayout主要用于支持动画
return;
}
// 当前scroll offset状态下的显示区域
Rect displayFrame = new Rect(getPaddingLeft(), getPaddingTop() + verticalScrollOffset, getWidth() - getPaddingRight(), verticalScrollOffset + (getHeight() - getPaddingBottom()));
//对所有的行信息进行遍历
for (int j = 0; j < lineRows.size(); j++) {
Row row = lineRows.get(j);
float lineTop = row.cuTop;
float lineBottom = lineTop + row.maxHeight;
//如果该行在屏幕中,进行放置item
// if (lineTop < displayFrame.bottom && displayFrame.top < lineBottom) {
List<Item> views = row.views;
for (int i = 0; i < views.size(); i++) {
View scrap = views.get(i).view;
measureChildWithMargins(scrap, 0, 0);
addView(scrap);
Rect frame = views.get(i).rect;
//将这个item布局出来
layoutDecoratedWithMargins(scrap, frame.left, frame.top - verticalScrollOffset, frame.right, frame.bottom - verticalScrollOffset);
}
// } else {
// //将不在屏幕中的item放到缓存中
// List<Item> views = row.views;
// for (int i = 0; i < views.size(); i++) {
// View scrap = views.get(i).view;
// removeAndRecycleView(scrap, recycler);
// }
// }
}
}
/**
* 计算每一行没有居中的viewgroup,让居中显示
*/
private void formatAboveRow() {
List<Item> views = row.views;
for (int i = 0; i < views.size(); i++) {
Item item = views.get(i);
View view = item.view;
int position = getPosition(view);
//如果该item的位置不在该行中间位置的话,进行重新放置
if (allItemFrames.get(position).top < row.cuTop + (row.maxHeight - views.get(i).useHeight) / 2) {
Rect frame = allItemFrames.get(position);
if (frame == null) {
frame = new Rect();
}
frame.set(allItemFrames.get(position).left, (int) (row.cuTop + (row.maxHeight - views.get(i).useHeight) / 2),
allItemFrames.get(position).right, (int) (row.cuTop + (row.maxHeight - views.get(i).useHeight) / 2 + getDecoratedMeasuredHeight(view)));
allItemFrames.put(position, frame);
item.setRect(frame);
views.set(i, item);
}
}
row.views = views;
lineRows.add(row);
row = new Row();
}
/**
* 竖直方向需要滑动的条件
*
* @return
*/
@Override
public boolean canScrollVertically() {
return true;
}
//监听竖直方向滑动的偏移量
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler,
RecyclerView.State state) {
Log.d("TAG", "totalHeight:" + totalHeight);
//实际要滑动的距离
int travel = dy;
//如果滑动到最顶部
if (verticalScrollOffset + dy < 0) {//限制滑动到顶部之后,不让继续向上滑动了
travel = -verticalScrollOffset;//verticalScrollOffset=0
} else if (verticalScrollOffset + dy > totalHeight - getVerticalSpace()) {//如果滑动到最底部
travel = totalHeight - getVerticalSpace() - verticalScrollOffset;//verticalScrollOffset=totalHeight - getVerticalSpace()
}
//将竖直方向的偏移量+travel
verticalScrollOffset += travel;
// 平移容器内的item
offsetChildrenVertical(-travel);
fillLayout(recycler, state);
return travel;
}
private int getVerticalSpace() {
return self.getHeight() - self.getPaddingBottom() - self.getPaddingTop();
}
public int getHorizontalSpace() {
return self.getWidth() - self.getPaddingLeft() - self.getPaddingRight();
}
}
package com.yidianling.consultant.listener
import com.yidianling.consultant.model.bean.CateItem
/**
* Created by zqk on 17-9-20.
*/
interface OnCategoriesSelectedListener {
fun onCategoriesSelected(categories: ArrayList<CateItem>)
fun onCategoriesSelected(signLit:ArrayList<String>)
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.yidianling.consultant.model
import com.ydl.ydlcommon.data.http.RxUtils
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.http.hotsearch.HotSearchDataManager
import io.reactivex.Observable
......@@ -17,4 +18,8 @@ class HotSearchModelImpl : IHotSearchContract.Model{
override fun searchData(): Observable<HotSearchBean> {
return HotSearchDataManager.getHttp().searchData().compose(RxUtils.resultJavaData())
}
override fun getSearchWords(map:HashMap<String,Any>): Observable<SearchWordsBean> {
return HotSearchDataManager.getHttp().getSearchWords(map).compose(RxUtils.resultJavaData())
}
}
\ No newline at end of file
......@@ -9,7 +9,8 @@ import com.ydl.ydlnet.YDLHttpUtils
import com.yidianling.consultant.bean.ExpertSearchTopShowBean
import com.yidianling.consultant.bean.GuideBean
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.model.bean.ExpertSearchBean
import com.yidianling.consultant.bean.SearchWordsBean
import com.yidianling.consultant.model.bean.ExpertBean
import com.yidianling.consultant.model.bean.HeadData
import io.reactivex.Observable
import retrofit2.http.*
......@@ -38,14 +39,25 @@ interface SearchApi {
fun listHead(@FieldMap maps: Map<String, String>): Observable<BaseResponse<HeadData>>
//搜索条件
@GET("consult/search/v2/conditions")
@GET("consult/search/v3/conditions")
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
fun searchConditions(@Query("cateSource") cateSource: Int): Observable<BaseAPIResponse<HeadData>>
//专家服务搜索
@retrofit2.http.Headers("Content-Type:application/json")
@GET
fun searchDoctorService(@Url url: String): Observable<BaseAPIResponse<ExpertSearchBean>>
/**
* 新咨询师列表接口(包含搜索、筛选咨询师)
*/
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA,"X-App-Id: plough_cloud")
@POST("smart-rank/v1/search")
fun getExpertList(@Body map: Map<String,@JvmSuppressWildcards Any>):Observable<BaseAPIResponse<ExpertBean>>
/**
* 获取搜索联想词
*/
@Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA)
@POST("dmp/v1/searchsuggest")
fun getSearchWords(@Body map: Map<String,@JvmSuppressWildcards Any>):Observable<BaseAPIResponse<SearchWordsBean>>
//搜索页面接口
@retrofit2.http.Headers(YDL_DOMAIN + YDL_DOMAIN_JAVA, "Content-Type:application/json")
......
......@@ -7,5 +7,5 @@ data class AgeItem(
val value: String? = null,
@field:SerializedName("key")
val key: Int? = null
val key: Int
)
\ No newline at end of file
......@@ -23,5 +23,30 @@ data class AllFilter(
val others: ArrayList<OtherItem> = ArrayList(),//其他筛选
val title:ArrayList<ReorderItem> = ArrayList(), //资质
val specialityCrowd:ArrayList<SpecialityCrowdBean> = ArrayList() // 擅长人群
val specialityCrowd:ArrayList<SpecialityCrowdBean> = ArrayList(), // 擅长人群
// 八大类标签集合
val childList:ArrayList<ChildrenBean> = ArrayList(), // 亲子教育
val stressList:ArrayList<ChildrenBean> = ArrayList(), // 情绪压力
val loveEmotionList:ArrayList<ChildrenBean> = ArrayList(), // 恋爱情感
val marriedFamilyList:ArrayList<ChildrenBean> = ArrayList(), // 婚姻家庭
val personalGrowthList:ArrayList<ChildrenBean> = ArrayList(), // 个人成长
val interpersonalRelationshipList:ArrayList<ChildrenBean> = ArrayList(), // 人际关系
val careerDevelopmentList:ArrayList<ChildrenBean> = ArrayList(), // 职场发展
val mentalHealthList:ArrayList<ChildrenBean> = ArrayList(), // 心理健康
// 八大类已选中标签id集合
val categoryId2List:ArrayList<String> = ArrayList(), // 一级类目id集合
val categoryId3List:ArrayList<String> = ArrayList(), // 二级类目id集合
// 八大类选中下标集合,重置的时候可以减少循坏,提升性能
val chooseChildIndexList:ArrayList<Int> = ArrayList(),
val chooseStressIndexList:ArrayList<Int> = ArrayList(),
val chooseLoveEmotionIndexList:ArrayList<Int> = ArrayList(),
val chooseMarriedFamilyIndexList:ArrayList<Int> = ArrayList(),
val choosePersonalGrowthIndexList:ArrayList<Int> = ArrayList(),
val chooseInterpersonalRelationshipIndexList:ArrayList<Int> = ArrayList(),
val chooseCareerDevelopmentIndexList:ArrayList<Int> = ArrayList(),
val chooseMentalHealthIndexList:ArrayList<Int> = ArrayList()
)
\ No newline at end of file
package com.yidianling.consultant.model.bean
import android.os.Parcel
import android.os.Parcelable
import com.chad.library.adapter.base.entity.MultiItemEntity
import com.google.gson.annotations.SerializedName
data class CateItem(
......@@ -10,30 +9,23 @@ data class CateItem(
var cateName: String? = null,
@field:SerializedName("cate_id")
var cateId: String? = null
) : Parcelable {
constructor(parcel: Parcel) : this(
parcel.readString(),
parcel.readString()
) {
}
var cateId: String? = null,
override fun writeToParcel(parcel: Parcel, flags: Int) {
parcel.writeString(cateName)
parcel.writeString(cateId)
}
@field:SerializedName("children")
var children: ArrayList<ChildrenBean>?=null
)
override fun describeContents(): Int {
return 0
}
data class ChildrenBean(var cate_name: String,var cate_id:String,var isVisible: Boolean, var type: Int): MultiItemEntity {
// @field:SerializedName("cate_name")
// var cateName: String? = null,
companion object CREATOR : Parcelable.Creator<CateItem> {
override fun createFromParcel(parcel: Parcel): CateItem {
return CateItem(parcel)
}
// @field:SerializedName("cate_id")
// var cateId: String? = null,
override fun newArray(size: Int): Array<CateItem?> {
return arrayOfNulls(size)
}
// var isVisible: Boolean = false // 是否显示
var isSelected: Boolean = false // 是否选中
override fun getItemType(): Int {
return type
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@ data class EnquiryItem(
val value: String? = null,
@field:SerializedName("key")
val key: Int? = null,
val key: Int,
val checkRrl: String?,
val unCheckUrl: String?
......
package com.yidianling.consultant.model.bean
/**
* @author yuanWai
* @描述:专家搜索页数据bean
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/11
*/
data class ExpertBean(
val amount : Int = 0,
val skip : Int = 0,
val limit : Int = 0,
val size : Int = 10,
val objects : MutableList<ExpertServiceItem>,
// 分页需要
val extras: Extras?)
data class Extras(
val skips: HashMap<String, Int>
)
\ No newline at end of file
package com.yidianling.consultant.model.bean
/**
* @author yuanWai
* @描述:专家搜索页数据bean
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2018/12/11
*/
data class ExpertSearchBean(val endRow : Int = 0,
val hasNextPage : Boolean = false,
val hasPreviousPage : Boolean = false,
val isFirstPage : Boolean = false,
val isLastPage : Boolean = false,
/**
* 数据列表
*/
val list : MutableList<DoctorServiceItem>?,
val navigateFirstPage : Int = 0,
val navigateLastPage : Int = 0,
val navigatePages : Int = 0,
val navigatepageNums : MutableList<Int>?,
val nextPage : Int = 0,
val pageNum : Int = 0,
val pageSize : Int = 0,
/**
* 总页数
*/
val pages : Int = 0,
val prePage : Int = 0,
val size : Int = 0,
val startRow : Int = 0,
/**
* 数据总条数
*/
val total : Int = 0)
\ No newline at end of file
......@@ -10,11 +10,11 @@ import com.yidianling.consultant.bean.ExpertSearchTagsIconBean
* @Company 壹点灵
* @date 2018/12/11
*/
data class DoctorServiceItem(
data class ExpertServiceItem(
/**
* 专家ID
*/
val doctorId: String?,
val id: String,
/**
* 专家uid
*/
......@@ -22,11 +22,11 @@ data class DoctorServiceItem(
/**
* 专家名称
*/
val name: String?,
val doctor_name: String?,
/**
* 跳转路由地址(正常为专家主页地址)
*/
val linkUrl: String?,
val link_url: String?,
/**
* 专家头像地址
*/
......@@ -34,7 +34,7 @@ data class DoctorServiceItem(
/**
* 专家是否在线 1.在线
*/
val isOnline: Int?,
val chat_status: Int?,
/**
* 能力等级 1.实习 2.新手 3.精英
*/
......@@ -42,7 +42,7 @@ data class DoctorServiceItem(
/**
* 有免费咨询:1.有,2.无
*/
val hasServiceFree: Int?,
val has_servicefree_consult: Int?,
/**
* 活动图标
*/
......@@ -54,11 +54,11 @@ data class DoctorServiceItem(
/**
* 是否新入驻:true:是,false:否
*/
var isNewEnter: Boolean = false,
var is_new_enter: Boolean?,
/**
* 好评率(倾诉+咨询)
*/
var feedbackRate: Float = 0f,
var evaluation_average_score: Float = 0f,
/**
* 是否抗疫先锋图标
*/
......@@ -66,59 +66,62 @@ data class DoctorServiceItem(
/**
* 评价数(咨询订单数)
*/
var zixunOrderNum: Int = 0,
var evaluate_num: Int = 0,
/**
* 咨询最低价
*/
val minBookingPrice: String?,
val min_price: String?,
/**
* 资质材料
*/
val teamCertifications: String?,
/**
* 标签分类
*/
val tags: String?,
val title: String?,
/**
* 已帮助人数(咨询人数)
*/
val zixunOrderUser: String?,
val help_num: String?,
/**
* 月售时长
*/
var saleDurationForMonth: Float = 0f,
var p30d_sold_hour: Float = 0f,
/**
* 服务时长
*/
var allSaleDuration: Float = 0f,
var sum_service_time: Float = 0f,
/**
* 服务
*/
val products: MutableList<ExpertSearchProductsBean>?,
val doctor_products: MutableList<ExpertSearchProductsBean>?,
/**
* 标签图片
*/
val tagsIcon: ExpertSearchTagsIconBean?,
/**
* 今日是否可约
*/
val isTodayFree: Boolean?,
/**
* 是否咨询中
*/
var inConsult: Boolean = false,
/**
* 是否聆听中
*/
var isListening: Boolean = false,
val icons: ExpertSearchTagsIconBean?,
// /**
// * 今日是否可约
// */
// 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,
/**
* 私聊人数
*/
var chatNum: Int = 0,
var chat_num: Int = 0,
/**
* 个人铭言
*/
val famousRemark: String?,
val famous_remark: String?,
/**
* 省
*/
......@@ -130,15 +133,36 @@ data class DoctorServiceItem(
/**
* 私聊按钮的文案(如果不为空则取这个字段的值,如果为空 则默认为:“私聊”)
*/
val chatBtnText: String?,
val chat_btn_text: String?,
/**
* 新标签分类
*/
val tagList: ArrayList<TagBean>?
)
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 TagBean(
val tagName:String?,
val isHigh:Int
data class FeatureTag(
val tag_id:String,
val tag_name:String,
val is_highlight:Boolean, // 是否高亮
val type:String // 标签类型
)
\ No newline at end of file
......@@ -45,12 +45,6 @@ data class Filters(
@field:SerializedName("title")
val title: List<ReorderItem> = ArrayList(),
// /**
// * 擅长人群
// */
// @field:SerializedName("crowdsTags")
// val crowdsTags: List<AgeItem> = ArrayList()
/**
* 擅长人群
......
......@@ -8,5 +8,11 @@ data class OtherItem(
val value: String? = null,
@field:SerializedName("key")
val key: Int? = null
val key: Int? = null,
@field:SerializedName("value1")
val value1: String,
@field:SerializedName("key1")
val key1: String
)
\ No newline at end of file
......@@ -8,5 +8,11 @@ data class ReorderItem(
var value: String? = null,
@field:SerializedName("key")
var key: String? = null
var key: String? = null,
@field:SerializedName("value1")
var value1: String="",
@field:SerializedName("key1")
var key1: String=""
)
\ No newline at end of file
//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
......@@ -403,7 +403,7 @@ class ConsultAssistantDialogUtils private constructor() {
.getSecondTaskActivity()?.finish()
activity.finish()
} else {
if (null != activity && !activity.isFinishing) {
if (!activity.isFinishing) {
activity.finish()
}
}
......@@ -417,10 +417,10 @@ class ConsultAssistantDialogUtils private constructor() {
ffrom
)
}
if (null != activity && activity is ConsultAssistantCenterActivity && !activity.isFinishing) activity.finish()
if (activity is ConsultAssistantCenterActivity && !activity.isFinishing) activity.finish()
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
if (null != activity && activity is ConsultAssistantCenterActivity && !activity.isFinishing) activity.finish()
if (activity is ConsultAssistantCenterActivity && !activity.isFinishing) activity.finish()
}
}
)
......
......@@ -53,7 +53,7 @@ object TempH5RouteUtils {
if (!TextUtils.isEmpty(host) && host == "h5") {
//如果是h5,跳转至NewH5Activity
try {
var params = URLDecoder.decode(linkUri.getQueryParameter("params"),"UTF-8")
val params = URLDecoder.decode(linkUri.getQueryParameter("params"),"UTF-8")
ARouter.getInstance().build("/new_h5/h5").withSerializable("routerParam", params).navigation()
return
}catch (e : NullPointerException){
......
package com.yidianling.consultant.presenter
import android.annotation.SuppressLint
import android.content.Context
import android.text.TextUtils
import com.google.gson.Gson
......@@ -8,11 +9,14 @@ import com.ydl.ydlcommon.mvp.base.BasePresenter
import com.ydl.ydlcommon.utils.RxLifecycleUtils
import com.ydl.ydlcommon.utils.YDLAsyncUtils
import com.ydl.ydlcommon.utils.YDLCacheUtils
import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.bean.HotSearchBean
import com.yidianling.consultant.contract.IHotSearchContract
import com.yidianling.consultant.model.HotSearchModelImpl
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import io.reactivex.schedulers.Schedulers
/**
* @author yuanwai
* @描述:搜索页面逻辑实现类
......@@ -20,8 +24,7 @@ import io.reactivex.functions.Consumer
* @Company 壹点灵
* @date 2019/3/19
*/
class HotSearchPresenterImpl () :
BasePresenter<IHotSearchContract.View, IHotSearchContract.Model>(), IHotSearchContract.Presenter{
class HotSearchPresenterImpl : BasePresenter<IHotSearchContract.View, IHotSearchContract.Model>(), IHotSearchContract.Presenter{
/**
* 实例化数据模型
......@@ -57,6 +60,7 @@ class HotSearchPresenterImpl () :
/**
* 搜索页接口
*/
@SuppressLint("CheckResult")
override fun searchData() {
mModel.searchData().map { it }
.filter { it != null }
......@@ -71,4 +75,20 @@ class HotSearchPresenterImpl () :
}
})
}
@SuppressLint("CheckResult")
override fun getSearchWords(map:HashMap<String,Any>,searchContent:String,isClickWords:Boolean) {
mModel.getSearchWords(map)
// .debounce(500L, TimeUnit.MILLISECONDS)
.compose(RxLifecycleUtils.bindToLifecycle(mView))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(Consumer {
mView.getSearchWordsSuccess(it,searchContent,isClickWords)
}, object : ThrowableConsumer() {
override fun accept(msg: String) {
ToastUtil.toastShort(msg)
}
})
}
}
\ No newline at end of file
......@@ -2,48 +2,693 @@ package com.yidianling.consultant.ui.view
import android.content.Context
import android.graphics.drawable.BitmapDrawable
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.PopupWindow
import com.ydl.ydlcommon.view.SpaceItemDecorator2
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.R
import com.yidianling.consultant.adapter.CategoryRecyclerViewAdapter
import com.yidianling.consultant.adapter.SortAdapter
import com.yidianling.consultant.layoutmanager.FlowLayoutManager
import com.yidianling.consultant.listener.OnCategoriesSelectedListener
import com.yidianling.consultant.model.bean.CateItem
import com.yidianling.consultant.model.bean.AllFilter
import com.yidianling.consultant.model.bean.ChildrenBean
import kotlinx.android.synthetic.main.consultant_ui_subject_popup_window.view.*
/**
* 主题弹窗
* Created by zqk on 17-9-15.
*/
class CategoryPopupWindow(context: Context, categories: ArrayList<CateItem>, selectedCategories: ArrayList<CateItem>)
: PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
class CategoryPopupWindow(context: Context,allFilter:AllFilter) : PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, RxImageTool.dp2px(566f)) {
private var view:View = LayoutInflater.from(context).inflate(R.layout.consultant_ui_subject_popup_window, null)
var mAllFilter:AllFilter
private lateinit var ivSortChildEducationOpen: ImageView
private lateinit var ivSortEmotionalStress: ImageView
private lateinit var ivSortLoveEmotion: ImageView
private lateinit var ivSortMarriedFamily: ImageView
private lateinit var ivSortPersonalGrowth: ImageView
private lateinit var ivSortInterpersonalRelationship: ImageView
private lateinit var ivSortCareerDevelopment: ImageView
private lateinit var ivSortMentalHealth: ImageView
var onSubjectsSelectedListener: OnCategoriesSelectedListener? = null
private val childList = ArrayList<ChildrenBean>()
private val stressList = ArrayList<ChildrenBean>()
private val loveEmotionList = ArrayList<ChildrenBean>()
private val marriedFamilyList = ArrayList<ChildrenBean>()
private val personalGrowthList = ArrayList<ChildrenBean>()
private val interpersonalRelationshipList = ArrayList<ChildrenBean>()
private val careerDevelopmentList = ArrayList<ChildrenBean>()
private val mentalHealthList = ArrayList<ChildrenBean>()
private val signList = ArrayList<String>() // 用于埋点
private lateinit var childEducationAdapter:SortAdapter
private lateinit var stressAdapter:SortAdapter
private lateinit var loveEmotionAdapter:SortAdapter
private lateinit var marriedFamilyAdapter:SortAdapter
private lateinit var personalGrowthAdapter:SortAdapter
private lateinit var interpersonalRelationshipAdapter:SortAdapter
private lateinit var careerDevelopmentAdapter:SortAdapter
private lateinit var mentalHealthAdapter:SortAdapter
init {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_ui_subject_popup_window, null)
this.contentView = view
this.isFocusable = true
@Suppress("DEPRECATION")
this.setBackgroundDrawable(BitmapDrawable())
this.isOutsideTouchable = true
val rvSubject = view.rvSubject
val adapter = CategoryRecyclerViewAdapter(context, categories, selectedCategories)
rvSubject.adapter = adapter
rvSubject.layoutManager = GridLayoutManager(
context,
3,
LinearLayoutManager.VERTICAL,
false
)
rvSubject.addItemDecoration(SpaceItemDecorator2(RxImageTool.dp2px(5f), 3))
inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED
mAllFilter = allFilter
initView()
}
private fun initView(){
inputMethodMode = INPUT_METHOD_NEEDED
// 重置
view.btn_reset.setOnClickListener {
reset()
}
// 确定
view.btnConfirm.setOnClickListener {
onSubjectsSelectedListener?.onCategoriesSelected(selectedCategories)
onSubjectsSelectedListener?.onCategoriesSelected(signList)
dismiss()
}
// 亲子教育
val rvSortChildEducation = view.rv_sort_child_education
ivSortChildEducationOpen = view.iv_sort_child_education_open
childEducationAdapter = SortAdapter(childList)
rvSortChildEducation.layoutManager = FlowLayoutManager()
rvSortChildEducation.adapter = childEducationAdapter
childEducationAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (childList[0].isSelected){
childList[0].isSelected = false
mAllFilter.categoryId2List.remove(childList[0].cate_id)
mAllFilter.chooseChildIndexList.remove(position)
signList.remove("亲子教育")
}else{
childList.forEachIndexed { index, _ ->
childList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(childList[0].cate_id)
signList.add("亲子教育")
}else{
mAllFilter.categoryId3List.remove(childList[index].cate_id)
signList.remove(childList[index].cate_name)
}
}
mAllFilter.chooseChildIndexList.add(position)
}
}else{
if (!childList[position].isSelected&&childList[0].isSelected){
childList[0].isSelected = false
mAllFilter.categoryId2List.remove(childList[0].cate_id)
signList.remove("亲子教育")
}
childList[position].isSelected = !childList[position].isSelected
if (childList[position].isSelected){
mAllFilter.categoryId3List.add(childList[position].cate_id)
mAllFilter.chooseChildIndexList.add(position)
signList.add(childList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(childList[position].cate_id)
mAllFilter.chooseChildIndexList.remove(position)
signList.remove(childList[position].cate_name)
}
}
childEducationAdapter.notifyDataSetChanged()
}
// 情绪压力
val rvSortEmotionalStress = view.rv_sort_emotional_stress
ivSortEmotionalStress = view.iv_sort_emotional_stress
stressAdapter = SortAdapter(stressList)
rvSortEmotionalStress.layoutManager = FlowLayoutManager()
rvSortEmotionalStress.adapter = stressAdapter
stressAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (stressList[0].isSelected){
stressList[0].isSelected = false
mAllFilter.categoryId2List.remove(stressList[0].cate_id)
mAllFilter.chooseStressIndexList.remove(position)
signList.remove("情绪压力")
}else{
stressList.forEachIndexed { index, _ ->
stressList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(stressList[0].cate_id)
signList.add("情绪压力")
}else{
mAllFilter.categoryId3List.remove(stressList[index].cate_id)
signList.remove(stressList[index].cate_name)
}
}
mAllFilter.chooseStressIndexList.add(position)
}
}else{
if (!stressList[position].isSelected&&stressList[0].isSelected){
stressList[0].isSelected = false
mAllFilter.categoryId2List.remove(stressList[0].cate_id)
signList.remove("情绪压力")
}
stressList[position].isSelected = !stressList[position].isSelected
if (stressList[position].isSelected){
mAllFilter.categoryId3List.add(stressList[position].cate_id)
mAllFilter.chooseStressIndexList.add(position)
signList.add(stressList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(stressList[position].cate_id)
mAllFilter.chooseStressIndexList.remove(position)
signList.remove(stressList[position].cate_name)
}
}
stressAdapter.notifyDataSetChanged()
}
// 恋爱情感
val rvLoveEmotion = view.rv_sort_love_emotion
ivSortLoveEmotion = view.iv_sort_love_emotion
loveEmotionAdapter = SortAdapter(loveEmotionList)
rvLoveEmotion.layoutManager = FlowLayoutManager()
rvLoveEmotion.adapter = loveEmotionAdapter
loveEmotionAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (loveEmotionList[0].isSelected){
loveEmotionList[0].isSelected = false
mAllFilter.categoryId2List.remove(loveEmotionList[0].cate_id)
mAllFilter.chooseLoveEmotionIndexList.remove(position)
signList.remove("恋爱情感")
}else{
loveEmotionList.forEachIndexed { index, _ ->
loveEmotionList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(loveEmotionList[0].cate_id)
signList.add("恋爱情感")
}else{
mAllFilter.categoryId3List.remove(loveEmotionList[index].cate_id)
signList.remove(loveEmotionList[index].cate_name)
}
}
mAllFilter.chooseLoveEmotionIndexList.add(position)
}
}else{
if (!loveEmotionList[position].isSelected&&loveEmotionList[0].isSelected){
loveEmotionList[0].isSelected = false
mAllFilter.categoryId2List.remove(loveEmotionList[0].cate_id)
signList.remove("恋爱情感")
}
loveEmotionList[position].isSelected = !loveEmotionList[position].isSelected
if (loveEmotionList[position].isSelected){
mAllFilter.categoryId3List.add(loveEmotionList[position].cate_id)
mAllFilter.chooseLoveEmotionIndexList.add(position)
signList.add(loveEmotionList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(loveEmotionList[position].cate_id)
mAllFilter.chooseLoveEmotionIndexList.remove(position)
signList.remove(loveEmotionList[position].cate_name)
}
}
loveEmotionAdapter.notifyDataSetChanged()
}
// 婚姻家庭
ivSortMarriedFamily = view.iv_sort_married_family
val rvSortMarriedFamily = view.rv_sort_married_family
marriedFamilyAdapter = SortAdapter(marriedFamilyList)
rvSortMarriedFamily.layoutManager = FlowLayoutManager()
rvSortMarriedFamily.adapter = marriedFamilyAdapter
marriedFamilyAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (marriedFamilyList[0].isSelected){
marriedFamilyList[0].isSelected = false
mAllFilter.categoryId2List.remove(marriedFamilyList[0].cate_id)
mAllFilter.chooseMarriedFamilyIndexList.remove(position)
signList.remove("婚姻家庭")
}else{
marriedFamilyList.forEachIndexed { index, _ ->
marriedFamilyList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(marriedFamilyList[0].cate_id)
signList.add("婚姻家庭")
}else{
mAllFilter.categoryId3List.remove(marriedFamilyList[index].cate_id)
signList.remove(marriedFamilyList[index].cate_name)
}
}
mAllFilter.chooseMarriedFamilyIndexList.add(position)
}
}else{
if (!marriedFamilyList[position].isSelected&&marriedFamilyList[0].isSelected){
marriedFamilyList[0].isSelected = false
mAllFilter.categoryId2List.remove(marriedFamilyList[0].cate_id)
signList.remove("婚姻家庭")
}
marriedFamilyList[position].isSelected = !marriedFamilyList[position].isSelected
if (marriedFamilyList[position].isSelected){
mAllFilter.categoryId3List.add(marriedFamilyList[position].cate_id)
mAllFilter.chooseMarriedFamilyIndexList.add(position)
signList.add(marriedFamilyList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(marriedFamilyList[position].cate_id)
mAllFilter.chooseMarriedFamilyIndexList.remove(position)
signList.remove(marriedFamilyList[position].cate_name)
}
}
marriedFamilyAdapter.notifyDataSetChanged()
}
// 个人成长
ivSortPersonalGrowth = view.iv_sort_personal_growth
val rvSortPersonalGrowth = view.rv_sort_personal_growth
personalGrowthAdapter = SortAdapter(personalGrowthList)
rvSortPersonalGrowth.layoutManager = FlowLayoutManager()
rvSortPersonalGrowth.adapter = personalGrowthAdapter
personalGrowthAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (personalGrowthList[0].isSelected){
personalGrowthList[0].isSelected = false
mAllFilter.categoryId2List.remove(personalGrowthList[0].cate_id)
mAllFilter.choosePersonalGrowthIndexList.remove(position)
signList.remove("个人成长")
}else{
personalGrowthList.forEachIndexed { index, _ ->
personalGrowthList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(personalGrowthList[0].cate_id)
signList.add("个人成长")
}else{
mAllFilter.categoryId3List.remove(personalGrowthList[index].cate_id)
signList.remove(personalGrowthList[index].cate_name)
}
}
mAllFilter.choosePersonalGrowthIndexList.add(position)
}
}else{
if (!personalGrowthList[position].isSelected&&personalGrowthList[0].isSelected){
personalGrowthList[0].isSelected = false
mAllFilter.categoryId2List.remove(childList[0].cate_id)
signList.remove("个人成长")
}
personalGrowthList[position].isSelected = !personalGrowthList[position].isSelected
if (personalGrowthList[position].isSelected){
mAllFilter.categoryId3List.add(personalGrowthList[position].cate_id)
mAllFilter.choosePersonalGrowthIndexList.add(position)
signList.add(personalGrowthList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(personalGrowthList[position].cate_id)
mAllFilter.choosePersonalGrowthIndexList.remove(position)
signList.remove(personalGrowthList[position].cate_name)
}
}
personalGrowthAdapter.notifyDataSetChanged()
}
// 人际关系
ivSortInterpersonalRelationship = view.iv_sort_interpersonal_relationship
val rvSortInterpersonalRelationship = view.rv_sort_interpersonal_relationship
interpersonalRelationshipAdapter = SortAdapter(interpersonalRelationshipList)
rvSortInterpersonalRelationship.layoutManager = FlowLayoutManager()
rvSortInterpersonalRelationship.adapter = interpersonalRelationshipAdapter
interpersonalRelationshipAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (interpersonalRelationshipList[0].isSelected){
interpersonalRelationshipList[0].isSelected = false
mAllFilter.categoryId2List.remove(interpersonalRelationshipList[0].cate_id)
mAllFilter.chooseInterpersonalRelationshipIndexList.remove(position)
signList.remove("人际关系")
}else{
interpersonalRelationshipList.forEachIndexed { index, _ ->
interpersonalRelationshipList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(interpersonalRelationshipList[0].cate_id)
signList.add("人际关系")
}else{
mAllFilter.categoryId3List.remove(interpersonalRelationshipList[index].cate_id)
signList.remove(interpersonalRelationshipList[index].cate_name)
}
}
mAllFilter.chooseInterpersonalRelationshipIndexList.add(position)
}
}else{
if (!interpersonalRelationshipList[position].isSelected&&interpersonalRelationshipList[0].isSelected){
interpersonalRelationshipList[0].isSelected = false
mAllFilter.categoryId2List.remove(interpersonalRelationshipList[0].cate_id)
signList.remove("人际关系")
}
interpersonalRelationshipList[position].isSelected = !interpersonalRelationshipList[position].isSelected
if (interpersonalRelationshipList[position].isSelected){
mAllFilter.categoryId3List.add(interpersonalRelationshipList[position].cate_id)
mAllFilter.chooseInterpersonalRelationshipIndexList.add(position)
signList.add(interpersonalRelationshipList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(interpersonalRelationshipList[position].cate_id)
mAllFilter.chooseInterpersonalRelationshipIndexList.remove(position)
signList.remove(interpersonalRelationshipList[position].cate_name)
}
}
interpersonalRelationshipAdapter.notifyDataSetChanged()
}
// 职场发展
ivSortCareerDevelopment = view.iv_sort_career_development
val rvSortCareerDevelopment = view.rv_sort_career_development
careerDevelopmentAdapter = SortAdapter(careerDevelopmentList)
rvSortCareerDevelopment.layoutManager = FlowLayoutManager()
rvSortCareerDevelopment.adapter = careerDevelopmentAdapter
careerDevelopmentAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (careerDevelopmentList[0].isSelected){
careerDevelopmentList[0].isSelected = false
mAllFilter.categoryId2List.remove(childList[0].cate_id)
mAllFilter.chooseCareerDevelopmentIndexList.remove(position)
signList.remove("职场发展")
}else{
careerDevelopmentList.forEachIndexed { index, _ ->
careerDevelopmentList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(careerDevelopmentList[0].cate_id)
signList.add("职场发展")
}else{
mAllFilter.categoryId3List.remove(careerDevelopmentList[index].cate_id)
signList.remove(careerDevelopmentList[index].cate_name)
}
}
mAllFilter.chooseCareerDevelopmentIndexList.add(position)
}
}else{
if (!careerDevelopmentList[position].isSelected&&careerDevelopmentList[0].isSelected){
careerDevelopmentList[0].isSelected = false
mAllFilter.categoryId2List.remove(careerDevelopmentList[0].cate_id)
signList.remove("职场发展")
}
careerDevelopmentList[position].isSelected = !careerDevelopmentList[position].isSelected
if (careerDevelopmentList[position].isSelected){
mAllFilter.categoryId3List.add(careerDevelopmentList[position].cate_id)
mAllFilter.chooseCareerDevelopmentIndexList.add(position)
signList.add(careerDevelopmentList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(careerDevelopmentList[position].cate_id)
mAllFilter.chooseCareerDevelopmentIndexList.remove(position)
signList.remove(careerDevelopmentList[position].cate_name)
}
}
careerDevelopmentAdapter.notifyDataSetChanged()
}
// 心理健康
ivSortMentalHealth = view.iv_sort_mental_health
val rvSortMentalHealth = view.rv_sort_mental_health
mentalHealthAdapter = SortAdapter(mentalHealthList)
rvSortMentalHealth.layoutManager = FlowLayoutManager()
rvSortMentalHealth.adapter = mentalHealthAdapter
mentalHealthAdapter.setOnItemClickListener { adapter, view, position ->
if (position==0){
if (mentalHealthList[0].isSelected){
mentalHealthList[0].isSelected = false
mAllFilter.categoryId2List.remove(mentalHealthList[0].cate_id)
mAllFilter.chooseMentalHealthIndexList.remove(position)
signList.remove("心理健康")
}else{
mentalHealthList.forEachIndexed { index, _ ->
mentalHealthList[index].isSelected = index==0
if (index==0){
mAllFilter.categoryId2List.add(mentalHealthList[0].cate_id)
signList.add("心理健康")
}else{
mAllFilter.categoryId3List.remove(mentalHealthList[index].cate_id)
signList.remove(mentalHealthList[index].cate_name)
}
}
mAllFilter.chooseMentalHealthIndexList.add(position)
}
}else{
if (!mentalHealthList[position].isSelected&&mentalHealthList[0].isSelected){
mentalHealthList[0].isSelected = false
mAllFilter.categoryId2List.remove(mentalHealthList[0].cate_id)
signList.remove("心理健康")
}
mentalHealthList[position].isSelected = !mentalHealthList[position].isSelected
if (mentalHealthList[position].isSelected){
mAllFilter.categoryId3List.add(mentalHealthList[position].cate_id)
mAllFilter.chooseMentalHealthIndexList.add(position)
signList.add(mentalHealthList[position].cate_name)
}else{
mAllFilter.categoryId3List.remove(mentalHealthList[position].cate_id)
mAllFilter.chooseMentalHealthIndexList.remove(position)
signList.remove(mentalHealthList[position].cate_name)
}
}
mentalHealthAdapter.notifyDataSetChanged()
}
/**
* 原来的筛选项写在PopupWindow里边,数据太多的情况下,弹窗第一次打开很慢,所以这里做了一个骚操作,
* 先加载亲子教育和情绪压力的12条数据,之后再加载全部,后期时间充裕可以优化,直接做到页面里边,不要写在PopupWindow里边
*/
// 亲子教育
if (mAllFilter.childList.size>12){
childList.addAll(mAllFilter.childList.subList(0,12))
}else{
childList.addAll(mAllFilter.childList)
}
childEducationAdapter.notifyDataSetChanged()
if (mAllFilter.childList.size>12){
ivSortChildEducationOpen.visibility = View.VISIBLE
view.ll_sort_child_education_open.setOnClickListener {
val params = rvSortChildEducation.layoutParams as LinearLayout.LayoutParams
if (!childEducationAdapter.isVisible){
if (childList.size<=12){
childList.addAll(mAllFilter.childList.subList(12,mAllFilter.childList.size))
childEducationAdapter.notifyDataSetChanged()
}
childEducationAdapter.setAllVisible()
ivSortChildEducationOpen.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
rvSortChildEducation.layoutParams = params
}else{
childEducationAdapter.setGone()
ivSortChildEducationOpen.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
rvSortChildEducation.layoutParams = params
}
}
}
// 情绪压力
if (mAllFilter.stressList.size>12){
stressList.addAll(mAllFilter.stressList.subList(0,12))
}else{
stressList.addAll(mAllFilter.stressList)
}
stressAdapter.notifyDataSetChanged()
if (mAllFilter.stressList.size>12){
ivSortEmotionalStress.visibility = View.VISIBLE
view.ll_sort_emotional_stress.setOnClickListener {
val params = rvSortEmotionalStress.layoutParams as LinearLayout.LayoutParams
if (!stressAdapter.isVisible){
if (stressList.size<=12){
stressList.addAll(mAllFilter.stressList.subList(12,mAllFilter.stressList.size))
stressAdapter.notifyDataSetChanged()
}
stressAdapter.setAllVisible()
ivSortEmotionalStress.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
rvSortEmotionalStress.layoutParams = params
}else{
stressAdapter.setGone()
ivSortEmotionalStress.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
rvSortEmotionalStress.layoutParams = params
}
}
}
}
fun updateData(){
// 恋爱情感
loveEmotionList.addAll(mAllFilter.loveEmotionList)
loveEmotionAdapter.notifyDataSetChanged()
if (loveEmotionList.size>12){
ivSortLoveEmotion.visibility = View.VISIBLE
view.ll_sort_love_emotion.setOnClickListener {
val params = view.rv_sort_love_emotion.layoutParams as LinearLayout.LayoutParams
if (!loveEmotionAdapter.isVisible){
loveEmotionAdapter.setAllVisible()
ivSortLoveEmotion.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
view.rv_sort_love_emotion.layoutParams = params
}else{
loveEmotionAdapter.setGone()
ivSortLoveEmotion.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
view.rv_sort_love_emotion.layoutParams = params
}
}
}
// 婚姻家庭
marriedFamilyList.addAll(mAllFilter.marriedFamilyList)
marriedFamilyAdapter.notifyDataSetChanged()
if (marriedFamilyList.size>12){
ivSortMarriedFamily.visibility = View.VISIBLE
view.ll_sort_married_family.setOnClickListener {
val params = view.rv_sort_married_family.layoutParams as LinearLayout.LayoutParams
if (!marriedFamilyAdapter.isVisible){
marriedFamilyAdapter.setAllVisible()
ivSortMarriedFamily.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
view.rv_sort_married_family.layoutParams = params
}else{
marriedFamilyAdapter.setGone()
ivSortMarriedFamily.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
view.rv_sort_married_family.layoutParams = params
}
}
}
// 个人成长
personalGrowthList.addAll(mAllFilter.personalGrowthList)
personalGrowthAdapter.notifyDataSetChanged()
if (personalGrowthList.size>12){
ivSortPersonalGrowth.visibility = View.VISIBLE
view.ll_sort_personal_growth.setOnClickListener {
val params = view.rv_sort_personal_growth.layoutParams as LinearLayout.LayoutParams
if (!personalGrowthAdapter.isVisible){
personalGrowthAdapter.setAllVisible()
ivSortPersonalGrowth.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
view.rv_sort_personal_growth.layoutParams = params
}else{
personalGrowthAdapter.setGone()
ivSortPersonalGrowth.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
view.rv_sort_personal_growth.layoutParams = params
}
}
}
// 人际关系
interpersonalRelationshipList.addAll(mAllFilter.interpersonalRelationshipList)
interpersonalRelationshipAdapter.notifyDataSetChanged()
if (interpersonalRelationshipList.size>12){
ivSortInterpersonalRelationship.visibility = View.VISIBLE
view.ll_sort_interpersonal_relationship.setOnClickListener {
val params = view.rv_sort_interpersonal_relationship.layoutParams as LinearLayout.LayoutParams
if (!interpersonalRelationshipAdapter.isVisible){
interpersonalRelationshipAdapter.setAllVisible()
ivSortInterpersonalRelationship.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
view.rv_sort_interpersonal_relationship.layoutParams = params
}else{
interpersonalRelationshipAdapter.setGone()
ivSortInterpersonalRelationship.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
view.rv_sort_interpersonal_relationship.layoutParams = params
}
}
}
// 职场发展
careerDevelopmentList.addAll(mAllFilter.careerDevelopmentList)
careerDevelopmentAdapter.notifyDataSetChanged()
if (careerDevelopmentList.size>12){
ivSortCareerDevelopment.visibility = View.VISIBLE
view.ll_sort_career_development.setOnClickListener {
val params = view.rv_sort_career_development.layoutParams as LinearLayout.LayoutParams
if (!careerDevelopmentAdapter.isVisible){
careerDevelopmentAdapter.setAllVisible()
ivSortCareerDevelopment.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
view.rv_sort_career_development.layoutParams = params
}else{
careerDevelopmentAdapter.setGone()
ivSortCareerDevelopment.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
view.rv_sort_career_development.layoutParams = params
}
}
}
// 心理健康
mentalHealthList.addAll(mAllFilter.mentalHealthList)
mentalHealthAdapter.notifyDataSetChanged()
if (mentalHealthList.size>12){
ivSortMentalHealth.visibility = View.VISIBLE
view.ll_sort_mental_health.setOnClickListener {
val params = view.rv_sort_mental_health.layoutParams as LinearLayout.LayoutParams
if (!mentalHealthAdapter.isVisible){
mentalHealthAdapter.setAllVisible()
ivSortMentalHealth.setImageResource(R.drawable.consultant_ic_sort_open)
// 展开的布局设置自适应
params.height = LinearLayout.LayoutParams.WRAP_CONTENT
view.rv_sort_mental_health.layoutParams = params
}else{
mentalHealthAdapter.setGone()
ivSortMentalHealth.setImageResource(R.drawable.consultant_ic_sort_close)
// 关闭的时候布局设置为固定高度
params.height = RxImageTool.dp2px(138f)
view.rv_sort_mental_health.layoutParams = params
}
}
}
}
/**
* 重置
*/
fun reset(){
if (mAllFilter.chooseChildIndexList.size>0){
mAllFilter.chooseChildIndexList.forEach {
childList[it].isSelected = false
}
childEducationAdapter.notifyDataSetChanged()
}
if (mAllFilter.chooseStressIndexList.size>0){
mAllFilter.chooseStressIndexList.forEach{
stressList[it].isSelected = false
}
stressAdapter.notifyDataSetChanged()
}
if (mAllFilter.chooseLoveEmotionIndexList.size>0){
mAllFilter.chooseLoveEmotionIndexList.forEach {
loveEmotionList[it].isSelected = false
}
loveEmotionAdapter.notifyDataSetChanged()
}
if (mAllFilter.chooseMarriedFamilyIndexList.size>0){
mAllFilter.chooseMarriedFamilyIndexList.forEach {
marriedFamilyList[it].isSelected = false
}
marriedFamilyAdapter.notifyDataSetChanged()
}
if (mAllFilter.choosePersonalGrowthIndexList.size>0){
mAllFilter.choosePersonalGrowthIndexList.forEach{
personalGrowthList[it].isSelected = false
}
personalGrowthAdapter.notifyDataSetChanged()
}
if (mAllFilter.chooseInterpersonalRelationshipIndexList.size>0){
mAllFilter.chooseInterpersonalRelationshipIndexList.forEach {
interpersonalRelationshipList[it].isSelected = false
}
interpersonalRelationshipAdapter.notifyDataSetChanged()
}
if (mAllFilter.chooseCareerDevelopmentIndexList.size>0){
mAllFilter.chooseCareerDevelopmentIndexList.forEach {
careerDevelopmentList[it].isSelected = false
}
careerDevelopmentAdapter.notifyDataSetChanged()
}
if (mAllFilter.chooseMentalHealthIndexList.size>0){
mAllFilter.chooseMentalHealthIndexList.forEach {
mentalHealthList[it].isSelected = false
}
mentalHealthAdapter.notifyDataSetChanged()
}
mAllFilter.categoryId2List.clear()
mAllFilter.categoryId3List.clear()
signList.clear()
}
}
\ No newline at end of file
......@@ -4,47 +4,40 @@ import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.os.Build
import androidx.core.content.ContextCompat
import android.text.*
import android.text.style.AbsoluteSizeSpan
import android.util.Log
import android.view.*
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.view.inputmethod.InputMethodManager
import android.widget.*
import com.bumptech.glide.Glide
import com.ydl.ydlcommon.data.http.RxUtils
import com.ydl.ydlcommon.utils.actionutil.ActionCountUtils
import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.RxKeyboardTool
import com.yidianling.consultant.R
import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.http.ExpertSearchDataManager
import com.yidianling.consultant.listener.OnFilterConfirmListener
import com.yidianling.consultant.model.bean.AllFilter
import com.yidianling.consultant.model.bean.Filters
import com.yidianling.consultant.model.bean.PriceRangesItem
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.consultant_item_filter.view.*
import kotlinx.android.synthetic.main.consultant_item_price_range.view.*
import kotlinx.android.synthetic.main.consultant_ui_filter_popup.view.*
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()
......@@ -121,7 +114,7 @@ class FilterPopupWindow(
@SuppressLint("ClickableViewAccessibility")
private fun initKeyboardListener(view: View) {
var svFilter = view.findViewById<ScrollView>(R.id.sv_filter)
val svFilter = view.findViewById<ScrollView>(R.id.sv_filter)
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
svFilter.setOnTouchListener { _, _ ->
......@@ -246,13 +239,6 @@ class FilterPopupWindow(
biEventParams = tempFilter.doctorEdu.map { it.value }.joinToString(",")
}
}
// 擅长人群拼接
if (tempFilter.specialityCrowd.isNotEmpty()){
sb.append("&crowdsTags=").append(tempFilter.specialityCrowd.map { it.key }.joinToString(","))
if (ConsultBIConstants.POSITION_GOOD_AT_CLICK==biEventName){
biEventParams = tempFilter.specialityCrowd.map { it.key }.joinToString(",")
}
}
if (tempFilter.others.isNotEmpty()) {
sb.append("&others=").append(tempFilter.others.map { it.key }.joinToString(","))
if (ConsultBIConstants.POSITION_OTHER_CHOICE_CLICK == biEventName) {
......@@ -282,50 +268,49 @@ class FilterPopupWindow(
account += tempFilter.priceRanges?.maxPrice?.toDouble()!!
}
biEventParams = (Math.round(account / 2)).toString()
biEventParams = ((account / 2).roundToInt()).toString()
}
}
//用户行为数据埋点
biEvent(biEventName, biEventParams)
// sb.append("&page=").append(1)
ExpertSearchDataManager.getHttp().getFilterCount(sb.toString())
.subscribeOn(Schedulers.io())
.compose(RxUtils.resultJavaData())
.map { it }
.filter { it != null }
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
contentView.btnConfirm.text = if (it > 0) "确定" else "暂无匹配咨询师"
//按钮置灰/解除置灰
contentView.btnConfirm.isEnabled = it > 0
if (it > 0) {
contentView.btnConfirm.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_but_text_color
)
)
contentView.btnConfirm.background =
ContextCompat.getDrawable(context, R.drawable.consultant_bg_radius_5_dark)
// contentView.btnConfirm.setTextColor(ContextCompat.getColor(context,R.color.consultant_white))
} else {
contentView.btnConfirm.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_text_light_color
)
)
contentView.btnConfirm.background =
ContextCompat.getDrawable(context, R.drawable.consultant_bg_radius_5_light)
// contentView.btnConfirm.setTextColor(ContextCompat.getColor(context,R.color.color_999999))
}
}, {
ToastHelper.show(it.message!!)
})
// ExpertSearchDataManager.getHttp().getFilterCount(sb.toString())
// .subscribeOn(Schedulers.io())
// .compose(RxUtils.resultJavaData())
// .map { it }
// .filter { true }
// .observeOn(AndroidSchedulers.mainThread())
// .subscribe({
//
// contentView.btnConfirm.text = if (it > 0) "确定" else "暂无匹配咨询师"
// //按钮置灰/解除置灰
// contentView.btnConfirm.isEnabled = it > 0
// if (it > 0) {
// contentView.btnConfirm.setTextColor(
// ContextCompat.getColor(
// context,
// R.color.platform_but_text_color
// )
// )
// contentView.btnConfirm.background =
// ContextCompat.getDrawable(context, R.drawable.consultant_bg_radius_5_dark)
//// contentView.btnConfirm.setTextColor(ContextCompat.getColor(context,R.color.consultant_white))
// } else {
// contentView.btnConfirm.setTextColor(
// ContextCompat.getColor(
// context,
// R.color.platform_text_light_color
// )
// )
// contentView.btnConfirm.background =
// ContextCompat.getDrawable(context, R.drawable.consultant_bg_radius_5_light)
//// contentView.btnConfirm.setTextColor(ContextCompat.getColor(context,R.color.color_999999))
// }
//
// }, {
// ToastHelper.show(it.message!!)
// })
}
private fun biEvent(biEventName: String, biEventParams: String = "") {
......@@ -465,7 +450,6 @@ class FilterPopupWindow(
textView.isSelected = true
textView.paint.isFakeBoldText = true
}
updateCount(ConsultBIConstants.POSITION_GOOD_AT_CLICK)
}
if (index>19){
......
......@@ -16,7 +16,7 @@ import kotlinx.android.synthetic.main.consultant_ui_sort_popup_window.view.*
* 排序弹窗
* Created by zqk on 17-9-15.
*/
class SortPopupWindow(val context: Context, private val sortItems: ArrayList<ReorderItem>, var selectedSort: ReorderItem, private val onSortItemSelectedListener: OnSortItemSelectedListener)
class SortPopupWindow(val context: Context, sortItems: ArrayList<ReorderItem>, var selectedSort: ReorderItem, onSortItemSelectedListener: OnSortItemSelectedListener)
: PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
private var adapter: SortRecyclerViewAdapter
......@@ -31,12 +31,7 @@ class SortPopupWindow(val context: Context, private val sortItems: ArrayList<Reo
val rvSortItem = view.rvSortItem
adapter = SortRecyclerViewAdapter(context, sortItems, selectedSort, onSortItemSelectedListener)
rvSortItem.adapter = adapter
rvSortItem.layoutManager =
LinearLayoutManager(
context,
LinearLayoutManager.VERTICAL,
false
)
rvSortItem.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
// rvSortItem.addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.VERTICAL))
}
......
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp" />
<solid android:color="@color/platform_main_theme" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="8dp" />
<stroke
android:width="1dp"
android:color="@color/platform_color_EBEBEB" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<stroke
android:width="0.5dp"
android:color="@color/platform_color_EBEBEB" />
<solid android:color="#f9f9f9" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/platform_white">
<LinearLayout
android:id="@+id/clContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_search"
android:layout_width="match_parent"
android:layout_height="@dimen/consultant_title_bar_height"
android:focusable="true"
android:focusableInTouchMode="true"
android:paddingLeft="15dp"
android:tag="tag_search_input">
android:paddingStart="15dp"
android:tag="tag_search_input"
app:layout_constraintTop_toTopOf="parent"
>
<View
android:id="@+id/view_search_input_bg"
......@@ -90,11 +85,24 @@
<View
android:id="@+id/v_topLine"
android:layout_width="match_parent"
android:layout_height="1px"
android:layout_height="0.5dp"
android:layout_below="@+id/rl_search"
android:layout_marginTop="@dimen/platform_dp_6"
android:layout_marginBottom="13dp"
android:background="@color/platform_color_E0E0E0" />
android:background="@color/platform_color_E0E0E0"
app:layout_constraintTop_toBottomOf="@id/rl_search" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:layout_constraintTop_toBottomOf="@id/v_topLine"
>
<LinearLayout
android:id="@+id/clContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.ydl.ydlcommon.view.widgets.RoundImageView
......@@ -239,5 +247,19 @@
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
</ScrollView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_search_words"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@id/v_topLine"
app:layout_constraintBottom_toBottomOf="parent"
android:background="@color/white"
android:layout_marginTop="8dp"
android:visibility="gone"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<?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
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:src="http://schemas.android.com/tools"
android:paddingTop="12dp"
android:paddingBottom="12dp">
<ImageView
android:layout_width="14dp"
android:layout_height="14dp"
android:layout_centerVertical="true"
android:src="@drawable/consultant_icon_input_search"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<TextView
android:id="@+id/tv_search_words"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
src:text="李哈哈"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:textColor="@color/platform_color_242424"
android:layout_marginStart="38dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10dp"
android:paddingTop="12dp"
android:orientation="vertical"
android:id="@+id/ll_sort_item"
>
<TextView
android:id="@+id/tv_sort_name"
android:layout_width="75dp"
android:layout_height="34dp"
android:gravity="center"
android:textColor="@color/consultant_color_search_filter_selector"
android:orientation="vertical"
android:background="@drawable/consultant_bg_search_filter_selector"
android:textSize="14sp"
tools:text="恋爱婚姻" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="10dp"
android:paddingTop="12dp"
android:orientation="vertical"
android:id="@+id/ll_sort_item"
>
<TextView
android:id="@+id/tv_sort_name"
android:layout_width="wrap_content"
android:layout_height="34dp"
android:gravity="center"
android:textColor="@color/consultant_color_search_filter_selector"
android:orientation="vertical"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:background="@drawable/consultant_bg_search_filter_selector"
android:textSize="14sp"
tools:text="恋爱婚姻" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/tvSubjectName"
android:id="@+id/tv_sort_name"
android:layout_width="match_parent"
android:layout_height="36dp"
android:gravity="center"
......
......@@ -8,6 +8,6 @@
android:gravity="center"
android:layout_marginEnd="6dp"
android:padding="3dp"
android:textColor="@color/platform_color_999999"
android:textColor="@color/platform_color_666666"
android:textSize="10sp"
tools:text="恋爱情感" />
......@@ -3,6 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
android:background="@color/platform_white"
android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
......
......@@ -211,12 +211,11 @@
android:layout_width="0dp"
android:layout_height="44dp"
android:layout_marginStart="10dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="@drawable/consultant_bg_radius_5_light"
android:background="@drawable/consultant_bg_radius_5_dark"
android:gravity="center"
android:hint="暂无匹配咨询师"
android:textColor="@color/platform_but_text_color"
android:hint="确定"
android:textColor="@color/white"
android:textColorHint="@color/platform_color_E0E0E0"
android:textSize="16sp" />
</LinearLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="566dp"
android:background="@color/platform_white"
android:orientation="vertical">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="68dp"
android:orientation="vertical">
<LinearLayout
android:id="@+id/ll_sort_child_education_open"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_17"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="服务类型"
android:textSize="@dimen/platform_dp_16"
android:layout_weight="1"
android:includeFontPadding="false"
android:textStyle="bold"
android:text="亲子教育"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_child_education_open"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_child_education"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_emotional_stress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:layout_marginTop="@dimen/platform_dp_24"
android:layout_marginLeft="@dimen/platform_dp_15"
android:layout_marginBottom="7dp"/>
android:includeFontPadding="false"
android:text="情绪压力"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_emotional_stress"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvSubject"
android:id="@+id/rv_sort_emotional_stress"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginEnd="12dp"
android:layout_marginStart="6dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_love_emotion"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:overScrollMode="never"/>
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:id="@+id/btnConfirm"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:includeFontPadding="false"
android:text="恋爱情感"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_love_emotion"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_love_emotion"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_married_family"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:includeFontPadding="false"
android:text="婚姻家庭"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_married_family"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_married_family"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_personal_growth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:includeFontPadding="false"
android:text="个人成长"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_personal_growth"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_personal_growth"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_interpersonal_relationship"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:includeFontPadding="false"
android:text="人际关系"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_interpersonal_relationship"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_interpersonal_relationship"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_career_development"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:includeFontPadding="false"
android:text="职场发展"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_career_development"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_career_development"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
<LinearLayout
android:id="@+id/ll_sort_mental_health"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/platform_dp_25"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="@dimen/platform_dp_16"
android:paddingEnd="@dimen/platform_dp_16">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textStyle="bold"
android:includeFontPadding="false"
android:text="心理健康"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<ImageView
android:id="@+id/iv_sort_mental_health"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/consultant_ic_sort_close"
android:visibility="gone" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_sort_mental_health"
android:layout_width="match_parent"
android:layout_height="138dp"
android:layout_marginStart="6dp"
android:layout_marginEnd="12dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:background="@color/white"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:id="@+id/btn_reset"
android:layout_width="0dp"
android:layout_height="44dp"
android:layout_weight="1"
android:background="@drawable/consultant_stroke_ebebeb_r_8"
android:gravity="center"
android:text="@string/platform_reset"
android:textColor="@color/platform_color_242424"
android:textSize="16sp" />
<TextView
android:id="@+id/btnConfirm"
android:layout_width="0dp"
android:layout_height="44dp"
android:layout_marginBottom="16dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="19dp"
android:background="@drawable/consultant_bg_radius_5_dark"
android:layout_marginStart="13dp"
android:layout_weight="1"
android:background="@drawable/consultant_solid_main_theme_color_r_8"
android:gravity="center"
android:text="@string/platform_confirm"
android:textSize="17dp"
android:textColor="@color/platform_but_text_color" />
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -23,7 +23,6 @@ import com.ydl.ydlcommon.base.config.HttpConfig
import com.ydl.ydlcommon.bean.ShareData
import com.ydl.ydlcommon.data.PlatformRamImpl
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.modular.ModularServiceManager.provide
import com.ydl.ydlcommon.router.IYDLRouterConstant
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.Utils
......@@ -213,9 +212,7 @@ open class HomeBaseImpl : IHomeBaseEvent {
return
}
EventBus.getDefault().post(
HomeModuleTabEvent(
2
)
HomeModuleTabEvent(2,"12")
)
ActionCountUtils.count(HomeBIConstants.YDL_USER_CONSULT_MORE_CLICK)
}
......@@ -286,9 +283,7 @@ open class HomeBaseImpl : IHomeBaseEvent {
return
}
EventBus.getDefault().post(
HomeModuleTabEvent(
2
)
HomeModuleTabEvent(2,"11")
)
ActionCountUtils.count(HomeBIConstants.YDL_USER_CONSULT_CLICK)
}
......
......@@ -75,7 +75,7 @@ interface IHomeBaseEvent {
fun categoryClick(category: HomeHeaderBean.AskCategoryDataBean)
/**
* 预约专家点击事件
* 心理咨询点击事件
*/
fun reservationExpertsClick()
......
......@@ -3,6 +3,12 @@ package com.yidianling.home.api.event;
public class HomeModuleTabEvent {
private int tabIndex;
public String sign; // 用于埋点参数
public HomeModuleTabEvent(int index,String sign) {
tabIndex = index;
this.sign =sign;
}
public HomeModuleTabEvent(int index) {
tabIndex = index;
......
......@@ -119,10 +119,10 @@ class YdlHomeAdapter(private val mContext: Context,
}
override fun getItemViewType(position: Int): Int {
if (position < list.size) {
return list[position].type!!
return if (position < list.size) {
list[position].type!!
} else {
return -1
-1
}
}
......
......@@ -145,10 +145,9 @@ open class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterIm
private fun initView() {
if (HomeViewConfig.getOrder().bannerIndex == null || HomeViewConfig.getOrder().bannerIndex == -1) {
var marginTop = this.resources.getDimension(R.dimen.home_home_title_bar_height)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
//4.4以下不支持状态栏变色
val statusBarHeight = StatusBarUtils.getStatusBarHeight(mActivity)
marginTop += statusBarHeight
}
val lp = home_swipe_refresh_layout.layoutParams as FrameLayout.LayoutParams
lp.topMargin = marginTop.toInt()
home_swipe_refresh_layout.layoutParams = lp
......@@ -179,9 +178,9 @@ open class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterIm
* 初始化状态栏位置
*/
private fun initStatus() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4以下不支持状态栏变色
//4.4以下不支持状态栏变色
val statusBarHeight = StatusBarUtils.getStatusBarHeight(mActivity)
var homeTitleBarHeight = resources.getDimension(R.dimen.home_home_title_bar_height)
val homeTitleBarHeight = resources.getDimension(R.dimen.home_home_title_bar_height)
val lp1 = view_rl_top_bg.layoutParams as RelativeLayout.LayoutParams
lp1.height = (homeTitleBarHeight + statusBarHeight).toInt()
view_rl_top_bg.layoutParams = lp1
......@@ -190,7 +189,6 @@ open class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterIm
lp2.topMargin = statusBarHeight
rl_top.layoutParams = lp2
}
}
override fun initDataAndEventLazy() {
}
......@@ -297,7 +295,7 @@ open class YdlHomeFragment : BaseMvpFragment<IHomeContract.View, HomePresenterIm
val act = homeHeaderBean.activityResponse
if (act != null) {
if (!TextUtils.isEmpty(act!!.imageUrl)) {
if (!TextUtils.isEmpty(act.imageUrl)) {
img_ad.visibility = View.VISIBLE
GlideApp.with(this).load(act!!.imageUrl).into(img_ad)
img_ad.setOnClickListener {
......
......@@ -69,9 +69,9 @@ class HomeButtonBannerView(private val mContext: Context, private var homeEvent:
*/
private fun initButtonView() {
if (null == buttonParams) {
var screenWidth = RxDeviceTool.getScreenWidth(mContext)
var viewWidth = ((screenWidth - 2 * 9 * RxDeviceTool.getScreenDensity(mContext)) / 4).toInt()
var viewHeight = viewWidth * 78 / 80
val screenWidth = RxDeviceTool.getScreenWidth(mContext)
val viewWidth = ((screenWidth - 2 * 9 * RxDeviceTool.getScreenDensity(mContext)) / 4).toInt()
val viewHeight = viewWidth * 78 / 80
buttonParams = LinearLayout.LayoutParams(viewWidth, viewHeight)
buttonParamsFrame = FrameLayout.LayoutParams(viewWidth, viewHeight)
buttonParamsFrame2= FrameLayout.LayoutParams((viewWidth/2.0).toInt(), (viewHeight/2.3).toInt())
......
......@@ -2,9 +2,12 @@ package com.ydl.ydlnet.builder.interceptor.log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;
import com.ydl.ydlnet.utils.CharacterHandler;
import com.ydl.ydlnet.utils.NetLogUtils;
import okhttp3.MediaType;
import okhttp3.Request;
......@@ -52,13 +55,13 @@ public class DefaultFormatPrinter {
public void printJsonRequest(@NonNull Request request, @NonNull String bodyString) {
final String requestBody = LINE_SEPARATOR + BODY_TAG + LINE_SEPARATOR + bodyString;
final String tag = getTag(true);
if (!request.url().toString().contains("writeMaiDianData")){
// if (!request.url().toString().contains("writeMaiDianData")){
NetLogUtils.debugInfo(tag, REQUEST_UP_LINE);
logLines(tag, new String[]{URL_TAG + request.url()}, false);
logLines(tag, getRequest(request), true);
logLines(tag, requestBody.split(LINE_SEPARATOR), true);
NetLogUtils.debugInfo(tag, END_LINE);
}
// }
}
......@@ -70,13 +73,13 @@ public class DefaultFormatPrinter {
public void printFileRequest(@NonNull Request request) {
final String tag = getTag(true);
if (!request.url().toString().contains("writeMaiDianData")){
// if (!request.url().toString().contains("writeMaiDianData")){
NetLogUtils.debugInfo(tag, REQUEST_UP_LINE);
logLines(tag, new String[]{URL_TAG + request.url()}, false);
logLines(tag, getRequest(request), true);
logLines(tag, OMITTED_REQUEST, true);
NetLogUtils.debugInfo(tag, END_LINE);
}
// }
}
......@@ -102,13 +105,13 @@ public class DefaultFormatPrinter {
final String responseBody = LINE_SEPARATOR + BODY_TAG + LINE_SEPARATOR + bodyString;
final String tag = getTag(false);
final String[] urlLine = {URL_TAG + responseUrl, N};
if (!responseUrl.contains("writeMaiDianData")){
// if (!responseUrl.contains("writeMaiDianData")) {
NetLogUtils.debugInfo(tag, RESPONSE_UP_LINE);
logLines(tag, urlLine, true);
logLines(tag, getResponse(headers, chainMs, code, isSuccessful, segments, message), true);
logLines(tag, responseBody.split(LINE_SEPARATOR), true);
NetLogUtils.debugInfo(tag, END_LINE);
}
// }
}
/**
......@@ -127,13 +130,13 @@ public class DefaultFormatPrinter {
@NonNull List<String> segments, @NonNull String message, @NonNull final String responseUrl) {
final String tag = getTag(false);
final String[] urlLine = {URL_TAG + responseUrl, N};
if (!responseUrl.contains("writeMaiDianData")){
// if (!responseUrl.contains("writeMaiDianData")) {
NetLogUtils.debugInfo(tag, RESPONSE_UP_LINE);
logLines(tag, urlLine, true);
logLines(tag, getResponse(headers, chainMs, code, isSuccessful, segments, message), true);
logLines(tag, OMITTED_RESPONSE, true);
NetLogUtils.debugInfo(tag, END_LINE);
}
// }
}
/**
......
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