Skip to content
Snippets Groups Projects
Verified Commit f992ec86 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Fixes #122 in a much cleaner and more reusable way

parent d0f6cfbc
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -417,10 +417,9 @@ class QuasselService : DaggerLifecycleService(),
disconnect: Boolean? = null,
markRead: BufferId? = null,
markReadMessage: MsgId? = null
): ComponentName = context.startService(intent(context,
disconnect,
markRead,
markReadMessage))
): ComponentName = context.startService(
intent(context, disconnect, markRead, markReadMessage)
)
fun intent(
context: Context,
......
......@@ -857,8 +857,8 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc
override fun onSelectAccount() {
if (!startedSelection) {
startActivityForResult(AccountSelectionActivity.intent(this), REQUEST_SELECT_ACCOUNT)
resetAccount()
startActivityForResult(AccountSelectionActivity.intent(this), REQUEST_SELECT_ACCOUNT)
}
}
......
......@@ -223,13 +223,7 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
})
var hasSetBufferViewConfigId = false
var hasRestoredSpinnerState = false
adapter.setOnUpdateFinishedListener {
if (!hasRestoredSpinnerState) {
savedInstanceState?.getParcelable<Parcelable>(KEY_STATE_SPINNER)
?.let(chatListSpinner::onRestoreInstanceState)
hasRestoredSpinnerState = true
}
if (!hasSetBufferViewConfigId) {
chatListSpinner.setSelection(adapter.indexOf(viewModel.bufferViewConfigId.value).nullIf { it == -1 }
?: 0)
......@@ -446,12 +440,11 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
savedInstanceState?.run {
chatList.layoutManager.onRestoreInstanceState(getParcelable(KEY_STATE_LIST))
chatListSpinner.onRestoreInstanceState(getParcelable(KEY_STATE_SPINNER))
}
viewModel.stateReset.toLiveData().observe(this, Observer {
listAdapter.submitList(emptyList())
hasSetBufferViewConfigId = false
hasRestoredSpinnerState = false
})
return view
......@@ -460,7 +453,6 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putParcelable(KEY_STATE_LIST, chatList.layoutManager.onSaveInstanceState())
outState.putParcelable(KEY_STATE_SPINNER, chatListSpinner.onSaveInstanceState())
}
private fun clickListener(it: BufferId) {
......@@ -483,6 +475,5 @@ class BufferViewConfigFragment : ServiceBoundFragment() {
companion object {
private const val KEY_STATE_LIST = "STATE_LIST"
private const val KEY_STATE_SPINNER = "STATE_SPINNER"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment