luizgrp / SectionedRecyclerViewAdapter

An Adapter that allows a RecyclerView to be split into Sections with headers and/or footers. Each Section can have its state controlled individually.
MIT License
1.68k stars 372 forks source link

can't hide empty sections : similar issue to one resolved earlier #140

Closed Fahad-pnw closed 5 years ago

Fahad-pnw commented 5 years ago

Hi, thanks for a great library.

my issue is very similar to this: https://github.com/luizgrp/SectionedRecyclerViewAdapter/issues/130

what i want to do is hide empty sections, i've tried various ways to do that, but i'm failing it constantly. I believe someone could instantly point out what i must do in order to hide a section that's empty.

` val headerHolder = holder as HeaderViewHolder

    if (sectionItemsTotal<=1){
        headerHolder.itemView.cl_lesson_header.visibility = View.GONE
        holder.itemView.visibility = View.GONE
    }`

this works, but shows empty views instead. tried sectionAdapter!!.notifyDataSetChanged() but it doesn't really help the case.

Fahad-pnw commented 5 years ago

also, this i'm trying to do it upon creation, while removal in the examples were done onclick which were already loaded. i just want to make sure when creating sections, if any section is empty, let it not be created, can someone pls point me to that example or so?

yccheok commented 5 years ago

There's a method setHasHeader for Section, has you tried that?

luizgrp commented 5 years ago

Closing due to inactivity.