/** This is called with the full size of the window since we are handling our own insets. */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    // Get the search bar bounds and measure the search bar layout
    if (mSearchBar != null) {
      Rect searchBarSpaceBounds = new Rect();
      mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
      mSearchBar.measure(
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY));
    }

    Rect taskStackBounds = new Rect();
    mConfig.getTaskStackBounds(
        width, height, mConfig.systemInsets.top, mConfig.systemInsets.right, taskStackBounds);

    // Measure each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
      View child = getChildAt(i);
      if (child != mSearchBar && child.getVisibility() != GONE) {
        TaskStackView tsv = (TaskStackView) child;
        // Set the insets to be the top/left inset + search bounds
        tsv.setStackInsetRect(taskStackBounds);
        tsv.measure(widthMeasureSpec, heightMeasureSpec);
      }
    }

    setMeasuredDimension(width, height);
  }
Beispiel #2
0
  /** This is called with the full size of the window since we are handling our own insets. */
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Log.d(TAG, "onMeasure: ");
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    // Get the search bar bounds and measure the search bar layout
    Rect searchBarSpaceBounds = new Rect();
    if (mSearchBar != null) {
      mConfig.getSearchBarBounds(width, height, mConfig.systemInsets.top, searchBarSpaceBounds);
      mSearchBar.measure(
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.width(), MeasureSpec.EXACTLY),
          MeasureSpec.makeMeasureSpec(searchBarSpaceBounds.height(), MeasureSpec.EXACTLY));
    }

    Rect taskStackBounds = new Rect();
    mConfig.getAvailableTaskStackBounds(
        width,
        height,
        mConfig.systemInsets.top,
        mConfig.systemInsets.right,
        searchBarSpaceBounds,
        taskStackBounds);

    // Measure each TaskStackView with the full width and height of the window since the
    // transition view is a child of that stack view
    List<TaskStackView> stackViews = getTaskStackViews();
    List<Rect> stackViewsBounds = mLayoutAlgorithm.computeStackRects(stackViews, taskStackBounds);
    int stackCount = stackViews.size();
    for (int i = 0; i < stackCount; i++) {
      TaskStackView stackView = stackViews.get(i);
      if (stackView.getVisibility() != GONE) {
        // We are going to measure the TaskStackView with the whole RecentsView dimensions,
        // but the actual stack is going to be inset to the bounds calculated by the layout
        // algorithm
        stackView.setStackInsetRect(stackViewsBounds.get(i));
        stackView.measure(widthMeasureSpec, heightMeasureSpec);
      }
    }

    setMeasuredDimension(width, height);
  }