Commit a6d4fc8c by 霍志良

feat:排序筛选UI、价格筛选器

parent b059f7bb
...@@ -22,6 +22,8 @@ import com.yidianling.consultant.listener.OnSortItemSelectedListener ...@@ -22,6 +22,8 @@ import com.yidianling.consultant.listener.OnSortItemSelectedListener
import com.yidianling.consultant.model.bean.AllFilter import com.yidianling.consultant.model.bean.AllFilter
import com.yidianling.consultant.model.bean.Filters import com.yidianling.consultant.model.bean.Filters
import com.yidianling.consultant.model.bean.ReorderItem import com.yidianling.consultant.model.bean.ReorderItem
import com.yidianling.consultant.ui.view.rangeseekbar.OnRangeChangedListener
import com.yidianling.consultant.ui.view.rangeseekbar.RangeSeekBar
import kotlinx.android.synthetic.main.consultant_item_price_range.view.* import kotlinx.android.synthetic.main.consultant_item_price_range.view.*
import kotlinx.android.synthetic.main.consultant_ui_filter_popup.view.* import kotlinx.android.synthetic.main.consultant_ui_filter_popup.view.*
import kotlinx.android.synthetic.main.consultant_ui_filter_popup.view.flPriceRange import kotlinx.android.synthetic.main.consultant_ui_filter_popup.view.flPriceRange
...@@ -46,7 +48,7 @@ class PricePopupWindow( ...@@ -46,7 +48,7 @@ class PricePopupWindow(
private var max_Price = "" private var max_Price = ""
private var SeekBarLeftValue = 0f private var SeekBarLeftValue = 0f
private var SeekBarRightValue = 0f private var SeekBarRightValue = 0f
private val maxPriceValue = 600
init { init {
val view = val view =
LayoutInflater.from(context).inflate(R.layout.consultant_ui_price_popup_window, null) LayoutInflater.from(context).inflate(R.layout.consultant_ui_price_popup_window, null)
...@@ -56,6 +58,29 @@ class PricePopupWindow( ...@@ -56,6 +58,29 @@ class PricePopupWindow(
this.setBackgroundDrawable(BitmapDrawable()) this.setBackgroundDrawable(BitmapDrawable())
this.isOutsideTouchable = true this.isOutsideTouchable = true
initPriceTag() initPriceTag()
contentView.range_price_seekbar.setOnRangeChangedListener(object : OnRangeChangedListener {
override fun onRangeChanged(
view: RangeSeekBar?,
leftValue: Float,
rightValue: Float,
isFromUser: Boolean
) {
var maxPrice = ((rightValue / 100) * maxPriceValue).toInt().toString()
if (rightValue > 93) {
maxPrice = "无限"
}
contentView.tv_start_end_price.text =
((leftValue / 100) * maxPriceValue).toInt().toString() + "-" + maxPrice
}
override fun onStartTrackingTouch(view: RangeSeekBar?, isLeft: Boolean) {
}
override fun onStopTrackingTouch(view: RangeSeekBar?, isLeft: Boolean) {
}
})
} }
fun initPriceTag() { fun initPriceTag() {
...@@ -121,7 +146,7 @@ class PricePopupWindow( ...@@ -121,7 +146,7 @@ class PricePopupWindow(
} else { } else {
min_Price = priceRangesItem.min_price.toString() min_Price = priceRangesItem.min_price.toString()
SeekBarLeftValue = SeekBarLeftValue =
(priceRangesItem.min_price.toString().toFloat() / 600) * 100f (priceRangesItem.min_price.toString().toFloat() / maxPriceValue) * 100f
} }
if (priceRangesItem.max_price.isNullOrEmpty()) { if (priceRangesItem.max_price.isNullOrEmpty()) {
max_Price = "无限" max_Price = "无限"
...@@ -129,17 +154,13 @@ class PricePopupWindow( ...@@ -129,17 +154,13 @@ class PricePopupWindow(
} else { } else {
max_Price = priceRangesItem.max_price.toString() max_Price = priceRangesItem.max_price.toString()
SeekBarRightValue = SeekBarRightValue =
(priceRangesItem.max_price.toString().toFloat() / 600) * 100f (priceRangesItem.max_price.toString().toFloat() / maxPriceValue) * 100f
} }
contentView.tv_start_end_price.text = "$min_Price-$max_Price"
contentView.range_price_seekbar.setProgress(SeekBarLeftValue, SeekBarRightValue) contentView.range_price_seekbar.setProgress(SeekBarLeftValue, SeekBarRightValue)
// etMinPrice?.setText(priceRangesItem.min_price) contentView.tv_start_end_price.text = "$min_Price-$max_Price"
// etMaxPrice?.setText(priceRangesItem.max_price)
// etMinPrice?.setSelection(etMinPrice?.text!!.length)
// etMaxPrice?.setSelection(etMaxPrice?.text!!.length)
} }
// updateCount(ConsultBIConstants.POSITION_AVERAGE_SERVICE_INPUT)
} }
contentView.flPriceRangeView.addView(textView) contentView.flPriceRangeView.addView(textView)
} }
......
...@@ -444,7 +444,7 @@ public class RangeSeekBar extends View { ...@@ -444,7 +444,7 @@ public class RangeSeekBar extends View {
//绘制刻度。其他场景要用,需要自己修改这部分代码 //绘制刻度。其他场景要用,需要自己修改这部分代码
for (int k = 1; k <= steps - 1; k++) { for (int k = 1; k <= steps - 1; k++) {
//如果是奇数Setp,则不绘制刻度 //如果是奇数Setp,则不绘制刻度
if (k % 2 == 1) continue; // if (k % 2 == 1) continue;
float x = getProgressLeft() + k * stepMarks - stepsWidth / 2f; float x = getProgressLeft() + k * stepMarks - stepsWidth / 2f;
stepDivRect.set(x, getProgressTop() + stepsHeight, x + stepsWidth, getProgressBottom() + 3 * stepsHeight); stepDivRect.set(x, getProgressTop() + stepsHeight, x + stepsWidth, getProgressBottom() + 3 * stepsHeight);
if (stepsBitmaps.isEmpty() || stepsBitmaps.size() <= k) { if (stepsBitmaps.isEmpty() || stepsBitmaps.size() <= k) {
...@@ -651,7 +651,8 @@ public class RangeSeekBar extends View { ...@@ -651,7 +651,8 @@ public class RangeSeekBar extends View {
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
if (verifyStepsMode() && stepsAutoBonding) { if (verifyStepsMode() && stepsAutoBonding) {
float percent = calculateCurrentSeekBarPercent(getEventX(event)); float percent = calculateCurrentSeekBarPercent(getEventX(event));
float stepPercent = 1.0f / steps; //步长step 自动滑动到step的一半
float stepPercent = 1.0f / (steps * 2);
int stepSelected = new BigDecimal(percent / stepPercent).setScale(0, RoundingMode.HALF_UP).intValue(); int stepSelected = new BigDecimal(percent / stepPercent).setScale(0, RoundingMode.HALF_UP).intValue();
currTouchSB.slide(stepSelected * stepPercent); currTouchSB.slide(stepSelected * stepPercent);
} }
......
...@@ -4,17 +4,17 @@ ...@@ -4,17 +4,17 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@color/white" android:background="@color/white"
android:paddingStart="@dimen/platform_dp_12" android:paddingTop="@dimen/platform_dp_15">
android:paddingTop="@dimen/platform_dp_15"
android:paddingEnd="@dimen/platform_dp_12">
<TextView <FrameLayout
android:id="@+id/tv_price" android:id="@+id/flPriceRangeView"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="价格" android:layout_marginTop="12dp"
android:textColor="@color/platform_color_black_333333" android:layout_marginBottom="50dp"
android:textStyle="bold" android:paddingStart="@dimen/platform_dp_12"
android:paddingEnd="@dimen/platform_dp_12"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
...@@ -23,26 +23,31 @@ ...@@ -23,26 +23,31 @@
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="200-500"
app:layout_constraintBottom_toBottomOf="@id/tv_price"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_price" /> android:layout_marginTop="@dimen/platform_dp_30"
android:textColor="@color/platform_color_black_333333"
android:textSize="@dimen/platform_sp_14"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/flPriceRangeView" />
<com.yidianling.consultant.ui.view.rangeseekbar.RangeSeekBar <com.yidianling.consultant.ui.view.rangeseekbar.RangeSeekBar
android:id="@+id/range_price_seekbar" android:id="@+id/range_price_seekbar"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="@dimen/platform_dp_12"
android:layout_marginEnd="@dimen/platform_dp_12"
android:layout_marginTop="@dimen/platform_dp_15" android:layout_marginTop="@dimen/platform_dp_15"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_price" app:layout_constraintTop_toBottomOf="@id/tv_start_end_price"
app:rsb_gravity="bottom" app:rsb_gravity="bottom"
app:rsb_mode="range" app:rsb_mode="range"
app:rsb_progress_color="@color/platform_main_theme" app:rsb_progress_color="@color/platform_main_theme"
app:rsb_step_auto_bonding="true" app:rsb_step_auto_bonding="true"
app:rsb_step_color="@color/platform_gray7" app:rsb_step_color="@color/platform_gray7"
app:rsb_step_height="5dp" app:rsb_step_height="5dp"
app:rsb_step_width="1dp" app:rsb_step_width="0.5dp"
app:rsb_steps="12" app:rsb_steps="6"
app:rsb_thumb_drawable="@drawable/thumb_yellow_stroke" app:rsb_thumb_drawable="@drawable/thumb_yellow_stroke"
app:rsb_thumb_height="15dp" app:rsb_thumb_height="15dp"
app:rsb_thumb_width="15dp" app:rsb_thumb_width="15dp"
...@@ -51,14 +56,48 @@ ...@@ -51,14 +56,48 @@
app:rsb_tick_mark_text_array="@array/wordsArray" app:rsb_tick_mark_text_array="@array/wordsArray"
app:rsb_tick_mark_text_margin="20dp" /> app:rsb_tick_mark_text_margin="20dp" />
<FrameLayout <View
android:id="@+id/flPriceRangeView" android:id="@+id/seperate_line"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="0.5dp"
android:layout_marginTop="12dp" android:layout_marginTop="@dimen/platform_dp_30"
android:layout_marginBottom="50dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/range_price_seekbar" /> app:layout_constraintTop_toBottomOf="@id/range_price_seekbar"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:layout_marginTop="@dimen/platform_dp_8"
android:background="@color/white"
android:orientation="horizontal"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
app:layout_constraintTop_toBottomOf="@id/seperate_line">
<TextView
android:id="@+id/price_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/price_Confirm"
android:layout_width="0dp"
android:layout_height="44dp"
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:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
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