RecyclerView разворачивается слишком быстро - PullRequest
1 голос
/ 18 июня 2019

My RecyclerView содержит элементы различных типов. Один из типов имеет заголовок TextView и RecyclerView для отображения списка. Щелчок по заголовку заполняет / не заполняет RecyclerView, расширяя / разворачивая его.

Мне кажется, я заметил анимацию разворачивания / разворачивания, но она очень быстрая. Вопрос в том, как его замедлить, чтобы оно было более заметным?

Код:

...
itemView.showIncludedCountriesTextAndArrowLayout.setOnClickListener {

    val whatCountriesAreIncludedLayout: ConstraintLayout = itemView.findViewById(R.id.whatCountriesAreIncludedLayout)

    if (countryGridAdapter?.itemCount == 0) {
        itemView.upOrDownArrowImageView.setImageResource(R.drawable.ic_up_arrow_32dp)
        itemView.showTheIncludedCountriesTextView.text = mobileSubscriptionSiteCoreSectionData.countriesListCollapseText

        countryGridAdapter.updateList(mobileSubscriptionSiteCoreSectionData.countryList)

        // Bottom margin.
        val layoutParams = whatCountriesAreIncludedLayout.layoutParams as RecyclerView.LayoutParams
        layoutParams.bottomMargin = context.resources.getDimensionPixelSize(R.dimen.countriesIncludedVisibleList)
        whatCountriesAreIncludedLayout.layoutParams = layoutParams

        recyclerView.requestLayout()
        recyclerView.invalidate()

        onShowHideListViewClickListener.onClick(it, true, viewHolder.adapterPosition,
                (itemView.showIncludedCountriesTextAndArrowLayout.top +
                        itemView.showIncludedCountriesTextAndArrowLayout.paddingTop +
                        itemView.showIncludedCountriesTextAndArrowLayout.paddingBottom) * -1)

    } else {
        itemView.upOrDownArrowImageView.setImageResource(R.drawable.ic_down_arrow_32dp)
        itemView.showTheIncludedCountriesTextView.text = mobileSubscriptionSiteCoreSectionData.countriesListExpandText

        countryGridAdapter?.updateList(listOf())

        // Bottom margin.
        val layoutParams = whatCountriesAreIncludedLayout.layoutParams as RecyclerView.LayoutParams
        layoutParams.bottomMargin = 0
        whatCountriesAreIncludedLayout.layoutParams = layoutParams

        recyclerView.requestLayout()
        recyclerView.invalidate()

        onShowHideListViewClickListener.onClick(it, false)
    }
}
...

Вот короткое видео о текущем поведении

...