|
|
@ -13,21 +13,23 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) |
|
|
|
|
|
|
|
|
|
|
|
fun topSource(vararg sources: RssSource) { |
|
|
|
fun topSource(vararg sources: RssSource) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
|
|
|
|
sources.sortBy { it.customOrder } |
|
|
|
val minOrder = appDb.rssSourceDao.minOrder - 1 |
|
|
|
val minOrder = appDb.rssSourceDao.minOrder - 1 |
|
|
|
sources.forEachIndexed { index, rssSource -> |
|
|
|
val array = Array(sources.size) { |
|
|
|
rssSource.customOrder = minOrder - index |
|
|
|
sources[it].copy(customOrder = minOrder - it) |
|
|
|
} |
|
|
|
} |
|
|
|
appDb.rssSourceDao.update(*sources) |
|
|
|
appDb.rssSourceDao.update(*array) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun bottomSource(vararg sources: RssSource) { |
|
|
|
fun bottomSource(vararg sources: RssSource) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
|
|
|
|
sources.sortBy { it.customOrder } |
|
|
|
val maxOrder = appDb.rssSourceDao.maxOrder + 1 |
|
|
|
val maxOrder = appDb.rssSourceDao.maxOrder + 1 |
|
|
|
sources.forEachIndexed { index, rssSource -> |
|
|
|
val array = Array(sources.size) { |
|
|
|
rssSource.customOrder = maxOrder + index |
|
|
|
sources[it].copy(customOrder = maxOrder + it) |
|
|
|
} |
|
|
|
} |
|
|
|
appDb.rssSourceDao.update(*sources) |
|
|
|
appDb.rssSourceDao.update(*array) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -51,21 +53,19 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application) |
|
|
|
|
|
|
|
|
|
|
|
fun enableSelection(sources: List<RssSource>) { |
|
|
|
fun enableSelection(sources: List<RssSource>) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val list = arrayListOf<RssSource>() |
|
|
|
val array = Array(sources.size) { |
|
|
|
sources.forEach { |
|
|
|
sources[it].copy(enabled = true) |
|
|
|
list.add(it.copy(enabled = true)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
appDb.rssSourceDao.update(*list.toTypedArray()) |
|
|
|
appDb.rssSourceDao.update(*array) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun disableSelection(sources: List<RssSource>) { |
|
|
|
fun disableSelection(sources: List<RssSource>) { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val list = arrayListOf<RssSource>() |
|
|
|
val array = Array(sources.size) { |
|
|
|
sources.forEach { |
|
|
|
sources[it].copy(enabled = false) |
|
|
|
list.add(it.copy(enabled = false)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
appDb.rssSourceDao.update(*list.toTypedArray()) |
|
|
|
appDb.rssSourceDao.update(*array) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|