Commit 1183915e by 霍志良

feat:BUG修改

parent 1899cb1a
...@@ -48,6 +48,7 @@ import com.yidianling.common.tools.LogUtil ...@@ -48,6 +48,7 @@ import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxImageTool import com.yidianling.common.tools.RxImageTool
import com.yidianling.common.tools.ToastUtil import com.yidianling.common.tools.ToastUtil
import com.yidianling.consultant.adapter.ExpertSearchAdapter import com.yidianling.consultant.adapter.ExpertSearchAdapter
import com.yidianling.consultant.bean.ConsultantRecentCity
import com.yidianling.consultant.constants.ConsultBIConstants import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.constants.ConsultBIConstants.ConsultantLocationAuth.Companion.WHETHER_LOCATION_AUTH import com.yidianling.consultant.constants.ConsultBIConstants.ConsultantLocationAuth.Companion.WHETHER_LOCATION_AUTH
import com.yidianling.consultant.listener.* import com.yidianling.consultant.listener.*
...@@ -56,6 +57,7 @@ import com.yidianling.consultant.listener.OnCategoriesSelectedListener ...@@ -56,6 +57,7 @@ import com.yidianling.consultant.listener.OnCategoriesSelectedListener
import com.yidianling.consultant.listener.OnExpertClickListener import com.yidianling.consultant.listener.OnExpertClickListener
import com.yidianling.consultant.listener.OnFilterConfirmListener import com.yidianling.consultant.listener.OnFilterConfirmListener
import com.yidianling.consultant.listener.OnSortItemSelectedListener import com.yidianling.consultant.listener.OnSortItemSelectedListener
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.model.bean.* import com.yidianling.consultant.model.bean.*
import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils import com.yidianling.consultant.modular.singlton.ConsultAssistantDialogUtils
import com.yidianling.consultant.router.ConsultantIn import com.yidianling.consultant.router.ConsultantIn
...@@ -89,6 +91,11 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -89,6 +91,11 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
var bottomWordDisposable: Disposable? = null var bottomWordDisposable: Disposable? = null
var isShow: Boolean = false var isShow: Boolean = false
private lateinit var bottomWordlist: List<FunctionWordBean> private lateinit var bottomWordlist: List<FunctionWordBean>
private var subLocationItem: SubItem? = SubItem()
private var locationRegionItem: RegionItem? = null
private var locationList: ArrayList<SubItem>? = arrayListOf()
private var locationHistoryList: ArrayList<RegionItem>? = arrayListOf()
override fun layoutResId(): Int { override fun layoutResId(): Int {
return R.layout.consultant_activity_expert_search_list return R.layout.consultant_activity_expert_search_list
} }
...@@ -1310,20 +1317,95 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -1310,20 +1317,95 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
refresh() refresh()
} }
@SuppressLint("CheckResult")
fun getRegionByIp(agreeLocation: Boolean) {
if (agreeLocation) {
SearchApi.getSearchApi().getCityByIp()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe({
if (it.code == "200") {
locationList?.clear()
subLocationItem?.code = it.data.city_code
subLocationItem?.key = it.data.city_code
subLocationItem?.value = it.data.city_name
subLocationItem?.locationCode = "-1"
subLocationItem?.let { locationList?.add(it) }
locationRegionItem = locationList?.let { it1 ->
RegionItem(
it1,
value = "定位",
key = it.data.province_code,
code = it.data.province_code
)
}
locationRegionItem?.let { locationHistoryList?.add(0, it) }
showAreaPoPup(agreeLocation)
}
}, {})
} else {
locationList?.clear()
subLocationItem?.code = null
subLocationItem?.key = null
subLocationItem?.value = "开启授权,获得定位城市"
subLocationItem?.locationCode = "NotAuth"
subLocationItem?.let { locationList?.add(it) }
locationRegionItem = locationList?.let { it1 ->
RegionItem(
it1,
value = "定位",
key = null,
code = null
)
}
locationRegionItem?.let { locationHistoryList?.add(0, it) }
showAreaPoPup(agreeLocation)
}
}
//显示地区弹窗 //显示地区弹窗
private fun showAreaPopupWindow(isAgreeLocation: Boolean) { private fun showAreaPopupWindow(isAgreeLocation: Boolean) {
if (headData?.region != null) { if (headData?.region != null) {
val regionPopupWindow = AreaPopupWindow( locationHistoryList?.clear()
//添加历史搜索
var recentCityBean =
MMKV.defaultMMKV().decodeParcelable(
ConsultBIConstants.ConsultantLocationAuth.RECENT_CITY,
ConsultantRecentCity::class.java
)
if (recentCityBean == null) recentCityBean = ConsultantRecentCity(arrayListOf())
locationHistoryList?.add(
RegionItem(
recentCityBean!!.recentCity,
value = "历史",
key = "0",
code = "0"
)
)
//添加定位
getRegionByIp(isAgreeLocation)
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
}
}
private fun showAreaPoPup(isAgreeLocation: Boolean) {
locationHistoryList?.addAll(headData?.region ?: ArrayList())
if (allFilter.region.value == null) allFilter.region = locationRegionItem!!
val regionPopupWindow = locationHistoryList?.let {
AreaPopupWindow(
mActivity, mActivity,
headData?.region ?: ArrayList(), it,
allFilter.region, allFilter.region,
allFilter.sub, allFilter.sub,
isAgreeLocation isAgreeLocation
) )
regionPopupWindow.showAsDropDown(viewSep2) }
regionPopupWindow?.showAsDropDown(viewSep2)
viewDim.visibility = View.VISIBLE viewDim.visibility = View.VISIBLE
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN) updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
regionPopupWindow.setOnDismissListener { regionPopupWindow?.setOnDismissListener {
viewDim.visibility = View.INVISIBLE viewDim.visibility = View.INVISIBLE
if (tvArea.text != "城市") { if (tvArea.text != "城市") {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_FILTERED) updateFilterTextViewStatus(tvArea, FILTER_STATUS_FILTERED)
...@@ -1331,7 +1413,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -1331,7 +1413,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL) updateFilterTextViewStatus(tvArea, FILTER_STATUS_NORMAL)
} }
} }
regionPopupWindow.onRegionSelectedListener = regionPopupWindow?.onRegionSelectedListener =
object : AreaPopupWindow.OnRegionSelectedListener { object : AreaPopupWindow.OnRegionSelectedListener {
override fun onRegionSelected(region: RegionItem, sub: SubItem) { override fun onRegionSelected(region: RegionItem, sub: SubItem) {
updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN) updateFilterTextViewStatus(tvArea, FILTER_STATUS_OPEN)
...@@ -1385,14 +1467,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres ...@@ -1385,14 +1467,10 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
} }
} }
} }
regionPopupWindow.dismiss() regionPopupWindow?.dismiss()
refresh() refresh()
} }
} }
} else {
ToastUtil.toastShort("数据初始化失败,请重试")
getPresenter().fetchListHead()
}
} }
private var mHandler: Handler? = null private var mHandler: Handler? = null
......
...@@ -44,12 +44,11 @@ class AreaPopupWindow( ...@@ -44,12 +44,11 @@ class AreaPopupWindow(
private var recentCityBean: ConsultantRecentCity? = ConsultantRecentCity(arrayListOf()) private var recentCityBean: ConsultantRecentCity? = ConsultantRecentCity(arrayListOf())
var onRegionSelectedListener: OnRegionSelectedListener? = null var onRegionSelectedListener: OnRegionSelectedListener? = null
private var subLocationItem: SubItem? = SubItem() private var subLocationItem: SubItem? = SubItem()
private var locationHistoryList: ArrayList<RegionItem>? = arrayListOf()
private val locationCode = "-1" private val locationCode = "-1"
private val recentCityCode = "0" private val recentCityCode = "0"
private var locationRegionItem: RegionItem? = null private var locationRegionItem: RegionItem? = null
private var locationList: ArrayList<SubItem>? = arrayListOf() private var locationList: ArrayList<SubItem>? = arrayListOf()
private var locationHistoryList = regionList
init { init {
val view = val view =
LayoutInflater.from(context).inflate(R.layout.consultant_ui_region_popup_window, null) LayoutInflater.from(context).inflate(R.layout.consultant_ui_region_popup_window, null)
...@@ -60,27 +59,12 @@ class AreaPopupWindow( ...@@ -60,27 +59,12 @@ class AreaPopupWindow(
this.isOutsideTouchable = true this.isOutsideTouchable = true
this.height = this.height =
((RxDeviceTool.getScreenHeight(context) - RxImageTool.dp2px(90f)) * 0.618).toInt() //设置高度为屏幕的80% ((RxDeviceTool.getScreenHeight(context) - RxImageTool.dp2px(90f)) * 0.618).toInt() //设置高度为屏幕的80%
//根据IP获取当前城市 regionAdapter.regionList = regionList
getRegionByIp(isAgree, true) if (selectedRegion.sub.isNotEmpty()) {
subList.addAll(selectedRegion.sub)
recentCityBean = } else {
MMKV.defaultMMKV().decodeParcelable(RECENT_CITY, ConsultantRecentCity::class.java) subList.addAll(regionList[0].sub)
if (recentCityBean == null) recentCityBean = ConsultantRecentCity(arrayListOf()) }
locationHistoryList?.add(
RegionItem(
recentCityBean!!.recentCity,
value = "历史",
key = recentCityCode,
code = recentCityCode
)
)
locationHistoryList?.addAll(regionList)
regionAdapter.regionList = locationHistoryList!!
subAdapter = SubRecyclerViewAdapter(context, subList, selectedSub, locationCode) subAdapter = SubRecyclerViewAdapter(context, subList, selectedSub, locationCode)
subAdapter.setOnAuthClickLister(object : SubRecyclerViewAdapter.OnAuthClickLister { subAdapter.setOnAuthClickLister(object : SubRecyclerViewAdapter.OnAuthClickLister {
override fun onAuthClick() { override fun onAuthClick() {
...@@ -88,7 +72,6 @@ class AreaPopupWindow( ...@@ -88,7 +72,6 @@ class AreaPopupWindow(
.setTitle("温馨提示") .setTitle("温馨提示")
.setMessage("建议您授权定位权限,就能轻松获取周边优秀咨询师和其他服务") .setMessage("建议您授权定位权限,就能轻松获取周边优秀咨询师和其他服务")
.setLeftOnclick("暂不") { v1 -> .setLeftOnclick("暂不") { v1 ->
dismiss()
}.setRightClick("授权") { v12 -> }.setRightClick("授权") { v12 ->
MMKV.defaultMMKV().encode( MMKV.defaultMMKV().encode(
ConsultBIConstants.ConsultantLocationAuth.WHETHER_LOCATION_AUTH, ConsultBIConstants.ConsultantLocationAuth.WHETHER_LOCATION_AUTH,
...@@ -114,10 +97,10 @@ class AreaPopupWindow( ...@@ -114,10 +97,10 @@ class AreaPopupWindow(
view.rvSub.scrollToPosition(0) view.rvSub.scrollToPosition(0)
} }
view.rvRegion.adapter = regionAdapter view.rvRegion.adapter = regionAdapter
// val i = locationHistoryList!! val i = regionList
// .takeWhile { it.key != selectedRegion.key } .takeWhile { it.key != selectedRegion.key }
// .count() .count()
// view.rvRegion.scrollToPosition(i) view.rvRegion.scrollToPosition(i)
view.rvSub.layoutManager = view.rvSub.layoutManager =
...@@ -137,6 +120,7 @@ class AreaPopupWindow( ...@@ -137,6 +120,7 @@ class AreaPopupWindow(
//倒序保留最近五次的搜索历史记录并去重 //倒序保留最近五次的搜索历史记录并去重
private fun saveCitySearchRecord(data: SubItem) { private fun saveCitySearchRecord(data: SubItem) {
if (data.value == "不限") return
recentCityBean?.let { recentCityBean?.let {
if (it.recentCity.size < 5) { if (it.recentCity.size < 5) {
it.recentCity.add(0, data) it.recentCity.add(0, data)
...@@ -163,26 +147,15 @@ class AreaPopupWindow( ...@@ -163,26 +147,15 @@ class AreaPopupWindow(
subLocationItem?.key = it.data.city_code subLocationItem?.key = it.data.city_code
subLocationItem?.value = it.data.city_name subLocationItem?.value = it.data.city_name
subLocationItem?.locationCode = locationCode subLocationItem?.locationCode = locationCode
locationList?.clear()
subLocationItem?.let { locationList?.add(it) } subLocationItem?.let { locationList?.add(it) }
locationRegionItem =
locationList?.let {
RegionItem(
it,
value = "定位",
key = locationCode,
code = locationCode
)
}
locationRegionItem?.let { locationHistoryList?.add(0, it) }
if (locationRegionItem != null) {
selectedRegion = locationRegionItem!!
regionAdapter.selectedRegion = selectedRegion
}
if (selectedRegion.sub.isNotEmpty()) { locationHistoryList.get(0).code = it.data.province_code
subList.addAll(selectedRegion.sub) locationHistoryList.get(0).key = it.data.province_code
} locationHistoryList.get(0).value = "定位"
locationList?.let { locationHistoryList.get(0).sub = it }
subList.clear()
locationList?.let { it1 -> subList.addAll(it1) }
subAdapter.notifyDataSetChanged() subAdapter.notifyDataSetChanged()
regionAdapter.notifyDataSetChanged() regionAdapter.notifyDataSetChanged()
} }
......
...@@ -208,10 +208,7 @@ class FilterPopupWindow( ...@@ -208,10 +208,7 @@ class FilterPopupWindow(
tempFilter.specialityCrowd.clear() tempFilter.specialityCrowd.clear()
tempFilter.others.clear() tempFilter.others.clear()
tempFilter.title.clear() tempFilter.title.clear()
tempFilter.priceRangesView = null
tempFilter.priceRanges = null
etMinPrice?.setText("")
etMaxPrice?.setText("")
for (v in showTypeViews) { for (v in showTypeViews) {
v.isSelected = false v.isSelected = false
...@@ -257,14 +254,6 @@ class FilterPopupWindow( ...@@ -257,14 +254,6 @@ class FilterPopupWindow(
v.paint.isFakeBoldText = false v.paint.isFakeBoldText = false
} }
} }
for (v in priceRangeViews) {
v.isSelected = false
if (v is TextView) {
v.paint.isFakeBoldText = false
}
}
updateCount(ConsultBIConstants.POSITION_CONSULT_FILTER_RESET_CLICK) updateCount(ConsultBIConstants.POSITION_CONSULT_FILTER_RESET_CLICK)
} }
......
...@@ -63,6 +63,35 @@ class PricePopupWindow( ...@@ -63,6 +63,35 @@ class PricePopupWindow(
onPriceItemSelectedListener.onPriceItemSelected(priceRangesItem) onPriceItemSelectedListener.onPriceItemSelected(priceRangesItem)
dismiss() dismiss()
} }
contentView.price_reset.setOnClickListener {
//重置
contentView.range_price_seekbar.setProgress(0f, 100f)
reset()
}
if (tempFilter.priceRanges != null) {
if (tempFilter.priceRanges?.min_price.isNullOrEmpty()) {
min_Price = "0"
SeekBarLeftValue = 0f
} else {
min_Price = tempFilter.priceRanges?.min_price.toString()
SeekBarLeftValue =
(tempFilter.priceRanges?.min_price.toString().toFloat() / maxPriceValue) * 100f
}
if (tempFilter.priceRanges?.max_price.isNullOrEmpty()) {
max_Price = infiniteText
SeekBarRightValue = 100f
} else {
max_Price = tempFilter.priceRanges?.max_price.toString() + "元"
SeekBarRightValue =
(tempFilter.priceRanges?.max_price.toString().toFloat() / maxPriceValue) * 100f
}
if (SeekBarRightValue > 100f) SeekBarRightValue = 100f
contentView.tv_start_end_price.text = "$min_Price-$max_Price"
contentView.range_price_seekbar.setProgress(SeekBarLeftValue, SeekBarRightValue)
} else {
contentView.range_price_seekbar.setProgress(0f, 100f)
}
contentView.range_price_seekbar.setOnRangeChangedListener(object : OnRangeChangedListener { contentView.range_price_seekbar.setOnRangeChangedListener(object : OnRangeChangedListener {
override fun onRangeChanged( override fun onRangeChanged(
view: RangeSeekBar?, view: RangeSeekBar?,
...@@ -80,6 +109,7 @@ class PricePopupWindow( ...@@ -80,6 +109,7 @@ class PricePopupWindow(
} }
override fun onStartTrackingTouch(view: RangeSeekBar?, isLeft: Boolean) { override fun onStartTrackingTouch(view: RangeSeekBar?, isLeft: Boolean) {
reset()
} }
override fun onStopTrackingTouch(view: RangeSeekBar?, isLeft: Boolean) { override fun onStopTrackingTouch(view: RangeSeekBar?, isLeft: Boolean) {
...@@ -88,6 +118,19 @@ class PricePopupWindow( ...@@ -88,6 +118,19 @@ class PricePopupWindow(
}) })
} }
private fun reset() {
tempFilter.priceRangesView = null
tempFilter.priceRanges = null
contentView?.tv_start_end_price?.text = "0-无限"
for (v in priceRangeViews) {
v.isSelected = false
if (v is TextView) {
v.paint.isFakeBoldText = false
}
}
initPriceTag()
}
fun initPriceTag() { fun initPriceTag() {
val mWidth = (popWidth - RxImageTool.dp2px(52f)) / enquirySize val mWidth = (popWidth - RxImageTool.dp2px(52f)) / enquirySize
for ((index, priceRangesItem) in filterData.priceRanges.withIndex()) { for ((index, priceRangesItem) in filterData.priceRanges.withIndex()) {
...@@ -164,7 +207,7 @@ class PricePopupWindow( ...@@ -164,7 +207,7 @@ class PricePopupWindow(
max_Price = infiniteText max_Price = infiniteText
SeekBarRightValue = 100f SeekBarRightValue = 100f
} else { } else {
max_Price = priceRangesItem.max_price.toString() max_Price = priceRangesItem.max_price.toString() + "元"
SeekBarRightValue = SeekBarRightValue =
(priceRangesItem.max_price.toString().toFloat() / maxPriceValue) * 100f (priceRangesItem.max_price.toString().toFloat() / maxPriceValue) * 100f
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
android:id="@+id/tv_start_end_price" android:id="@+id/tv_start_end_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="200-500" android:text="0-不限"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="@dimen/platform_dp_30" android:layout_marginTop="@dimen/platform_dp_30"
android:textColor="@color/platform_color_black_333333" android:textColor="@color/platform_color_black_333333"
......
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