Search in sources :

Example 6 with FreeFlowItem

use of com.comcast.freeflow.core.FreeFlowItem 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 7 with FreeFlowItem

use of com.comcast.freeflow.core.FreeFlowItem 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)

Example 8 with FreeFlowItem

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

the class VGridLayoutTest method testGridLayoutMath.

public void testGridLayoutMath() {
    VGridLayout vGrid = new VGridLayout();
    vGrid.setLayoutParams(new VGridLayout.LayoutParams(250, 250, 200, 500));
    DefaultSectionAdapter adapter = new DefaultSectionAdapter(getActivity(), 2, 5);
    vGrid.setAdapter(adapter);
    vGrid.setDimensions(600, 1000);
    vGrid.prepareLayout();
    Map<? extends Object, FreeFlowItem> map;
    map = vGrid.getItemProxies(0, 0);
    assertEquals("VGridLayout did not generate correct number of frames", 5, map.size());
    vGrid.setDimensions(600, 1001);
    map = vGrid.getItemProxies(0, 0);
    assertEquals("VGridLayout did not generate correct number of frames (2) ", 6, map.size());
    FreeFlowItem proxy = map.get(adapter.getSection(0).getHeaderData());
    assertNotNull("Header frame was null", proxy);
}
Also used : DefaultSectionAdapter(com.comcast.freeflow.helpers.DefaultSectionAdapter) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem)

Example 9 with FreeFlowItem

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

the class ArtbookActivity method onDataLoaded.

public void onDataLoaded(DribbbleFeed feed) {
    Log.d(TAG, "photo: " + feed.getShots().get(0).getImage_teaser_url());
    adapter.update(feed);
    container.dataInvalidated();
    container.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AbsLayoutContainer parent, FreeFlowItem proxy) {
        }
    });
    container.addScrollListener(new OnScrollListener() {

        @Override
        public void onScroll(FreeFlowContainer container) {
            Log.d(TAG, "scroll percent " + container.getScrollPercentY());
        }
    });
}
Also used : OnItemClickListener(com.comcast.freeflow.core.AbsLayoutContainer.OnItemClickListener) OnScrollListener(com.comcast.freeflow.core.FreeFlowContainer.OnScrollListener) FreeFlowContainer(com.comcast.freeflow.core.FreeFlowContainer) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) AbsLayoutContainer(com.comcast.freeflow.core.AbsLayoutContainer)

Example 10 with FreeFlowItem

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

the class HGridLayout method getContentWidth.

@Override
public int getContentWidth() {
    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.left + fd.frame.width());
}
Also used : FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Aggregations

FreeFlowItem (com.comcast.freeflow.core.FreeFlowItem)18 Rect (android.graphics.Rect)8 Section (com.comcast.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.comcast.freeflow.core.AbsLayoutContainer)2 OnItemClickListener (com.comcast.freeflow.core.AbsLayoutContainer.OnItemClickListener)2 FreeFlowContainer (com.comcast.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.comcast.freeflow.animations.DefaultLayoutAnimator)1 OnScrollListener (com.comcast.freeflow.core.FreeFlowContainer.OnScrollListener)1 DefaultSectionAdapter (com.comcast.freeflow.helpers.DefaultSectionAdapter)1