|
|
@ -100,30 +100,32 @@ data class SearchScope(private var scope: String) { |
|
|
|
val list = hashSetOf<BookSource>() |
|
|
|
val list = hashSetOf<BookSource>() |
|
|
|
if (scope.isEmpty()) { |
|
|
|
if (scope.isEmpty()) { |
|
|
|
list.addAll(appDb.bookSourceDao.allEnabled) |
|
|
|
list.addAll(appDb.bookSourceDao.allEnabled) |
|
|
|
} else if (scope.contains("::")) { |
|
|
|
|
|
|
|
scope.substringAfter("::").let { |
|
|
|
|
|
|
|
appDb.bookSourceDao.getBookSource(it)?.let { source -> |
|
|
|
|
|
|
|
list.add(source) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
val oldScope = scope.splitNotBlank(",") |
|
|
|
if (scope.contains("::")) { |
|
|
|
val newScope = oldScope.filter { |
|
|
|
scope.substringAfter("::").let { |
|
|
|
val bookSources = appDb.bookSourceDao.getEnabledByGroup(it) |
|
|
|
appDb.bookSourceDao.getBookSource(it)?.let { source -> |
|
|
|
list.addAll(bookSources) |
|
|
|
list.add(source) |
|
|
|
bookSources.isNotEmpty() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (oldScope.size != newScope.size) { |
|
|
|
} else { |
|
|
|
update(newScope) |
|
|
|
val oldScope = scope.splitNotBlank(",") |
|
|
|
stateLiveData.postValue(scope) |
|
|
|
val newScope = oldScope.filter { |
|
|
|
} |
|
|
|
val bookSources = appDb.bookSourceDao.getEnabledByGroup(it) |
|
|
|
} |
|
|
|
list.addAll(bookSources) |
|
|
|
if (list.isEmpty()) { |
|
|
|
bookSources.isNotEmpty() |
|
|
|
scope = "" |
|
|
|
} |
|
|
|
appDb.bookSourceDao.allEnabled.let { |
|
|
|
if (oldScope.size != newScope.size) { |
|
|
|
if (it.isNotEmpty()) { |
|
|
|
update(newScope) |
|
|
|
stateLiveData.postValue(scope) |
|
|
|
stateLiveData.postValue(scope) |
|
|
|
list.addAll(it) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (list.isEmpty()) { |
|
|
|
|
|
|
|
scope = "" |
|
|
|
|
|
|
|
appDb.bookSourceDao.allEnabled.let { |
|
|
|
|
|
|
|
if (it.isNotEmpty()) { |
|
|
|
|
|
|
|
stateLiveData.postValue(scope) |
|
|
|
|
|
|
|
list.addAll(it) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|