jmartinesp / SpannedGridLayoutManager

Android RecyclerView.LayoutManager that resizes and reorders views based on SpanSize
MIT License
600 stars 105 forks source link

Recyclerview items doesn't appear #31

Closed sami-khleaf closed 5 years ago

sami-khleaf commented 6 years ago

In the Adapter onCreate/onBindViewHolder are not called!!

val recyclerLayoutManager = SpannedGridLayoutManager(
            orientation = SpannedGridLayoutManager.Orientation.VERTICAL,
            spans = 3
        )

//        recyclerLayoutManager.spanSizeLookup = GallerySpanSizeLookup()
        galleryRecycler.layoutManager = recyclerLayoutManager
        galleryRecycler.adapter = GalleryAdapter()
sami-khleaf commented 6 years ago

@Arasthel https://stackoverflow.com/questions/52758081/recyclerview-items-doesnt-appear-when-using-spannedgridlayoutmanager

jmartinesp commented 6 years ago

How are you updating the items in the adapter? Also, does your Adapter's getItemCount() method return the actual number of items?

sami-khleaf commented 6 years ago

@Arasthel i am just showing the items for now no actions or customizations applied on any item also the getItemCount() always returns 4 i don't know where the issue is

jmartinesp commented 6 years ago

This is the current library sample with only 4 items:

screenshot

So there must be some issue with either the layout of your items or how you update them. Without that code, there's not much I can do.

sami-khleaf commented 6 years ago

@Arasthel the samples works fine but im using the library in a custom Widget i've created i only add the widget in the XML. the recycler code and the layout managers code is in the custom widget

jmartinesp commented 6 years ago

I've tried different ways to break the LayoutManager by setting match_parent, fixed sizes or huge children views on the items, even using complex ViewGroups such as ConstraintLayout as the root view of the items and it still worked. I can't help you if I don't know what you've done by looking at some actual code.

devabir93 commented 6 years ago

also mine :\

jmartinesp commented 6 years ago

also mine :\

Could you provide some code so I can reproduce it and debug it? Thanks.

devabir93 commented 6 years ago

Here is the code in activity

       spannedGridLayoutManager = new SpannedGridLayoutManager(
                SpannedGridLayoutManager.Orientation.VERTICAL, 4);
        spannedGridLayoutManager.setItemOrderIsStable(true);
        recyclerview.setLayoutManager(spannedGridLayoutManager);
 recyclerview.setAdapter(categoryAdapter);
and here in adapter

        if (type == Const.GRID) {
            Timber.d("type grid");
            if (position % 3 == 0) {
                width = 2;
                height = 2;
            } else if (position % 3 != 0) {
                width = 2;
                height = 1;
            }
            holder.itemView.setLayoutParams(new SpanLayoutParams(new SpanSize(width, height)));
        } 

am using two type of layout grid and linear and the items shown in linear way but the SpannedGridLayoutManager didn't show any thing.

jmartinesp commented 6 years ago

What are all the assigned width and height values? I just tried with your code and got this: image

devabir93 commented 6 years ago

should i give height and width for items ? first i made it match_parent for height and width , and after i gave it specific width and height it still doesn't appear. i am using custom adapter and the items are images with some text.

jmartinesp commented 6 years ago

I meant for the SpanSize. On the snippet you posted, you set the SpanSizes if the type is GRID, but what about the rest of types? Do they also have defined SpanSizes?

jmartinesp commented 5 years ago

If this was related to a scrolling issue because the adapter was empty when first presented, this should be fixed on version 3.0.1.