|
|
@ -1,5 +1,6 @@ |
|
|
|
package io.legado.app.ui.book.search |
|
|
|
package io.legado.app.ui.book.search |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.lifecycle.MutableLiveData |
|
|
|
import io.legado.app.data.appDb |
|
|
|
import io.legado.app.data.appDb |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.data.entities.BookSource |
|
|
|
import io.legado.app.help.config.AppConfig |
|
|
|
import io.legado.app.help.config.AppConfig |
|
|
@ -13,12 +14,18 @@ data class SearchScope(private var scope: String) { |
|
|
|
|
|
|
|
|
|
|
|
constructor(groups: List<String>) : this(groups.joinToString(",")) |
|
|
|
constructor(groups: List<String>) : this(groups.joinToString(",")) |
|
|
|
|
|
|
|
|
|
|
|
constructor(source: BookSource) : this("${source.bookSourceName}::${source.bookSourceUrl}") |
|
|
|
constructor(source: BookSource) : this( |
|
|
|
|
|
|
|
"${ |
|
|
|
|
|
|
|
source.bookSourceName.replace("::", "") |
|
|
|
|
|
|
|
}::${source.bookSourceUrl}" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
override fun toString(): String { |
|
|
|
override fun toString(): String { |
|
|
|
return scope |
|
|
|
return scope |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val stateLiveData = MutableLiveData("") |
|
|
|
|
|
|
|
|
|
|
|
fun update(scope: String) { |
|
|
|
fun update(scope: String) { |
|
|
|
this.scope = scope |
|
|
|
this.scope = scope |
|
|
|
} |
|
|
|
} |
|
|
@ -70,12 +77,20 @@ data class SearchScope(private var scope: String) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
scope.splitNotBlank(",").forEach { |
|
|
|
val oldScope = scope.splitNotBlank(",") |
|
|
|
list.addAll(appDb.bookSourceDao.getEnabledByGroup(it)) |
|
|
|
val newScope = oldScope.filter { |
|
|
|
|
|
|
|
val bookSources = appDb.bookSourceDao.getEnabledByGroup(it) |
|
|
|
|
|
|
|
list.addAll(bookSources) |
|
|
|
|
|
|
|
bookSources.isNotEmpty() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (oldScope.size != newScope.size) { |
|
|
|
|
|
|
|
update(newScope) |
|
|
|
|
|
|
|
stateLiveData.postValue("") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (list.isEmpty()) { |
|
|
|
if (list.isEmpty()) { |
|
|
|
scope = "" |
|
|
|
scope = "" |
|
|
|
|
|
|
|
stateLiveData.postValue("") |
|
|
|
return appDb.bookSourceDao.allEnabled |
|
|
|
return appDb.bookSourceDao.allEnabled |
|
|
|
} |
|
|
|
} |
|
|
|
return list.sortedBy { it.customOrder } |
|
|
|
return list.sortedBy { it.customOrder } |
|
|
|