Commit d8a14b9d by 霍志良

feat:价格筛选回调

parent c18a8b73
......@@ -1307,7 +1307,7 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
pricePopup = PricePopupWindow(
this, headData?.reorder!!,
headData?.filters!!,
tempFilter, allFilter.reorder, this
tempFilter, this
)
pricePopup!!.setOnDismissListener {
......@@ -1395,7 +1395,8 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
if (headData?.region != null) {
val regionPopupWindow = AreaPopupWindow(
this, headData?.region
?: ArrayList(), allFilter.region, allFilter.sub
?: ArrayList(), allFilter.region, allFilter.sub,
true
)
regionPopupWindow.showAsDropDown(viewSep2)
viewDim.visibility = View.VISIBLE
......@@ -1615,7 +1616,9 @@ class ExpertSearchActivity : BaseMvpActivity<IExpertSearchView, ExpertSearchPres
ConsultAssistantDialogUtils.INSTANCE.expertSearchResetStatus()
}
override fun onPriceItemSelected(sortItem: ReorderItem) {
override fun onPriceItemSelected(priceRangesItem: PriceRangesItem) {
//价格筛选回调
allFilter.priceRanges = priceRange
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
}
}
......@@ -892,16 +892,16 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
appbar_layout.postDelayed({
if (MMKV.defaultMMKV().decodeBool(WHETHER_LOCATION_AUTH)) {
//同意定位授权
showAreaPopupWindow()
showAreaPopupWindow(true)
} else {
val dialog = CommonDialog(mContext)
.setTitle("温馨提示")
.setMessage("建议您授权定位权限,就能轻松获取周边优秀咨询师和其他服务")
.setLeftOnclick("暂不") { v1 ->
showAreaPopupWindow()
showAreaPopupWindow(false)
}.setRightClick("授权") { v12 ->
MMKV.defaultMMKV().encode(WHETHER_LOCATION_AUTH, true)
showAreaPopupWindow()
showAreaPopupWindow(true)
}
dialog.show()
}
......@@ -913,7 +913,6 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
hideSoftInput()
appbar_layout.setExpanded(false)
appbar_layout.postDelayed({
// showSortPopupWindow()
showPricePopupWindow()
}, 300)
......@@ -965,7 +964,7 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
pricePopup = PricePopupWindow(
requireContext(), headData?.reorder!!,
headData?.filters!!,
tempFilter, allFilter.reorder, this
tempFilter, this
)
pricePopup!!.setOnDismissListener {
......@@ -1281,13 +1280,14 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
}
//显示地区弹窗
private fun showAreaPopupWindow() {
private fun showAreaPopupWindow(isAgreeLocation: Boolean) {
if (headData?.region != null) {
val regionPopupWindow = AreaPopupWindow(
mActivity,
headData?.region ?: ArrayList(),
allFilter.region,
allFilter.sub
allFilter.sub,
isAgreeLocation
)
regionPopupWindow.showAsDropDown(viewSep2)
viewDim.visibility = View.VISIBLE
......@@ -1515,7 +1515,9 @@ class ExpertSearchFragment : BaseMvpFragment<IExpertSearchView, ExpertSearchPres
ConsultAssistantDialogUtils.INSTANCE.resetStatus()
}
override fun onPriceItemSelected(sortItem: ReorderItem) {
override fun onPriceItemSelected(priceRange: PriceRangesItem) {
//价格筛选回调
allFilter.priceRanges = priceRange
getPresenter().fetchListData(allFilter, getPresenter().mExtras)
}
}
......@@ -16,31 +16,88 @@ import kotlinx.android.synthetic.main.consultant_item_consult_type.view.*
* 城市列表适配器
* Created by zqk on 17-7-21.
*/
class SubRecyclerViewAdapter(val context: Context, val subList: ArrayList<SubItem>, var selectedSub: SubItem) : RecyclerView.Adapter<SubRecyclerViewAdapter.ViewHolder>() {
class SubRecyclerViewAdapter(
val context: Context, val subList: ArrayList<SubItem>,
var selectedSub: SubItem, val locationCode: String
) : RecyclerView.Adapter<SubRecyclerViewAdapter.ViewHolder>() {
var onItemClickListener: MyBaseAdapter.OnItemClickListener<SubItem>? = null
private lateinit var mOnAuthClickLister: OnAuthClickLister
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val subItem = subList[position]
holder.itemView.tvConsultTypeName.text = subItem.value
if (subItem.locationCode == locationCode) {
holder.itemView.reLocation.visibility = View.GONE
holder.itemView.location_img.visibility = View.VISIBLE
holder.itemView.location_img.drawable.setTint(context.resources.getColor(R.color.platform_main_theme))
//选中状态
holder.itemView.tvConsultTypeName.setTypeface(Typeface.DEFAULT_BOLD)
holder.itemView.tvConsultTypeName.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_main_theme
)
)
holder.itemView.isEnabled = true
} else if (subItem.locationCode == "NotAuth") {
//未选中状态
holder.itemView.reLocation.visibility = View.VISIBLE
holder.itemView.reLocation.setOnClickListener {
mOnAuthClickLister.onAuthClick()
}
holder.itemView.location_img.visibility = View.VISIBLE
holder.itemView.tvConsultTypeName.setTypeface(Typeface.DEFAULT)
holder.itemView.tvConsultTypeName.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_default_text_color
)
)
holder.itemView.location_img.drawable.setTint(context.resources.getColor(R.color.platform_color_black_333333))
holder.itemView.isEnabled = false
} else {
holder.itemView.reLocation.visibility = View.GONE
holder.itemView.isEnabled = true
holder.itemView.location_img.visibility = View.GONE
if (selectedSub.code == subItem.code) {
//选中状态
holder.itemView.tvConsultTypeName.setTypeface(Typeface.DEFAULT_BOLD)
holder.itemView.tvConsultTypeName.setTextColor(ContextCompat.getColor(context,R.color.platform_main_theme))
holder.itemView.tvConsultTypeName.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_main_theme
)
)
} else {
//未选中状态
holder.itemView.tvConsultTypeName.setTypeface(Typeface.DEFAULT)
holder.itemView.tvConsultTypeName.setTextColor(ContextCompat.getColor(context,R.color.platform_default_text_color))
holder.itemView.tvConsultTypeName.setTextColor(
ContextCompat.getColor(
context,
R.color.platform_default_text_color
)
)
}
}
}
override fun getItemCount(): Int = subList.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = LayoutInflater.from(context).inflate(R.layout.consultant_item_consult_type, parent, false)
val view = LayoutInflater.from(context)
.inflate(R.layout.consultant_item_consult_type, parent, false)
return ViewHolder(view)
}
interface OnAuthClickLister {
fun onAuthClick()
}
fun setOnAuthClickLister(lister: OnAuthClickLister) {
mOnAuthClickLister = lister
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
init {
itemView.setOnClickListener {
......
package com.yidianling.consultant.listener
import com.yidianling.consultant.model.bean.ReorderItem
import com.yidianling.consultant.model.bean.PriceRangesItem
/**
* Created by zqk on 17-9-20.
*/
interface OnPriceItemSelectedListener {
fun onPriceItemSelected(sortItem: ReorderItem)
fun onPriceItemSelected(priceRangesItem: PriceRangesItem)
}
\ No newline at end of file
......@@ -14,5 +14,6 @@ data class SubItem(
var key: String? = null,
@field:SerializedName("code")
var code: String? = null
var code: String? = null,
var locationCode: String? = ""
) : Parcelable
\ No newline at end of file
......@@ -7,16 +7,16 @@ import androidx.recyclerview.widget.LinearLayoutManager
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.PopupWindow
import androidx.collection.arraySetOf
import com.tencent.mmkv.MMKV
import com.ydl.ydlcommon.adapter.MyBaseAdapter
import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.view.dialog.CommonDialog
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.R
import com.yidianling.consultant.adapter.RegionRecyclerViewAdapter
import com.yidianling.consultant.adapter.SubRecyclerViewAdapter
import com.yidianling.consultant.bean.ConsultantRecentCity
import com.yidianling.consultant.constants.ConsultBIConstants
import com.yidianling.consultant.constants.ConsultBIConstants.ConsultantLocationAuth.Companion.RECENT_CITY
import com.yidianling.consultant.model.SearchApi
import com.yidianling.consultant.model.bean.RegionItem
......@@ -32,7 +32,8 @@ class AreaPopupWindow(
val context: Context,
regionList: ArrayList<RegionItem>,
private var selectedRegion: RegionItem,
private var selectedSub: SubItem
private var selectedSub: SubItem,
private val isAgree: Boolean
) : PopupWindow(null, ViewGroup.LayoutParams.MATCH_PARENT, RxImageTool.dp2px(369f)) {
private val subList = ArrayList<SubItem>()
......@@ -43,6 +44,8 @@ class AreaPopupWindow(
var onRegionSelectedListener: OnRegionSelectedListener? = null
private var subLocationItem: SubItem? = SubItem()
private var locationHistoryList: ArrayList<RegionItem>? = arrayListOf()
private val locationCode = "-1"
private val recentCityCode = "0"
init {
val view =
......@@ -55,7 +58,8 @@ class AreaPopupWindow(
this.height =
((RxDeviceTool.getScreenHeight(context) - RxImageTool.dp2px(90f)) * 0.618).toInt() //设置高度为屏幕的80%
//根据IP获取当前城市
getRegionByIp()
getRegionByIp(isAgree, false)
recentCityBean =
MMKV.defaultMMKV().decodeParcelable(RECENT_CITY, ConsultantRecentCity::class.java)
if (recentCityBean == null) recentCityBean = ConsultantRecentCity(arrayListOf())
......@@ -66,12 +70,12 @@ class AreaPopupWindow(
RegionItem(
recentCityBean!!.recentCity,
value = "历史",
key = "0",
code = "0"
key = recentCityCode,
code = recentCityCode
)
)
subLocationItem?.let { locationList?.add(it) }
locationList?.let { RegionItem(it, value = "定位", key = "-1", code = "-1") }
locationList?.let { RegionItem(it, value = "定位", key = locationCode, code = locationCode) }
?.let { locationHistoryList?.add(0, it) }
locationHistoryList?.addAll(regionList)
......@@ -82,8 +86,25 @@ class AreaPopupWindow(
subList.addAll(regionList[0].sub)
}
subAdapter = SubRecyclerViewAdapter(context, subList, selectedSub)
subAdapter = SubRecyclerViewAdapter(context, subList, selectedSub, locationCode)
subAdapter.setOnAuthClickLister(object : SubRecyclerViewAdapter.OnAuthClickLister {
override fun onAuthClick() {
val dialog = CommonDialog(context)
.setTitle("温馨提示")
.setMessage("建议您授权定位权限,就能轻松获取周边优秀咨询师和其他服务")
.setLeftOnclick("暂不") { v1 ->
dismiss()
}.setRightClick("授权") { v12 ->
MMKV.defaultMMKV().encode(
ConsultBIConstants.ConsultantLocationAuth.WHETHER_LOCATION_AUTH,
true
)
getRegionByIp(true, true)
}
dialog.show()
}
})
view.rvRegion.layoutManager =
LinearLayoutManager(
context,
......@@ -111,7 +132,6 @@ class AreaPopupWindow(
false
)
subAdapter.onItemClickListener = MyBaseAdapter.OnItemClickListener { _, _, data ->
//倒序保留最近五次的搜索历史记录并去重
saveCitySearchRecord(data)
selectedSub = data
onRegionSelectedListener?.onRegionSelected(selectedRegion, selectedSub)
......@@ -120,6 +140,7 @@ class AreaPopupWindow(
view.rvSub.scrollToPosition(subList.indexOf(selectedSub) + 1)
}
//倒序保留最近五次的搜索历史记录并去重
private fun saveCitySearchRecord(data: SubItem) {
recentCityBean?.let {
if (it.recentCity.size < 5) {
......@@ -136,7 +157,8 @@ class AreaPopupWindow(
}
@SuppressLint("CheckResult")
fun getRegionByIp() {
fun getRegionByIp(agreeLocation: Boolean, refreshAdapter: Boolean) {
if (agreeLocation) {
SearchApi.getSearchApi().getCityByIp()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
......@@ -145,8 +167,19 @@ class AreaPopupWindow(
subLocationItem?.code = it.data.city_code
subLocationItem?.key = it.data.city_code
subLocationItem?.value = it.data.city_name
subLocationItem?.locationCode = locationCode
if (refreshAdapter) {
subAdapter.notifyDataSetChanged()
}
}
}, {})
} else {
subLocationItem?.code = null
subLocationItem?.key = null
subLocationItem?.value = "开启授权,获得定位城市"
subLocationItem?.locationCode = "NotAuth"
}
}
interface OnRegionSelectedListener {
......
package com.yidianling.consultant.ui.view
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.Drawable
import android.text.SpannableString
import android.text.Spanned
import android.text.style.AbsoluteSizeSpan
......@@ -14,13 +11,13 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.PopupWindow
import android.widget.TextView
import com.ydl.ydlcommon.utils.ResUtil.getResources
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxImageTool
import com.yidianling.consultant.R
import com.yidianling.consultant.listener.OnPriceItemSelectedListener
import com.yidianling.consultant.model.bean.AllFilter
import com.yidianling.consultant.model.bean.Filters
import com.yidianling.consultant.model.bean.PriceRangesItem
import com.yidianling.consultant.model.bean.ReorderItem
import com.yidianling.consultant.ui.view.rangeseekbar.OnRangeChangedListener
import com.yidianling.consultant.ui.view.rangeseekbar.RangeSeekBar
......@@ -35,7 +32,7 @@ class PricePopupWindow(
val context: Context, sortItems: ArrayList<ReorderItem>,
private val filterData: Filters,
private val tempFilter: AllFilter,
var selectedSort: ReorderItem, onPriceItemSelectedListener: OnPriceItemSelectedListener
var onPriceItemSelectedListener: OnPriceItemSelectedListener
) : PopupWindow(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) {
private val popWidth = (RxDeviceTool.getScreenWidth(context))
......@@ -58,6 +55,13 @@ class PricePopupWindow(
this.setBackgroundDrawable(BitmapDrawable())
this.isOutsideTouchable = true
initPriceTag()
contentView.price_Confirm.setOnClickListener {
// tempFilter.priceRanges?.min_price=min_Price
// tempFilter.priceRanges?.max_price=max_Price
var priceRangesItem = PriceRangesItem(min_Price, max_Price)
onPriceItemSelectedListener.onPriceItemSelected(priceRangesItem)
dismiss()
}
contentView.range_price_seekbar.setOnRangeChangedListener(object : OnRangeChangedListener {
override fun onRangeChanged(
view: RangeSeekBar?,
......
......@@ -350,7 +350,6 @@ public class RangeSeekBar extends View {
//平分显示
float x;
if (tickMarkMode == TRICK_MARK_MODE_OTHER) {
Log.e("aaaa", "tickMarkGravity" + tickMarkGravity);
if (tickMarkGravity == TICK_MARK_GRAVITY_RIGHT) {
x = getProgressLeft() + i * trickPartWidth - tickMarkTextRect.width();
} else if (tickMarkGravity == TICK_MARK_GRAVITY_CENTER) {
......
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="#1DA1F2"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z" />
</vector>
<?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="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -9,6 +9,13 @@
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
android:id="@+id/location_img"
android:layout_width="@dimen/platform_dp_15"
android:layout_height="@dimen/platform_dp_15"
android:src="@drawable/consultant_baseline_location_on_24"
android:visibility="gone" />
<TextView
android:id="@+id/tvConsultTypeName"
android:layout_width="0dp"
......@@ -18,12 +25,21 @@
android:textSize="14sp"
tools:text="咨询方式" />
<TextView
android:id="@+id/reLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="授权"
android:textColor="@color/platform_main_theme"
android:textSize="@dimen/platform_sp_14"
android:visibility="gone"></TextView>
<ImageView
android:id="@+id/ivCheckCircle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@null"
android:src="@drawable/consultant_ic_check"
android:visibility="invisible"/>
android:visibility="invisible" />
</LinearLayout>
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