mikepenz / FastAdapter

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
https://mikepenz.dev
Apache License 2.0
3.84k stars 494 forks source link

Diff items in GridLayout #1004

Closed NetylkinOV closed 3 years ago

NetylkinOV commented 3 years ago

Hello mikepenz. Tell me is it possible to do it? Add 2 different items to RecyclerView with GridLayoutManager 2 columns. Check image. Thank you :)

example

mikepenz commented 3 years ago

@NetylkinOV yes this is possible.

See this example: https://github.com/mikepenz/FastAdapter/blob/develop/app/src/main/java/com/mikepenz/fastadapter/app/IconGridActivity.kt

NetylkinOV commented 3 years ago

Hi mikepenz, thank you so much for your help. The short answer is:

val gridLayoutManager = GridLayoutManager (this, 3)
         gridLayoutManager.spanSizeLookup = object: GridLayoutManager.SpanSizeLookup () {
             override fun getSpanSize (position: Int): Int {
                 return when (fastItemAdapter.getItemViewType (position)) {
                     R.id.fastadapter_expandable_item_id -> 3
                     R.id.fastadapter_icon_item_id -> 1
                     else -> -1
                 }
             }
         }

As I don't need an implementation with Expandable. I have been using your library for several years now, it's amazing how powerful it is.

I'm still waiting for the multiplatform kotlin version :)))

NetylkinOV commented 3 years ago

I wish you health and good luck :)

mikepenz commented 3 years ago

Happy I could help :) Thanks for the kind words