Improve animations

This commit is contained in:
andrew 2023-08-22 10:58:06 +09:30
parent 6818be21a1
commit 621c74c1d6
2 changed files with 6 additions and 5 deletions

View File

@ -5,14 +5,13 @@ import android.os.Parcelable
import android.util.SparseArray
import android.widget.Toast
import androidx.activity.viewModels
import androidx.core.content.ContextCompat
import androidx.core.text.HtmlCompat
import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.SimpleItemAnimator
import com.google.android.material.divider.MaterialDividerItemDecoration
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
@ -92,6 +91,7 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
viewModel.onExpirationTypeSelected(it)
}
binding.recyclerViewDeleteTypes.apply {
(itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
adapter = deleteTypeOptionAdapter
addDividers()
setHasFixedSize(true)
@ -102,6 +102,7 @@ class ExpirationSettingsActivity: PassphraseRequiredActionBarActivity() {
viewModel.onExpirationTimerSelected(it)
}
binding.recyclerViewTimerOptions.apply {
(itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false
adapter = timerOptionAdapter
addDividers()
}

View File

@ -35,14 +35,14 @@ class RadioOptionAdapter<T>(
isSelected = position == selectedOptionPosition
) {
onClickListener(it)
selectedOptionPosition = position
notifyItemRangeChanged(0, itemCount)
setSelectedPosition(position)
}
}
fun setSelectedPosition(selectedPosition: Int) {
notifyItemChanged(selectedOptionPosition)
selectedOptionPosition = selectedPosition
notifyDataSetChanged()
notifyItemChanged(selectedOptionPosition)
}
class ViewHolder<T>(itemView: View): RecyclerView.ViewHolder(itemView) {