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;
}
}
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());
}
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);
}
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());
}
});
}
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());
}
Aggregations