Search in sources :

Example 11 with FreeFlowItem

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

the class HLayout 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)

Example 12 with FreeFlowItem

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

the class VGridLayout 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);
    if (fd == null) {
        return 0;
    }
    return (fd.frame.top + fd.frame.height());
}
Also used : FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Section(com.comcast.freeflow.core.Section)

Example 13 with FreeFlowItem

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

the class DefaultLayoutAnimator method getItemsAddedAnimation.

/**
	 * 
	 */
protected AnimatorSet getItemsAddedAnimation(List<FreeFlowItem> added) {
    AnimatorSet appearingSet = new AnimatorSet();
    ArrayList<Animator> fadeIns = new ArrayList<Animator>();
    for (FreeFlowItem proxy : added) {
        proxy.view.setAlpha(0);
        fadeIns.add(ObjectAnimator.ofFloat(proxy.view, "alpha", 1));
    }
    if (animateIndividualCellsSequentially)
        appearingSet.playSequentially(fadeIns);
    else
        appearingSet.playTogether(fadeIns);
    appearingSet.setStartDelay(newCellsAdditionAnimationStartDelay);
    appearingSet.setDuration(newCellsAdditionAnimationDurationPerCell);
    return appearingSet;
}
Also used : 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)

Example 14 with FreeFlowItem

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

the class DefaultLayoutAnimator method animateChanges.

@Override
public void animateChanges(LayoutChangeset changeSet, final FreeFlowContainer callback) {
    this.changeSet = changeSet;
    this.callback = callback;
    cancel();
    mIsRunning = true;
    disappearingSet = null;
    appearingSet = null;
    movingSet = null;
    Comparator<FreeFlowItem> cmp = new Comparator<FreeFlowItem>() {

        @Override
        public int compare(FreeFlowItem lhs, FreeFlowItem rhs) {
            return (lhs.itemSection * 1000 + lhs.itemIndex) - (rhs.itemSection * 1000 + rhs.itemIndex);
        }
    };
    List<FreeFlowItem> removed = changeSet.getRemoved();
    if (removed.size() > 0) {
        Collections.sort(removed, cmp);
        disappearingSet = getItemsRemovedAnimation(changeSet.getRemoved());
    }
    List<FreeFlowItem> added = changeSet.getAdded();
    if (added.size() > 0) {
        Collections.sort(added, cmp);
        appearingSet = getItemsAddedAnimation(added);
    }
    if (changeSet.getMoved().size() > 0) {
        movingSet = getItemsMovedAnimation(changeSet.getMoved());
    }
    AnimatorSet all = getAnimationSequence();
    if (all == null) {
        mIsRunning = false;
        callback.onLayoutChangeAnimationsCompleted(this);
    } else {
        all.addListener(new AnimatorListener() {

            @Override
            public void onAnimationStart(Animator animation) {
            }

            @Override
            public void onAnimationRepeat(Animator animation) {
            }

            @Override
            public void onAnimationEnd(Animator animation) {
                mIsRunning = false;
                callback.onLayoutChangeAnimationsCompleted(DefaultLayoutAnimator.this);
            }

            @Override
            public void onAnimationCancel(Animator animation) {
            }
        });
        all.start();
    }
}
Also used : AnimatorListener(android.animation.Animator.AnimatorListener) ObjectAnimator(android.animation.ObjectAnimator) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) AnimatorSet(android.animation.AnimatorSet) FreeFlowItem(com.comcast.freeflow.core.FreeFlowItem) Comparator(java.util.Comparator)

Example 15 with FreeFlowItem

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

the class DefaultLayoutAnimator method getItemsRemovedAnimation.

/**
	 * The animation to run on the items being removed
	 * 
	 * @param removed
	 *            An ArrayList of <code>FreeFlowItems</code> removed
	 * @return The AnimatorSet of the removed objects
	 */
protected AnimatorSet getItemsRemovedAnimation(List<FreeFlowItem> removed) {
    AnimatorSet disappearingSet = new AnimatorSet();
    ArrayList<Animator> fades = new ArrayList<Animator>();
    for (FreeFlowItem proxy : removed) {
        fades.add(ObjectAnimator.ofFloat(proxy.view, "alpha", 0));
    }
    disappearingSet.setDuration(oldCellsRemovalAnimationDuration);
    disappearingSet.setStartDelay(oldCellsRemovalAnimationStartDelay);
    if (animateIndividualCellsSequentially)
        disappearingSet.playSequentially(fades);
    else
        disappearingSet.playTogether(fades);
    return disappearingSet;
}
Also used : 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)

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