|
|
|
@ -50,6 +50,9 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView |
|
|
|
|
override val viewModel by viewModels<RssSourceViewModel>() |
|
|
|
|
private val importRecordKey = "rssSourceRecordKey" |
|
|
|
|
private val adapter by lazy { RssSourceAdapter(this, this) } |
|
|
|
|
private val searchView: SearchView by lazy { |
|
|
|
|
binding.titleBar.findViewById(R.id.search_view) |
|
|
|
|
} |
|
|
|
|
private var sourceFlowJob: Job? = null |
|
|
|
|
private var groups = hashSetOf<String>() |
|
|
|
|
private var groupMenu: SubMenu? = null |
|
|
|
@ -120,10 +123,21 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView |
|
|
|
|
R.id.menu_import_qr -> qrCodeResult.launch() |
|
|
|
|
R.id.menu_group_manage -> showDialogFragment<GroupManageDialog>() |
|
|
|
|
R.id.menu_import_default -> viewModel.importDefault() |
|
|
|
|
R.id.menu_enabled_group -> { |
|
|
|
|
searchView.setQuery(getString(R.string.enabled), true) |
|
|
|
|
} |
|
|
|
|
R.id.menu_disabled_group -> { |
|
|
|
|
searchView.setQuery(getString(R.string.disabled), true) |
|
|
|
|
} |
|
|
|
|
R.id.menu_group_login -> { |
|
|
|
|
searchView.setQuery(getString(R.string.need_login), true) |
|
|
|
|
} |
|
|
|
|
R.id.menu_group_null -> { |
|
|
|
|
searchView.setQuery(getString(R.string.no_group), true) |
|
|
|
|
} |
|
|
|
|
R.id.menu_help -> showHelp() |
|
|
|
|
else -> if (item.groupId == R.id.source_group) { |
|
|
|
|
binding.titleBar.findViewById<SearchView>(R.id.search_view) |
|
|
|
|
.setQuery("group:${item.title}", true) |
|
|
|
|
searchView.setQuery("group:${item.title}", true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return super.onCompatOptionsItemSelected(item) |
|
|
|
@ -144,6 +158,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView |
|
|
|
|
R.id.menu_share_source -> viewModel.saveToFile(adapter.selection) { |
|
|
|
|
share(it) |
|
|
|
|
} |
|
|
|
|
R.id.menu_check_selected_interval -> adapter.checkSelectedInterval() |
|
|
|
|
} |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
@ -240,6 +255,18 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView |
|
|
|
|
searchKey.isNullOrBlank() -> { |
|
|
|
|
appDb.rssSourceDao.flowAll() |
|
|
|
|
} |
|
|
|
|
searchKey == getString(R.string.enabled) -> { |
|
|
|
|
appDb.rssSourceDao.flowEnabled() |
|
|
|
|
} |
|
|
|
|
searchKey == getString(R.string.disabled) -> { |
|
|
|
|
appDb.rssSourceDao.flowDisabled() |
|
|
|
|
} |
|
|
|
|
searchKey == getString(R.string.need_login) -> { |
|
|
|
|
appDb.rssSourceDao.flowLogin() |
|
|
|
|
} |
|
|
|
|
searchKey == getString(R.string.no_group) -> { |
|
|
|
|
appDb.rssSourceDao.flowNoGroup() |
|
|
|
|
} |
|
|
|
|
searchKey.startsWith("group:") -> { |
|
|
|
|
val key = searchKey.substringAfter("group:") |
|
|
|
|
appDb.rssSourceDao.flowGroupSearch(key) |
|
|
|
|