Search in sources :

Example 1 with Section

use of com.comcast.freeflow.core.Section in project FreeFlow by Comcast.

the class VLayout method prepareLayout.

public void prepareLayout() {
    if (itemHeight < 0) {
        throw new IllegalStateException("itemHeight not set");
    }
    proxies.clear();
    int topStart = 0;
    for (int i = 0; i < itemsAdapter.getNumberOfSections(); i++) {
        Section s = itemsAdapter.getSection(i);
        if (itemsAdapter.shouldDisplaySectionHeaders()) {
            if (headerWidth < 0) {
                throw new IllegalStateException("headerWidth not set");
            }
            if (headerHeight < 0) {
                throw new IllegalStateException("headerHeight not set");
            }
            FreeFlowItem header = new FreeFlowItem();
            Rect hframe = new Rect();
            header.itemSection = i;
            header.itemIndex = -1;
            header.isHeader = true;
            hframe.left = 0;
            hframe.top = topStart;
            hframe.right = headerWidth;
            hframe.bottom = topStart + headerHeight;
            header.frame = hframe;
            header.data = s.getHeaderData();
            proxies.put(header.data, header);
            topStart += headerHeight;
        }
        for (int j = 0; j < s.getDataCount(); j++) {
            FreeFlowItem descriptor = new FreeFlowItem();
            Rect frame = new Rect();
            descriptor.itemSection = i;
            descriptor.itemIndex = j;
            frame.left = 0;
            frame.top = j * itemHeight + topStart;
            frame.right = width;
            frame.bottom = frame.top + itemHeight;
            descriptor.frame = frame;
            descriptor.data = s.getDataAtIndex(j);
            proxies.put(descriptor.data, descriptor);
        }
        topStart += (s.getDataCount()) * itemHeight;
    }
}
Also used : Rect(android.graphics.Rect) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Example 2 with Section

use of com.comcast.freeflow.core.Section in project FreeFlow by Comcast.

the class HGridLayout method prepareLayout.

public void prepareLayout() {
    proxies.clear();
    int rows = height / itemHeight;
    int leftStart = 0;
    for (int i = 0; i < itemsAdapter.getNumberOfSections(); i++) {
        Section s = itemsAdapter.getSection(i);
        if (itemsAdapter.shouldDisplaySectionHeaders()) {
            FreeFlowItem header = new FreeFlowItem();
            Rect hframe = new Rect();
            header.itemSection = i;
            header.itemIndex = -1;
            header.isHeader = true;
            hframe.left = leftStart;
            hframe.top = 0;
            hframe.right = leftStart + headerWidth;
            hframe.bottom = headerHeight;
            header.frame = hframe;
            header.data = s.getHeaderData();
            proxies.put(header.data, header);
            leftStart += headerWidth;
        }
        for (int j = 0; j < s.getDataCount(); j++) {
            FreeFlowItem descriptor = new FreeFlowItem();
            Rect frame = new Rect();
            descriptor.itemSection = i;
            descriptor.itemIndex = j;
            frame.left = (j / rows) * itemWidth + leftStart;
            frame.top = (j % rows) * itemHeight;
            frame.right = frame.left + itemWidth;
            frame.bottom = frame.top + itemHeight;
            descriptor.frame = frame;
            descriptor.data = s.getDataAtIndex(j);
            proxies.put(descriptor.data, descriptor);
        }
        int mod = 0;
        if (s.getDataCount() % rows != 0)
            mod = 1;
        leftStart += ((s.getDataCount() / rows) + mod) * itemWidth;
    }
}
Also used : Rect(android.graphics.Rect) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Example 3 with Section

use of com.comcast.freeflow.core.Section in project FreeFlow by Comcast.

the class HLayout method prepareLayout.

public void prepareLayout() {
    if (itemWidth < 0) {
        throw new IllegalStateException("itemWidth not set");
    }
    proxies.clear();
    int leftStart = 0;
    for (int i = 0; i < itemsAdapter.getNumberOfSections(); i++) {
        Section s = itemsAdapter.getSection(i);
        if (itemsAdapter.shouldDisplaySectionHeaders()) {
            if (headerWidth < 0) {
                throw new IllegalStateException("headerWidth not set");
            }
            if (headerHeight < 0) {
                throw new IllegalStateException("headerHeight not set");
            }
            FreeFlowItem header = new FreeFlowItem();
            Rect hframe = new Rect();
            header.itemSection = i;
            header.itemIndex = -1;
            header.isHeader = true;
            hframe.left = leftStart;
            hframe.top = 0;
            hframe.right = leftStart + headerWidth;
            hframe.bottom = headerHeight;
            header.frame = hframe;
            header.data = s.getHeaderData();
            proxies.put(header.data, header);
            leftStart += headerWidth;
        }
        for (int j = 0; j < s.getDataCount(); j++) {
            FreeFlowItem descriptor = new FreeFlowItem();
            Rect frame = new Rect();
            descriptor.itemSection = i;
            descriptor.itemIndex = j;
            frame.left = j * itemWidth + leftStart;
            frame.top = 0;
            frame.right = frame.left + itemWidth;
            frame.bottom = height;
            descriptor.frame = frame;
            descriptor.data = s.getDataAtIndex(j);
            proxies.put(descriptor.data, descriptor);
        }
        leftStart += s.getDataCount() * itemWidth;
    }
}
Also used : Rect(android.graphics.Rect) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Example 4 with Section

use of com.comcast.freeflow.core.Section in project FreeFlow by Comcast.

the class VGridLayout method prepareLayout.

public void prepareLayout() {
    proxies.clear();
    int cols = width / itemWidth;
    int topStart = 0;
    if (itemsAdapter == null)
        return;
    for (int i = 0; i < itemsAdapter.getNumberOfSections(); i++) {
        Section s = itemsAdapter.getSection(i);
        if (itemsAdapter.shouldDisplaySectionHeaders()) {
            FreeFlowItem header = new FreeFlowItem();
            Rect hframe = new Rect();
            header.itemSection = i;
            header.itemIndex = -1;
            header.isHeader = true;
            hframe.left = 0;
            hframe.top = topStart;
            hframe.right = headerWidth;
            hframe.bottom = topStart + headerHeight;
            header.frame = hframe;
            header.data = s.getHeaderData();
            proxies.put(header.data, header);
            topStart += headerHeight;
        }
        for (int j = 0; j < s.getDataCount(); j++) {
            FreeFlowItem descriptor = new FreeFlowItem();
            Rect frame = new Rect();
            descriptor.itemSection = i;
            descriptor.itemIndex = j;
            frame.left = (j % cols) * itemWidth;
            frame.top = (j / cols) * itemHeight + topStart;
            frame.right = frame.left + itemWidth;
            frame.bottom = frame.top + itemHeight;
            frame.inset(itemFrameInsetX, itemFrameInsetY);
            descriptor.frame = frame;
            descriptor.data = s.getDataAtIndex(j);
            proxies.put(descriptor.data, descriptor);
        }
        int mod = 0;
        if (s.getDataCount() % cols != 0)
            mod = 1;
        topStart += ((s.getDataCount() / cols) + mod) * itemHeight;
    }
}
Also used : Rect(android.graphics.Rect) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Example 5 with Section

use of com.comcast.freeflow.core.Section in project FreeFlow by Comcast.

the class VLayout method getContentHeight.

@Override
public int getContentHeight() {
    if (itemsAdapter == null || itemsAdapter.getNumberOfSections() <= 0) {
        return 0;
    }
    int sectionIndex = itemsAdapter.getNumberOfSections() - 1;
    Section s = itemsAdapter.getSection(sectionIndex);
    if (s.getDataCount() == 0)
        return 0;
    Object lastFrameData = s.getDataAtIndex(s.getDataCount() - 1);
    FreeFlowItem fd = proxies.get(lastFrameData);
    return (fd.frame.top + fd.frame.height());
}
Also used : FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Aggregations

Section (com.comcast.freeflow.core.Section)9 FreeFlowItem (com.comcast.freeflow.core.FreeFlowItem)8 Rect (android.graphics.Rect)4 Paint (android.graphics.Paint)1