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:
@@ -129,7 +129,6 @@ dependencies {
|
||||
|
||||
//Google's Goodies
|
||||
implementation "com.google.android.material:material:1.9.0"
|
||||
implementation "com.google.android.flexbox:flexbox:3.0.0"
|
||||
implementation "com.google.code.gson:gson:2.10.1"
|
||||
|
||||
//AndroidX
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user