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