[m1]
[recycleview 滚动问题]
This commit is contained in:
@@ -55,6 +55,7 @@ class M1SoftFragment :
|
||||
|
||||
private var currentTemperature: Temperature? = null
|
||||
|
||||
private var subscribeAir: Disposable? = null
|
||||
private var subscribeLightTop1: Disposable? = null
|
||||
private var subscribeLightTop2: Disposable? = null
|
||||
private var subscribeAtmosphere: Disposable? = null
|
||||
@@ -239,26 +240,26 @@ class M1SoftFragment :
|
||||
rv_aircondition_temperature.layoutManager = pickerLayoutManager
|
||||
rv_aircondition_temperature.adapter = adapter
|
||||
HorizontalDecoration.distance = SharedPrefsMgr.getInstance(requireContext()).getInt(HorizontalDecoration.distancekey,0)
|
||||
rv_aircondition_temperature.addItemDecoration(HorizontalDecoration(15,data.size-1))
|
||||
rv_aircondition_temperature.addItemDecoration(HorizontalDecoration(20,data.size-1))
|
||||
|
||||
pickerLayoutManager.setOnScrollStopListener { view ->
|
||||
if (view is TextView) {
|
||||
// 未拖到中点、自动滚动到中点会短时间触发两次
|
||||
if (ClickUtils.isClickTooFrequent(rv_aircondition_temperature)) {
|
||||
return@setOnScrollStopListener
|
||||
}
|
||||
val tag = view.tag
|
||||
if (tag is Temperature) {
|
||||
adapter.setCheckIndex(tag.index)
|
||||
currentTemperature = tag
|
||||
if(rv_aircondition_temperature.tag== touchTag){
|
||||
rv_aircondition_temperature.tag = null
|
||||
return@setOnScrollStopListener
|
||||
mPresenter?.disposeSubscribe(subscribeAir)
|
||||
if(tag.index==0||tag.index==adapter.data.size-1){
|
||||
subscribeAir = Observable.timer(200, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
setCheckAir(adapter,tag)
|
||||
}
|
||||
}else {
|
||||
SoundPoolHelper.getSoundPoolHelper()
|
||||
.playSoundWithRedId(context, R.raw.bus_di)
|
||||
if (ClickUtils.isClickTooFrequent(rv_aircondition_temperature)) {
|
||||
return@setOnScrollStopListener
|
||||
}
|
||||
setCheckAir(adapter,tag)
|
||||
}
|
||||
openAircondition()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -269,6 +270,19 @@ class M1SoftFragment :
|
||||
}
|
||||
}
|
||||
|
||||
private fun setCheckAir(adapter:TemperatureAdapter,tag:Temperature){
|
||||
adapter.setCheckIndex(tag.index)
|
||||
currentTemperature = tag
|
||||
if (rv_aircondition_temperature.tag == touchTag) {
|
||||
rv_aircondition_temperature.tag = null
|
||||
return
|
||||
} else {
|
||||
SoundPoolHelper.getSoundPoolHelper()
|
||||
.playSoundWithRedId(context, R.raw.bus_di)
|
||||
}
|
||||
openAircondition()
|
||||
}
|
||||
|
||||
private fun getData(): MutableList<Temperature> {
|
||||
val mutableListOf = mutableListOf<Temperature>()
|
||||
mutableListOf.add(Temperature(0, 16, "16°"))
|
||||
|
||||
Reference in New Issue
Block a user