/** Sets the touchable region of this popup to be the area occupied by its content. */
 private void setContentAreaAsTouchableSurface() {
   if (!mPopupWindow.isShowing()) {
     mContentContainer.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
   }
   int width = mContentContainer.getMeasuredWidth();
   int height = mContentContainer.getMeasuredHeight();
   mTouchableRegion.set(
       (int) mContentContainer.getX(),
       (int) mContentContainer.getY(),
       (int) mContentContainer.getX() + width,
       (int) mContentContainer.getY() + height);
 }
Exemplo n.º 2
0
 @Override
 /**
  * Determines where in the ActionBar various views should go. Gives priority to HIGH Priority
  * buttons, then the title, then LOW Priority buttons. If the title won't fit, force it to by
  * cutting off excess. If any buttons won't fit, move them to the OverflowMenu. *
  */
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
   if (mLayoutFinished && mNeedsLayout) {
     mController.onMeasure(
         mControllerContainer.getMeasuredWidth(), mControllerContainer.getMeasuredHeight());
     mNeedsLayout = false;
   }
 }
Exemplo n.º 3
0
 /**
  * Find the view touching the bottom of this ViewGroup. Non visible children are ignored, however
  * getChildDrawingOrder is not taking into account for simplicity and because it behaves
  * inconsistently across platform versions.
  *
  * @return View touching the bottom of this ViewGroup or null
  */
 @Nullable
 private static View getBottomView(ViewGroup viewGroup) {
   if (viewGroup == null || viewGroup.getChildCount() == 0) return null;
   View bottomView = null;
   for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
     View child = viewGroup.getChildAt(i);
     if (child.getVisibility() == View.VISIBLE
         && child.getBottom() == viewGroup.getMeasuredHeight()) {
       bottomView = child;
       break;
     }
   }
   return bottomView;
 }
Exemplo n.º 4
0
    public void onto(final ViewGroup target) {
      factor.width = target.getMeasuredWidth();
      factor.height = target.getMeasuredHeight();

      if (async) {
        BlurTask task =
            new BlurTask(
                target,
                factor,
                new BlurTask.Callback() {
                  @Override
                  public void done(BitmapDrawable drawable) {
                    addView(target, drawable);
                  }
                });
        task.execute();
      } else {
        Drawable drawable = new BitmapDrawable(context.getResources(), Blur.rs(target, factor));
        addView(target, drawable);
      }
    }
 /**
  * Returns how big this panel's view should be. This method should only be called when the view
  * has not been attached to a parent otherwise it will throw an illegal state.
  */
 public Size measure() throws IllegalStateException {
   Preconditions.checkState(mContentView.getParent() == null);
   mContentView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
   return new Size(mContentView.getMeasuredWidth(), mContentView.getMeasuredHeight());
 }
 @Override
 @NonNull
 protected Animator getAnimator(@NonNull final ViewGroup parent, @NonNull final View view) {
   return ObjectAnimator.ofFloat(view, TRANSLATION_Y, parent.getMeasuredHeight() >> 1, 0);
 }
Exemplo n.º 7
0
  public void createTopBarElements() {
    // 1. Create view groups and controls
    statusBar = createStatusBar();
    statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));

    lanesControl = createLanesControl();
    lanesControl.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_free));

    rightStack = new MapStackControl(view.getContext());
    rightStack.addStackView(createAltitudeControl());
    rightStack.addStackView(createDistanceControl());
    rightStack.addCollapsedView(createSpeedControl());
    rightStack.addCollapsedView(createTimeControl());

    leftStack = new MapStackControl(view.getContext());
    leftStack.addStackView(createNextInfoControl());
    leftStack.addStackView(createMiniMapControl());
    leftStack.addStackView(createNextNextInfoControl());
    //		leftStack.addStackView(createAlarmInfoControl());

    // 2. Preparations
    Rect topRectPadding = new Rect();
    view.getResources().getDrawable(R.drawable.box_top).getPadding(topRectPadding);

    STATUS_BAR_MARGIN_X = (int) (STATUS_BAR_MARGIN_X * scaleCoefficient);
    statusBar.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
    Rect statusBarPadding = new Rect();
    statusBar.getBackground().getPadding(statusBarPadding);
    // 3. put into frame parent layout controls
    FrameLayout parent = (FrameLayout) view.getParent();
    // status bar hides own top part
    int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom;
    // we want that status bar lays over map stack controls
    topMargin -= topRectPadding.top;

    FrameLayout.LayoutParams flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.RIGHT);
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    rightStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.CENTER_HORIZONTAL | Gravity.TOP);
    flp.topMargin = (int) (topMargin + scaleCoefficient * 8);
    lanesControl.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.LEFT);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = topMargin;
    leftStack.setLayoutParams(flp);

    flp =
        new FrameLayout.LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
            Gravity.TOP);
    flp.leftMargin = STATUS_BAR_MARGIN_X;
    flp.rightMargin = STATUS_BAR_MARGIN_X;
    flp.topMargin = -topRectPadding.top;
    statusBar.setLayoutParams(flp);

    parent.addView(rightStack);
    parent.addView(leftStack);
    parent.addView(statusBar);
    parent.addView(lanesControl);
  }