mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
parent
ecdc955f81
commit
ab7fd929d3
@ -276,46 +276,43 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
|||||||
appDb.bookSourceDao.flowSearch(searchKey)
|
appDb.bookSourceDao.flowSearch(searchKey)
|
||||||
}
|
}
|
||||||
}.conflate().map { data ->
|
}.conflate().map { data ->
|
||||||
if (sortAscending) {
|
if (sortAscending) when (sort) {
|
||||||
when (sort) {
|
Sort.Weight -> data.sortedBy { it.weight }
|
||||||
Sort.Weight -> data.sortedBy { it.weight }
|
Sort.Name -> data.sortedWith { o1, o2 ->
|
||||||
Sort.Name -> data.sortedWith { o1, o2 ->
|
o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||||
o1.bookSourceName.cnCompare(o2.bookSourceName)
|
|
||||||
}
|
|
||||||
|
|
||||||
Sort.Url -> data.sortedBy { it.bookSourceUrl }
|
|
||||||
Sort.Update -> data.sortedByDescending { it.lastUpdateTime }
|
|
||||||
Sort.Respond -> data.sortedBy { it.respondTime }
|
|
||||||
Sort.Enable -> data.sortedWith { o1, o2 ->
|
|
||||||
var sort = -o1.enabled.compareTo(o2.enabled)
|
|
||||||
if (sort == 0) {
|
|
||||||
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
|
||||||
}
|
|
||||||
sort
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> data
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
when (sort) {
|
|
||||||
Sort.Weight -> data.sortedByDescending { it.weight }
|
|
||||||
Sort.Name -> data.sortedWith { o1, o2 ->
|
|
||||||
o2.bookSourceName.cnCompare(o1.bookSourceName)
|
|
||||||
}
|
|
||||||
|
|
||||||
Sort.Url -> data.sortedByDescending { it.bookSourceUrl }
|
Sort.Url -> data.sortedBy { it.bookSourceUrl }
|
||||||
Sort.Update -> data.sortedBy { it.lastUpdateTime }
|
Sort.Update -> data.sortedByDescending { it.lastUpdateTime }
|
||||||
Sort.Respond -> data.sortedByDescending { it.respondTime }
|
Sort.Respond -> data.sortedBy { it.respondTime }
|
||||||
Sort.Enable -> data.sortedWith { o1, o2 ->
|
Sort.Enable -> data.sortedWith { o1, o2 ->
|
||||||
var sort = o1.enabled.compareTo(o2.enabled)
|
var sort = -o1.enabled.compareTo(o2.enabled)
|
||||||
if (sort == 0) {
|
if (sort == 0) {
|
||||||
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||||
}
|
|
||||||
sort
|
|
||||||
}
|
}
|
||||||
|
sort
|
||||||
else -> data.reversed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else -> data
|
||||||
|
}
|
||||||
|
else when (sort) {
|
||||||
|
Sort.Weight -> data.sortedByDescending { it.weight }
|
||||||
|
Sort.Name -> data.sortedWith { o1, o2 ->
|
||||||
|
o2.bookSourceName.cnCompare(o1.bookSourceName)
|
||||||
|
}
|
||||||
|
|
||||||
|
Sort.Url -> data.sortedByDescending { it.bookSourceUrl }
|
||||||
|
Sort.Update -> data.sortedBy { it.lastUpdateTime }
|
||||||
|
Sort.Respond -> data.sortedByDescending { it.respondTime }
|
||||||
|
Sort.Enable -> data.sortedWith { o1, o2 ->
|
||||||
|
var sort = o1.enabled.compareTo(o2.enabled)
|
||||||
|
if (sort == 0) {
|
||||||
|
sort = o1.bookSourceName.cnCompare(o2.bookSourceName)
|
||||||
|
}
|
||||||
|
sort
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> data.reversed()
|
||||||
}
|
}
|
||||||
}.catch {
|
}.catch {
|
||||||
AppLog.put("书源界面更新书源出错", it)
|
AppLog.put("书源界面更新书源出错", it)
|
||||||
@ -656,19 +653,11 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toTop(bookSource: BookSourcePart) {
|
override fun toTop(bookSource: BookSourcePart) {
|
||||||
if (sortAscending) {
|
viewModel.topSource(bookSource)
|
||||||
viewModel.topSource(bookSource)
|
|
||||||
} else {
|
|
||||||
viewModel.bottomSource(bookSource)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun toBottom(bookSource: BookSourcePart) {
|
override fun toBottom(bookSource: BookSourcePart) {
|
||||||
if (sortAscending) {
|
viewModel.bottomSource(bookSource)
|
||||||
viewModel.bottomSource(bookSource)
|
|
||||||
} else {
|
|
||||||
viewModel.topSource(bookSource)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun searchBook(bookSource: BookSourcePart) {
|
override fun searchBook(bookSource: BookSourcePart) {
|
||||||
|
@ -39,6 +39,11 @@ object RhinoClassShutter : ClassShutter {
|
|||||||
private val protectedClasses by lazy {
|
private val protectedClasses by lazy {
|
||||||
hashSetOf(
|
hashSetOf(
|
||||||
"dalvik.system",
|
"dalvik.system",
|
||||||
|
"java.lang.Class",
|
||||||
|
"java.lang.ClassLoader",
|
||||||
|
"java.net.URLClassLoader",
|
||||||
|
"cn.hutool.core.lang.JarClassLoader",
|
||||||
|
"org.mozilla.javascript.DefiningClassLoader",
|
||||||
"java.lang.Runtime",
|
"java.lang.Runtime",
|
||||||
"java.io.File",
|
"java.io.File",
|
||||||
"java.security.AccessController",
|
"java.security.AccessController",
|
||||||
|
Loading…
Reference in New Issue
Block a user