Search in sources :

Example 1 with DefaultSectionAdapter

use of com.comcast.freeflow.helpers.DefaultSectionAdapter in project FreeFlow by Comcast.

the class FreeFlowContainerTest method testSourceCannotModifyFreeFlowContainerReferences.

/**
	 * Tests that changing an attached layout cannot change 
	 * the internal map of the item proxies insode a container
	 * 
	 * @throws InterruptedException
	 */
public void testSourceCannotModifyFreeFlowContainerReferences() throws InterruptedException {
    final CountDownLatch lock = new CountDownLatch(1);
    main.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            final FreeFlowContainer container = new FreeFlowContainer(main);
            final VLayout vLayout = new VLayout();
            vLayout.setLayoutParams(new VLayout.LayoutParams(300, 200, 10));
            container.setLayout(vLayout);
            final DefaultSectionAdapter adapter = new DefaultSectionAdapter(main, 1, 2);
            container.setAdapter(adapter);
            main.setContentView(container);
            container.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {

                @Override
                public boolean onPreDraw() {
                    int frameCount = container.getFrames().size();
                    adapter.setData(5, 10);
                    // setItems will force new frames to be generated, but not set 
                    vLayout.setAdapter(adapter);
                    vLayout.prepareLayout();
                    //assertEquals("Layout frames did not generate as expected", 5*(10+1), vLayout.getAllProxies().size());
                    assertEquals("FreeFlowContainer frames changed unexpectedly with data", frameCount, container.getFrames().size());
                    lock.countDown();
                    return false;
                }
            });
        }
    });
    lock.await(5000, TimeUnit.MILLISECONDS);
}
Also used : VLayout(com.comcast.freeflow.layouts.VLayout) DefaultSectionAdapter(com.comcast.freeflow.helpers.DefaultSectionAdapter) CountDownLatch(java.util.concurrent.CountDownLatch) OnPreDrawListener(android.view.ViewTreeObserver.OnPreDrawListener)

Example 2 with DefaultSectionAdapter

use of com.comcast.freeflow.helpers.DefaultSectionAdapter in project FreeFlow by Comcast.

the class FreeFlowContainerTest method testAllViewsAreGeneratedByFirstLayout.

/**
	 * Tests that all items are generated by the time predraw kicks in
	 * 
	 * @throws InterruptedException
	 */
public void testAllViewsAreGeneratedByFirstLayout() throws InterruptedException {
    final CountDownLatch lock = new CountDownLatch(1);
    main.runOnUiThread(new Runnable() {

        @Override
        public void run() {
            final FreeFlowContainer container = new FreeFlowContainer(main);
            DefaultSectionAdapter adapter = new DefaultSectionAdapter(main, 1, 2);
            container.setAdapter(adapter);
            VLayout vLayout = new VLayout();
            vLayout.setLayoutParams(new VLayout.LayoutParams(300, 200, 10));
            container.setLayout(vLayout);
            container.addFreeFlowEventListener(new FreeFlowEventListener() {

                @Override
                public void onLayoutChanging(FreeFlowLayout oldLayout, FreeFlowLayout newLayout) {
                }

                @Override
                public void layoutComputed() {
                }

                @Override
                public void layoutComplete(boolean areTransitionAnimationsPlaying) {
                    assertEquals("Correct number of children were not created", 3, container.getChildCount());
                }

                @Override
                public void dataChanged() {
                }

                @Override
                public void animationsStarted() {
                }

                @Override
                public void layoutChangeAnimationsComplete() {
                }
            });
            main.setContentView(container);
        }
    });
    lock.await(5000, TimeUnit.MILLISECONDS);
}
Also used : DefaultSectionAdapter(com.comcast.freeflow.helpers.DefaultSectionAdapter) VLayout(com.comcast.freeflow.layouts.VLayout) CountDownLatch(java.util.concurrent.CountDownLatch) FreeFlowLayout(com.comcast.freeflow.layouts.FreeFlowLayout)

Example 3 with DefaultSectionAdapter

use of com.comcast.freeflow.helpers.DefaultSectionAdapter 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)

Aggregations

DefaultSectionAdapter (com.comcast.freeflow.helpers.DefaultSectionAdapter)3 VLayout (com.comcast.freeflow.layouts.VLayout)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 OnPreDrawListener (android.view.ViewTreeObserver.OnPreDrawListener)1 FreeFlowItem (com.comcast.freeflow.core.FreeFlowItem)1 FreeFlowLayout (com.comcast.freeflow.layouts.FreeFlowLayout)1