Search in sources :

Example 16 with FreeFlowItem

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

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;
}
Also used : Rect(android.graphics.Rect) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) ArrayList(java.util.ArrayList) AnimatorSet(android.animation.AnimatorSet) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) View(android.view.View)

Example 17 with FreeFlowItem

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

the class NoAnimationLayoutAnimator method animateChanges.

@Override
public void animateChanges(LayoutChangeset changes, FreeFlowContainer callback) {
    this.changes = changes;
    for (Pair<FreeFlowItem, Rect> item : changes.getMoved()) {
        Rect r = item.first.frame;
        View v = item.first.view;
        int wms = MeasureSpec.makeMeasureSpec(r.right - r.left, MeasureSpec.EXACTLY);
        int hms = MeasureSpec.makeMeasureSpec(r.bottom - r.top, MeasureSpec.EXACTLY);
        v.measure(wms, hms);
        v.layout(r.left, r.top, r.right, r.bottom);
    }
    callback.onLayoutChangeAnimationsCompleted(this);
}
Also used : Rect(android.graphics.Rect) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) View(android.view.View)

Example 18 with FreeFlowItem

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

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);
    }
}
Also used : Rect(android.graphics.Rect) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem)

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