[6.7.2]
[fix] [line add、delete or update]
This commit is contained in:
@@ -46,6 +46,13 @@ object LineDb: IDbRepository {
|
|||||||
// TODO: Ui展示需要动态刷新UI去
|
// TODO: Ui展示需要动态刷新UI去
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
val tempList = loadData.groupBy { it.lineId }.filter { it.value.size > 1 }
|
||||||
|
val needDelete = mutableListOf<LineDataBean>()
|
||||||
|
tempList.forEach {multData->
|
||||||
|
needDelete.add(multData.value.first())
|
||||||
|
}
|
||||||
|
// 删除本地重复的
|
||||||
|
lineDao.delete(*needDelete.toTypedArray())
|
||||||
// 后台新增数据
|
// 后台新增数据
|
||||||
val needAddDatas = serverDatalist-loadData
|
val needAddDatas = serverDatalist-loadData
|
||||||
// 后台没有本地数据库有的未分配线路
|
// 后台没有本地数据库有的未分配线路
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class SwitchLineView: WindowRelativeLayout, SwtichLineModel.SwtichLineViewCallba
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
aciv_refresh_task.onClick {
|
aciv_refresh_task.onClick(5_000) {
|
||||||
if(RepositoryManager.supportDb()) {
|
if(RepositoryManager.supportDb()) {
|
||||||
viewModel?.refreshTask()
|
viewModel?.refreshTask()
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ class SwtichLineModel : ViewModel(), IBusLinesCallback {
|
|||||||
|
|
||||||
override fun onNext(data: List<LineDataBean>) {
|
override fun onNext(data: List<LineDataBean>) {
|
||||||
d(LineModel.TAG, "queryBusLines onNext ${data}")
|
d(LineModel.TAG, "queryBusLines onNext ${data}")
|
||||||
viewCallback?.onBusLinesChange(data.toMutableList(),loading)
|
val tempData = data.distinctBy { it.lineId }
|
||||||
|
viewCallback?.onBusLinesChange(tempData.toMutableList(),loading)
|
||||||
if(RepositoryManager.supportDb()) {
|
if(RepositoryManager.supportDb()) {
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.mogo.och.common.module
|
package com.mogo.och.common.module
|
||||||
|
|
||||||
import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
import com.mogo.eagle.core.network.utils.digest.DigestUtils
|
||||||
|
import com.mogo.och.weaknet.repository.db.bean.LineDataBean
|
||||||
import com.mogo.och.weaknet.repository.db.bean.SiteDataBean
|
import com.mogo.och.weaknet.repository.db.bean.SiteDataBean
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
@@ -10,6 +11,29 @@ import org.junit.Test
|
|||||||
* See [testing documentation](http://d.android.com/tools/testing).
|
* See [testing documentation](http://d.android.com/tools/testing).
|
||||||
*/
|
*/
|
||||||
class ExampleUnitTest {
|
class ExampleUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun lineTest() {
|
||||||
|
|
||||||
|
|
||||||
|
val serverDataList = mutableListOf<LineDataBean>()
|
||||||
|
serverDataList.add(LineDataBean(lineId = 12))
|
||||||
|
serverDataList.add(LineDataBean(lineId = 12))
|
||||||
|
serverDataList.add(LineDataBean(lineId = 13))
|
||||||
|
serverDataList.add(LineDataBean(lineId = 13))
|
||||||
|
|
||||||
|
val tempData = serverDataList.distinctBy { it.lineId }
|
||||||
|
println(serverDataList)
|
||||||
|
println(tempData)
|
||||||
|
|
||||||
|
val loaclDataList = mutableListOf<LineDataBean>()
|
||||||
|
loaclDataList.add(LineDataBean(lineId = 12))
|
||||||
|
loaclDataList.add(LineDataBean(lineId = 12))
|
||||||
|
loaclDataList.add(LineDataBean(lineId = 13))
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun addition_isCorrect() {
|
fun addition_isCorrect() {
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.mogo.eagle.core.utilcode.util.ClickUtils
|
import com.mogo.eagle.core.utilcode.util.ClickUtils
|
||||||
import com.mogo.eagle.core.utilcode.util.R
|
import com.mogo.eagle.core.utilcode.util.R
|
||||||
|
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||||
import com.mogo.eagle.core.utilcode.util.Utils
|
import com.mogo.eagle.core.utilcode.util.Utils
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.Channel
|
import kotlinx.coroutines.channels.Channel
|
||||||
@@ -109,6 +110,17 @@ fun View.onClick(block: (View) -> Unit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun View.onClick(during:Int,block: (View) -> Unit) {
|
||||||
|
this.setOnClickListener {
|
||||||
|
if (ClickUtils.isClickTooFrequent(this,during)) {
|
||||||
|
ToastUtils.showShort("不要频繁点击哦~")
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
block(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun View.onClickWidthDuration(duration: Int, block: (View) -> Unit) {
|
fun View.onClickWidthDuration(duration: Int, block: (View) -> Unit) {
|
||||||
this.setOnClickListener {
|
this.setOnClickListener {
|
||||||
if (ClickUtils.isClickTooFrequent(this, duration)) {
|
if (ClickUtils.isClickTooFrequent(this, duration)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user