Search in sources :

Example 1 with HeaderData

use of com.battlelancer.seriesguide.adapters.model.HeaderData in project SeriesGuide by UweTrottmann.

the class SectionedHistoryAdapter method generateHeaderList.

protected List<HeaderData> generateHeaderList() {
    int count = getCount();
    if (count == 0) {
        return null;
    }
    LongSparseArray<HeaderData> mapping = new LongSparseArray<>();
    List<HeaderData> headers = new ArrayList<>();
    for (int position = 0; position < count; position++) {
        long headerId = getHeaderId(position);
        HeaderData headerData = mapping.get(headerId);
        if (headerData == null) {
            headerData = new HeaderData(position);
            headers.add(headerData);
        }
        headerData.incrementCount();
        mapping.put(headerId, headerData);
    }
    return headers;
}
Also used : LongSparseArray(android.support.v4.util.LongSparseArray) ArrayList(java.util.ArrayList) HeaderData(com.battlelancer.seriesguide.adapters.model.HeaderData)

Example 2 with HeaderData

use of com.battlelancer.seriesguide.adapters.model.HeaderData in project SeriesGuide by UweTrottmann.

the class CalendarAdapter method generateHeaderList.

protected List<HeaderData> generateHeaderList() {
    int count = getCount();
    if (count == 0 || !mIsShowingHeaders) {
        return null;
    }
    // pre-size to 30 as we display 30 days == headers at most
    LongSparseArray<HeaderData> mapping = new LongSparseArray<>(30);
    List<HeaderData> headers = new ArrayList<>();
    for (int position = 0; position < count; position++) {
        long headerId = getHeaderId(position);
        HeaderData headerData = mapping.get(headerId);
        if (headerData == null) {
            headerData = new HeaderData(position);
            headers.add(headerData);
        }
        headerData.incrementCount();
        mapping.put(headerId, headerData);
    }
    return headers;
}
Also used : LongSparseArray(android.support.v4.util.LongSparseArray) ArrayList(java.util.ArrayList) HeaderData(com.battlelancer.seriesguide.adapters.model.HeaderData)

Aggregations

LongSparseArray (android.support.v4.util.LongSparseArray)2 HeaderData (com.battlelancer.seriesguide.adapters.model.HeaderData)2 ArrayList (java.util.ArrayList)2