Prevent Chats icon from animating when returning from other activity.

This commit is contained in:
Nicholas
2022-09-22 09:04:58 -04:00
committed by Cody Henthorne
parent 0bf5f15cf9
commit cf3dd70600
2 changed files with 7 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ class ConversationListTabsFragment : Fragment(R.layout.conversation_list_tabs) {
private lateinit var chatsPill: ImageView
private lateinit var storiesPill: ImageView
private var shouldBeImmediate = true
private var pillAnimator: Animator? = null
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@@ -63,9 +64,10 @@ class ConversationListTabsFragment : Fragment(R.layout.conversation_list_tabs) {
viewModel.onStoriesSelected()
}
update(viewModel.stateSnapshot, true)
viewModel.state.observe(viewLifecycleOwner) { update(it, false) }
viewModel.state.observe(viewLifecycleOwner) {
update(it, shouldBeImmediate)
shouldBeImmediate = false
}
}
private fun update(state: ConversationListTabsState, immediate: Boolean) {

View File

@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.stories.tabs
import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import io.reactivex.rxjava3.core.Observable
@@ -15,7 +16,7 @@ class ConversationListTabsViewModel(repository: ConversationListTabRepository) :
private val store = Store(ConversationListTabsState())
val stateSnapshot: ConversationListTabsState = store.state
val state: LiveData<ConversationListTabsState> = store.stateLiveData
val state: LiveData<ConversationListTabsState> = Transformations.distinctUntilChanged(store.stateLiveData)
val disposables = CompositeDisposable()
private val internalTabClickEvents: Subject<ConversationListTab> = PublishSubject.create()