Beispiel #1
0
  /** Updates the min and max virtual scroll bounds */
  void updateMinMaxScroll(
      boolean boundScrollToNewMinMax, boolean launchedWithAltTab, boolean launchedFromHome) {
    // Compute the min and max scroll values
    mLayoutAlgorithm.computeMinMaxScroll(mCallback.getData(), launchedWithAltTab, launchedFromHome);

    // Debug logging
    if (true) {
      mStackScroller.boundScroll();
    }
  }
Beispiel #2
0
  public void notifyDataSetChanged() {
    // Get the stack scroll of the task to anchor to (since we are removing something, the front
    // most task will be our anchor task)
    T anchorTask = null;
    float prevAnchorTaskScroll = 0;
    boolean pullStackForward = mCallback.getData().size() > 0;
    if (pullStackForward) {
      anchorTask = mCallback.getData().get(mCallback.getData().size() - 1);
      prevAnchorTaskScroll = mLayoutAlgorithm.getStackScrollForTask(anchorTask);
    }

    // Update the min/max scroll and animate other task views into their new positions
    updateMinMaxScroll(true, mConfig.launchedWithAltTab, mConfig.launchedFromHome);

    // Offset the stack by as much as the anchor task would otherwise move back
    if (pullStackForward) {
      float anchorTaskScroll = mLayoutAlgorithm.getStackScrollForTask(anchorTask);
      mStackScroller.setStackScroll(
          mStackScroller.getStackScroll() + (anchorTaskScroll - prevAnchorTaskScroll));
      mStackScroller.boundScroll();
    }

    // Animate all the tasks into place
    requestSynchronizeStackViewsWithModel(200);

    T newFrontMostTask =
        mCallback.getData().size() > 0
            ? mCallback.getData().get(mCallback.getData().size() - 1)
            : null;
    // Update the new front most task
    if (newFrontMostTask != null) {
      DeckChildView<T> frontTv = getChildViewForTask(newFrontMostTask);
      if (frontTv != null) {
        frontTv.onTaskBound(newFrontMostTask);
      }
    }

    // If there are no remaining tasks
    if (mCallback.getData().size() == 0) {
      mCallback.onNoViewsToDeck();
    }
  }