use of com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.
the class DefaultLayoutAnimator method getItemsMovedAnimation.
protected AnimatorSet getItemsMovedAnimation(List<Pair<FreeFlowItem, Rect>> moved) {
AnimatorSet anim = new AnimatorSet();
ArrayList<Animator> moves = new ArrayList<Animator>();
for (Pair<FreeFlowItem, Rect> item : moved) {
FreeFlowItem proxy = FreeFlowItem.clone(item.first);
View v = proxy.view;
proxy.frame.left -= callback.getViewportLeft();
proxy.frame.top -= callback.getViewportTop();
proxy.frame.right -= callback.getViewportLeft();
proxy.frame.bottom -= callback.getViewportTop();
moves.add(transitionToFrame(item.second, proxy, v));
}
anim.playTogether(moves);
return anim;
}
use of com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.
the class FreeFlowPhotoGridActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.free_flow_photo_grid_activity);
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.frameLayout);
final ImageAdapter adapter = new ImageAdapter();
container = new FreeFlowContainer(this);
DefaultLayoutAnimator anim = (DefaultLayoutAnimator) container.getLayoutAnimator();
anim.animateAllSetsSequentially = false;
anim.animateIndividualCellsSequentially = false;
container.requestFocus();
hLayout = new HLayout();
hLayout.setLayoutParams(new HLayout.LayoutParams(100, 150, 600));
vLayout = new VLayout();
vLayout.setLayoutParams(new VLayout.LayoutParams(100, 600, 150));
vGridLayout = new VGridLayout();
vGridLayout.setLayoutParams(new VGridLayout.LayoutParams(200, 200, 600, 100));
hGridLayout = new HGridLayout();
hGridLayout.setLayoutParams(new HGridLayout.LayoutParams(200, 200, 100, 600));
layouts = new FreeFlowLayout[] { vLayout, hLayout, vGridLayout, hGridLayout };
container.setAdapter(adapter);
container.setLayout(layouts[currentLayoutIndex]);
frameLayout.addView(container);
changeButton = ((Button) frameLayout.findViewById(R.id.transitionButton));
changeButton.setText("Layout");
changeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
currentLayoutIndex++;
if (currentLayoutIndex == layouts.length) {
currentLayoutIndex = 0;
}
container.setLayout(layouts[currentLayoutIndex]);
}
});
jumpButton = (Button) findViewById(R.id.jumpButton);
jumpButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int section = (int) (adapter.getNumberOfSections() * Math.random());
int index = (int) (adapter.getSection(section).getDataCount() * Math.random());
String s = "section = " + section + ", index = " + index;
Toast.makeText(FreeFlowPhotoGridActivity.this, s, Toast.LENGTH_SHORT).show();
container.scrollToItem(section, index, false);
}
});
jumpButtonAnim = (Button) findViewById(R.id.jumpButtonAnim);
jumpButtonAnim.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int section = (int) (adapter.getNumberOfSections() * Math.random());
int index = (int) (adapter.getSection(section).getDataCount() * Math.random());
String s = "section = " + section + ", index = " + index;
Toast.makeText(FreeFlowPhotoGridActivity.this, s, Toast.LENGTH_SHORT).show();
container.scrollToItem(section, index, true);
}
});
container.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AbsLayoutContainer parent, FreeFlowItem proxy) {
Log.d("Test", "container item: " + proxy.itemSection + " / " + proxy.itemIndex);
}
});
changeButton.bringToFront();
jumpButton.bringToFront();
jumpButtonAnim.bringToFront();
}
use of com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.
the class ArtbookLayout method prepareLayout.
@Override
public void prepareLayout() {
Log.d(TAG, "prepare layout!!!");
map = new HashMap<Object, FreeFlowItem>();
s = itemsAdapter.getSection(0);
int rowIndex;
Log.d(TAG, "prepare layout for: " + s.getDataCount());
for (int i = 0; i < s.getDataCount(); i++) {
rowIndex = i / 5;
FreeFlowItem p = new FreeFlowItem();
p.isHeader = false;
p.itemIndex = i;
p.itemSection = 0;
p.data = s.getDataAtIndex(i);
Rect r = new Rect();
switch(i % 5) {
case (0):
r.left = 0;
r.top = rowIndex * largeItemSide;
r.right = largeItemSide;
r.bottom = r.top + largeItemSide;
if (rowIndex % 2 != 0) {
r.offset(largeItemSide, 0);
}
break;
case (1):
r.left = largeItemSide;
r.right = largeItemSide + regularItemSide;
r.top = rowIndex * largeItemSide;
r.bottom = r.top + regularItemSide;
if (rowIndex % 2 != 0) {
r.offset(-largeItemSide, 0);
}
break;
case (2):
r.left = 3 * regularItemSide;
r.right = width;
r.top = rowIndex * largeItemSide;
r.bottom = r.top + regularItemSide;
if (rowIndex % 2 != 0) {
r.offset(-largeItemSide, 0);
}
break;
case (3):
r.left = largeItemSide;
r.right = largeItemSide + regularItemSide;
r.top = rowIndex * largeItemSide + regularItemSide;
r.bottom = r.top + regularItemSide;
if (rowIndex % 2 != 0) {
r.offset(-largeItemSide, 0);
}
break;
case (4):
r.left = 3 * regularItemSide;
r.right = width;
r.top = rowIndex * largeItemSide + regularItemSide;
r.bottom = r.top + regularItemSide;
if (rowIndex % 2 != 0) {
r.offset(-largeItemSide, 0);
}
break;
default:
break;
}
p.frame = r;
map.put(s.getDataAtIndex(i), p);
}
}
use of com.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.
the class FreeFlowArtbookActivity 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.marshalchen.common.uimodule.freeflow.core.FreeFlowItem in project UltimateAndroid by cymcsg.
the class ArtbookLayout method getItemProxies.
@Override
public HashMap<Object, FreeFlowItem> getItemProxies(int viewPortLeft, int viewPortTop) {
Rect viewport = new Rect(viewPortLeft, viewPortTop, viewPortLeft + width, viewPortTop + height);
//Log.d(TAG, "Viewport: "+viewPortLeft+", "+viewPortTop+", "+viewport.width()+","+viewport.height());
HashMap<Object, FreeFlowItem> ret = new HashMap<Object, FreeFlowItem>();
Iterator<Entry<Object, FreeFlowItem>> it = map.entrySet().iterator();
while (it.hasNext()) {
Entry<Object, FreeFlowItem> pairs = it.next();
FreeFlowItem p = (FreeFlowItem) pairs.getValue();
if (Rect.intersects(p.frame, viewport)) {
ret.put(pairs.getKey(), p);
}
}
return ret;
}
Aggregations