This commit is contained in:
Benoit Marty 2019-12-09 22:09:17 +01:00
parent edc6c3dd4f
commit 99423bacb2
5 changed files with 9 additions and 9 deletions

View file

@ -16,6 +16,7 @@
package im.vector.riotx.core.extensions
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.airbnb.epoxy.EpoxyController
@ -25,11 +26,13 @@ import com.airbnb.epoxy.EpoxyController
*/
fun RecyclerView.configureWith(epoxyController: EpoxyController,
itemAnimator: RecyclerView.ItemAnimator? = null,
itemDecoration: RecyclerView.ItemDecoration? = null,
showDivider: Boolean = false,
hasFixedSize: Boolean = true) {
layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
itemAnimator?.let { this.itemAnimator = it }
itemDecoration?.let { addItemDecoration(it) }
if (showDivider) {
addItemDecoration(DividerItemDecoration(context, DividerItemDecoration.VERTICAL))
}
setHasFixedSize(hasFixedSize)
adapter = epoxyController.adapter
}

View file

@ -68,7 +68,7 @@ class ViewEditHistoryBottomSheet : VectorBaseBottomSheetDialogFragment() {
super.onActivityCreated(savedInstanceState)
recyclerView.configureWith(
epoxyController,
itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL),
showDivider = true,
hasFixedSize = false)
bottomSheetTitle.text = context?.getString(R.string.message_edits)
}

View file

@ -17,7 +17,6 @@ package im.vector.riotx.features.reactions
import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.DividerItemDecoration
import com.airbnb.mvrx.activityViewModel
import com.airbnb.mvrx.withState
import im.vector.riotx.R
@ -49,7 +48,7 @@ class EmojiSearchResultFragment @Inject constructor(
}
}
recyclerView.configureWith(epoxyController, itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL))
recyclerView.configureWith(epoxyController, showDivider = true)
}
override fun onDestroyView() {

View file

@ -18,7 +18,6 @@ package im.vector.riotx.features.settings.push
import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.DividerItemDecoration
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.riotx.R
@ -46,7 +45,7 @@ class PushGatewaysFragment @Inject constructor(
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerView.configureWith(epoxyController, itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL))
recyclerView.configureWith(epoxyController, showDivider = true)
}
override fun onDestroyView() {

View file

@ -17,7 +17,6 @@ package im.vector.riotx.features.settings.push
import android.os.Bundle
import android.view.View
import androidx.recyclerview.widget.DividerItemDecoration
import com.airbnb.epoxy.TypedEpoxyController
import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
@ -46,7 +45,7 @@ class PushRulesFragment : VectorBaseFragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
recyclerView.configureWith(epoxyController, itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL))
recyclerView.configureWith(epoxyController, showDivider = true)
}
override fun onDestroyView() {