@Override
 public void onLayoutChange(
     View v,
     int left,
     int top,
     int right,
     int bottom,
     int oldLeft,
     int oldTop,
     int oldRight,
     int oldBottom) {
   v.removeOnLayoutChangeListener(this); // Unregister self.
   addSearchFragment();
 }
Ejemplo n.º 2
0
  /**
   * Set the view that acts as the anchor for the control view. This can for example be a VideoView,
   * or your Activity's main view.
   *
   * @param view The view to which to anchor the controller when it is visible.
   */
  public void setAnchorView(View view) {
    if (mAnchor != null) {
      mAnchor.removeOnLayoutChangeListener(mLayoutChangeListener);
    }
    mAnchor = view;
    if (mAnchor != null) {
      mAnchor.addOnLayoutChangeListener(mLayoutChangeListener);
    }

    FrameLayout.LayoutParams frameParams =
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    removeAllViews();
    View v = makeControllerView();
    addView(v, frameParams);
  }
Ejemplo n.º 3
0
 /*package*/ void removeViewWithSubviewClippingEnabled(View view) {
   Assertions.assertCondition(mRemoveClippedSubviews);
   Assertions.assertNotNull(mClippingRect);
   Assertions.assertNotNull(mAllChildren);
   view.removeOnLayoutChangeListener(mChildrenLayoutChangeListener);
   int index = indexOfChildInAllChildren(view);
   if (mAllChildren[index].getParent() != null) {
     int clippedSoFar = 0;
     for (int i = 0; i < index; i++) {
       if (mAllChildren[i].getParent() == null) {
         clippedSoFar++;
       }
     }
     super.removeViewsInLayout(index - clippedSoFar, 1);
   }
   removeFromArray(index);
 }
Ejemplo n.º 4
0
  private void dismissSheet(Runnable runAfterDismissThis) {
    if (state == State.HIDDEN) {
      runAfterDismiss = null;
      return;
    }
    // This must be set every time, including if the parameter is null
    // Otherwise a new sheet might be shown when the caller called dismiss after a showWithSheet
    // call, which would be
    runAfterDismiss = runAfterDismissThis;
    final View sheetView = getSheetView();
    sheetView.removeOnLayoutChangeListener(sheetViewOnLayoutChangeListener);
    cancelCurrentAnimation();
    ObjectAnimator anim = ObjectAnimator.ofFloat(this, SHEET_TRANSLATION, 0);
    anim.setDuration(ANIMATION_DURATION);
    anim.setInterpolator(animationInterpolator);
    anim.addListener(
        new CancelDetectionAnimationListener() {
          @Override
          public void onAnimationEnd(Animator animation) {
            if (!canceled) {
              currentAnimator = null;
              setState(State.HIDDEN);
              setSheetLayerTypeIfEnabled(LAYER_TYPE_NONE);
              removeView(sheetView);

              for (OnSheetDismissedListener onSheetDismissedListener : onSheetDismissedListeners) {
                onSheetDismissedListener.onDismissed(BottomSheetLayout.this);
              }

              // Remove sheet specific properties
              viewTransformer = null;
              onSheetDismissedListeners.clear();
              onSheetStateChangeListeners.clear();
              if (runAfterDismiss != null) {
                runAfterDismiss.run();
                runAfterDismiss = null;
              }
            }
          }
        });
    anim.start();
    currentAnimator = anim;
    sheetStartX = 0;
    sheetEndX = screenWidth;
  }