Search in sources :

Example 16 with FreeFlowItem

use of com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.

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.marshalchen.common.uimodule.freeflow.core.FreeFlowItem) Section(com.marshalchen.common.uimodule.freeflow.core.Section)

Example 17 with FreeFlowItem

use of com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.

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.marshalchen.common.uimodule.freeflow.core.FreeFlowItem) Section(com.marshalchen.common.uimodule.freeflow.core.Section)

Aggregations

FreeFlowItem (com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem)17 Rect (android.graphics.Rect)8 Section (com.marshalchen.common.uimodule.freeflow.core.Section)8 Animator (android.animation.Animator)4 AnimatorSet (android.animation.AnimatorSet)4 ObjectAnimator (android.animation.ObjectAnimator)4 ValueAnimator (android.animation.ValueAnimator)4 View (android.view.View)3 ArrayList (java.util.ArrayList)3 AbsLayoutContainer (com.marshalchen.common.uimodule.freeflow.core.AbsLayoutContainer)2 OnItemClickListener (com.marshalchen.common.uimodule.freeflow.core.AbsLayoutContainer.OnItemClickListener)2 FreeFlowContainer (com.marshalchen.common.uimodule.freeflow.core.FreeFlowContainer)2 AnimatorListener (android.animation.Animator.AnimatorListener)1 OnClickListener (android.view.View.OnClickListener)1 Button (android.widget.Button)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 DefaultLayoutAnimator (com.marshalchen.common.uimodule.freeflow.animations.DefaultLayoutAnimator)1 OnScrollListener (com.marshalchen.common.uimodule.freeflow.core.FreeFlowContainer.OnScrollListener)1 HGridLayout (com.marshalchen.common.uimodule.freeflow.layouts.HGridLayout)1