@ -95,7 +95,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
R . id . menu _help -> showHelp ( )
else -> if ( item . groupId == R . id . source _group ) {
binding . titleBar . findViewById < SearchView > ( R . id . search _view )
. setQuery ( item . title , true )
. setQuery ( " group: ${item.title} " , true )
}
}
return super . onCompatOptionsItemSelected ( item )
@ -197,13 +197,20 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
}
}
private fun initLiveDataSource ( k ey: String ? = null ) {
private fun initLiveDataSource ( searchK ey: String ? = null ) {
sourceLiveData ?. removeObservers ( this )
sourceLiveData =
if ( key . isNullOrBlank ( ) ) {
App . db . rssSourceDao . liveAll ( )
} else {
App . db . rssSourceDao . liveSearch ( " % $key % " )
when {
searchKey . isNullOrBlank ( ) -> {
App . db . rssSourceDao . liveAll ( )
}
searchKey . startsWith ( " group: " ) -> {
val key = searchKey . substringAfter ( " group: " )
App . db . rssSourceDao . liveGroupSearch ( " % $key % " )
}
else -> {
App . db . rssSourceDao . liveSearch ( " % $searchKey % " )
}
}
sourceLiveData ?. observe ( this , {
adapter . setItems ( it , adapter . diffItemCallback )