Commit 92a44089 by huangzhicong

当清空网址跳转时,清空记录的地址

parent 9072aa05
...@@ -46,15 +46,22 @@ class StartFragment : Fragment() { ...@@ -46,15 +46,22 @@ class StartFragment : Fragment() {
} }
button.setOnClickListener { button.setOnClickListener {
val storageKey = stringPreferencesKey(STORAGE_URL)
val url = urlEditText.text.trim().toString() val url = urlEditText.text.trim().toString()
if (url.isEmpty()) { if (url.isEmpty()) {
runBlocking {
context?.dataStore?.edit {
if (it.contains(storageKey)) {
it.remove(storageKey)
}
}
}
findNavController().navigate( findNavController().navigate(
R.id.action_startFragment_to_mainFragment, R.id.action_startFragment_to_mainFragment,
MainFragment.createStartBundle() MainFragment.createStartBundle()
) )
return@setOnClickListener return@setOnClickListener
} }
val storageKey = stringPreferencesKey(STORAGE_URL)
runBlocking { runBlocking {
context?.dataStore?.edit { it[storageKey] = url } context?.dataStore?.edit { it[storageKey] = url }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment