Fix: Product Adapter cleanup

This commit is contained in:
LooKeR 2021-11-22 00:10:03 +05:30
parent 4f31854876
commit 83a9efcfd7
2 changed files with 2 additions and 7 deletions

View File

@ -59,12 +59,8 @@ import java.lang.ref.WeakReference
import java.util.*
import kotlin.math.*
class ProductAdapter(private val callbacks: Callbacks, private val columns: Int) :
class ProductAdapter(private val callbacks: Callbacks) :
StableRecyclerAdapter<ProductAdapter.ViewType, RecyclerView.ViewHolder>() {
companion object {
private const val GRID_SPACING_OUTER_DP = 16
private const val GRID_SPACING_INNER_DP = 8
}
interface Callbacks {
fun onActionClick(action: Action)

View File

@ -108,11 +108,10 @@ class ProductFragment() : ScreenFragment(), ProductAdapter.Callbacks {
val content = fragmentBinding.fragmentContent
content.addView(RecyclerView(content.context).apply {
id = android.R.id.list
val columns = (resources.configuration.screenWidthDp / 120).coerceIn(3, 5)
this.layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
isMotionEventSplittingEnabled = false
isVerticalScrollBarEnabled = false
val adapter = ProductAdapter(this@ProductFragment, columns)
val adapter = ProductAdapter(this@ProductFragment)
this.adapter = adapter
addOnScrollListener(scrollListener)
savedInstanceState?.getParcelable<ProductAdapter.SavedState>(STATE_ADAPTER)