Switch to StaggeredGridLayoutManager for accents

Gives almost same effect as FlexLayoutManager and is part of recyclerview
library letting us drop an additional dependency

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-05-18 10:23:10 +05:30
parent 52fce86131
commit 00e93f53f6
3 changed files with 3 additions and 50 deletions

View File

@@ -1,47 +0,0 @@
/*
* Aurora Store
* Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
*
* Aurora Store is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Aurora Store is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.gara.store.view.epoxy.controller
import android.content.Context
import android.util.AttributeSet
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.google.android.flexbox.FlexboxLayoutManager
class FlexLayoutManager : FlexboxLayoutManager {
constructor(context: Context?) : super(context)
constructor(context: Context?, flexDirection: Int) : super(context, flexDirection)
constructor(context: Context?, flexDirection: Int, flexWrap: Int) : super(
context,
flexDirection,
flexWrap
)
constructor(
context: Context?,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
override fun generateLayoutParams(lp: ViewGroup.LayoutParams): RecyclerView.LayoutParams {
return LayoutParams(lp)
}
}

View File

@@ -29,6 +29,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewAnimationUtils
import android.view.ViewGroup
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.aurora.store.R
import com.aurora.store.data.model.Accent
import com.aurora.store.databinding.FragmentOnboardingAccentBinding
@@ -44,7 +45,6 @@ import com.aurora.store.util.save
import com.aurora.store.view.custom.CubicBezierInterpolator
import com.aurora.store.view.epoxy.views.AccentViewModel_
import com.aurora.store.view.ui.commons.BaseFragment
import com.gara.store.view.epoxy.controller.FlexLayoutManager
import com.google.gson.reflect.TypeToken
import java.nio.charset.StandardCharsets
import kotlin.math.sqrt
@@ -94,7 +94,8 @@ class AccentFragment : BaseFragment() {
private fun attachRecycler() {
with(B.epoxyRecycler) {
layoutManager = FlexLayoutManager(requireContext())
setHasFixedSize(true)
layoutManager = StaggeredGridLayoutManager(5, StaggeredGridLayoutManager.VERTICAL)
}
}