Exemplo n.º 1
0
  public void getStackScrollState(AmbientState ambientState, StackScrollState resultState) {
    // The state of the local variables are saved in an algorithmState to easily subdivide it
    // into multiple phases.
    Log.d(TAG, "getStackScrollState: ");
    StackScrollAlgorithmState algorithmState = mTempAlgorithmState;

    // First we reset the view states to their default values.
    resultState.resetViewStates();

    algorithmState.itemsInTopStack = 0.0f;
    algorithmState.partialInTop = 0.0f;
    algorithmState.lastTopStackIndex = 0;
    algorithmState.scrolledPixelsTop = 0;
    algorithmState.itemsInBottomStack = 0.0f;
    algorithmState.partialInBottom = 0.0f;
    float bottomOverScroll = ambientState.getOverScrollAmount(false /* onTop */);

    int scrollY = ambientState.getScrollY();

    // Due to the overScroller, the stackscroller can have negative scroll state. This is
    // already accounted for by the top padding and doesn't need an additional adaption
    scrollY = Math.max(0, scrollY);
    algorithmState.scrollY = (int) (scrollY + mCollapsedSize + bottomOverScroll);

    updateVisibleChildren(resultState, algorithmState);

    // Phase 1:
    findNumberOfItemsInTopStackAndUpdateState(resultState, algorithmState, ambientState);

    // Phase 2:
    updatePositionsForState(resultState, algorithmState, ambientState);

    // Phase 3:
    updateZValuesForState(resultState, algorithmState);

    handleDraggedViews(ambientState, resultState, algorithmState);
    updateDimmedActivatedHideSensitive(ambientState, resultState, algorithmState);
    updateClipping(resultState, algorithmState, ambientState);
    updateSpeedBumpState(resultState, algorithmState, ambientState.getSpeedBumpIndex());
    getNotificationChildrenStates(resultState, algorithmState);
  }