TonicArtos / SuperSLiM

A layout manager for the RecyclerView with interchangeable linear, grid, and staggered displays of views, all with configurable section headers including the sticky variety as specified in the material design docs.
http://tonicartos.nz
2.12k stars 297 forks source link

Sections Empty ( firstSectionPosition behavior ) #154

Closed andersonkxiass closed 8 years ago

andersonkxiass commented 8 years ago

I have a App that shows a timeline with name of people, sometimes some section have no content, my questions is, what must be the behavior of the section Id?

public  List<AdapterBaseRow> getData(){

    int firstSectionPosition = 0; //Header index

    List<AdapterBaseRow> adapterBaseRows = new ArrayList<>();

    //Header
    adapterBaseRows.add(new AdapterRowHeader(new User("Google I/O 2010"), firstSectionPosition));

    //items
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_1), firstSectionPosition));
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_3), firstSectionPosition));

    firstSectionPosition = 3; //Header index

    //Header
    adapterBaseRows.add(new AdapterRowHeader(new User("Google I/O 2011"), firstSectionPosition));

    firstSectionPosition = 3; //Header index

    //Header
    adapterBaseRows.add(new AdapterRowHeader(new User("Google I/O 2012"), firstSectionPosition));

    firstSectionPosition = 3; //Header index

    //Header
    adapterBaseRows.add(new AdapterRowHeader(new User("Google I/O 2013"), firstSectionPosition));

    firstSectionPosition = 4; //Header index

    //items
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_3), firstSectionPosition));
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_5), firstSectionPosition));
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_4), firstSectionPosition));
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_3), firstSectionPosition));
    adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_2), firstSectionPosition));

    return adapterBaseRows;
}
andersonkxiass commented 8 years ago

fixed, when a section is empty just need to increase the current firstSectionPosition++.

int firstSectionPosition = 0; //Header index

List<AdapterBaseRow> adapterBaseRows = new ArrayList<>();

//Header
adapterBaseRows.add(new AdapterRowHeader(new User("Google I/O 2010"), firstSectionPosition));

//items
adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_1), firstSectionPosition));
adapterBaseRows.add(new AdapterRowPicture(new Picture(R.drawable.picture_3), firstSectionPosition));

firstSectionPosition = 4; //Header index

//Header
adapterBaseRows.add(new AdapterRowHeader(new User("Google I/O 2011"), firstSectionPosition));

firstSectionPosition = 5; //Header index

...