car/src/main/java/androidx/car/app/CarAlertDialog.java
private void updateTargetTargetForButton(View button) {
        if (button != mPositiveButton && button != mNegativeButton) {
            throw new IllegalArgumentException("Method must be passed one of mPositiveButton or "
                    + "mNegativeButton");
        }

        if (button.getVisibility() != View.VISIBLE) {
            return;
        }

        // The TouchDelegate needs to be set after the panel has been laid out in order to get the
        // hit Rect.
        mButtonPanel.post(() -> {
            Rect rect = new Rect();
            button.getHitRect(rect);

            int hitWidth = Math.abs(rect.right - rect.left);

            TouchDelegate touchDelegate = null;

            // If the button does not meet the minimum requirements for touch target size, then
            // expand its hit area with a TouchDelegate.
            if (hitWidth < mButtonMinWidth) {
                int amountToIncrease = (mButtonMinWidth - hitWidth) / 2;
                rect.left -= amountToIncrease;
                rect.right += amountToIncrease;

                touchDelegate = new TouchDelegate(rect, button);
            }

            if (button == mPositiveButton) {
                mButtonPanelTouchDelegate.setPositiveButtonDelegate(touchDelegate);
            } else {
                mButtonPanelTouchDelegate.setNegativeButtonDelegate(touchDelegate);
            }
        });
    }
/**
     * Checks if the given view that represents a positive or negative button currently meets the
     * minimum touch target size that is dictated by {@link #mButtonMinWidth}. If it does not, then
     * this method will utilize a {@link TouchDelegate} to expand the touch target size of that
     * button.
     *
     * @param button One of {@link #mPositiveButton} or {@link #mNegativeButton}.
     */
Checks if the given view that represents a positive or negative button currently meets the
minimum touch target size that is dictated by  #mButtonMinWidth. If it does not, then
this method will utilize a  TouchDelegate to expand the touch target size of that
button.

@param button One of  #mPositiveButton or  #mNegativeButton.
Checks if the given view that represents a positive or negative button currently meets the minimum touch target size that is dictated by #mButtonMinWidth . If it does not then this method will utilize a TouchDelegate to expand the touch target size of that button . @param button One of #mPositiveButton or #mNegativeButton .
private void updateTargetTargetForButton(View button) {
        if (button != mPositiveButton && button != mNegativeButton) {
            throw new IllegalArgumentException("Method must be passed one of mPositiveButton or "
                    + "mNegativeButton");
        }
        if (button.getVisibility() != View.VISIBLE) {
            return;
        }
        mButtonPanel.post(() -> {
            Rect rect = new Rect();
            button.getHitRect(rect);
            int hitWidth = Math.abs(rect.right - rect.left);
            TouchDelegate touchDelegate = null;
            if (hitWidth < mButtonMinWidth) {
                int amountToIncrease = (mButtonMinWidth - hitWidth) / 2;
                rect.left -= amountToIncrease;
                rect.right += amountToIncrease;
                touchDelegate = new TouchDelegate(rect, button);
            }
            if (button == mPositiveButton) {
                mButtonPanelTouchDelegate.setPositiveButtonDelegate(touchDelegate);
            } else {
                mButtonPanelTouchDelegate.setNegativeButtonDelegate(touchDelegate);
            }
        });
    }
private void updateTargetTargetForButton ( View button ) { if ( button != mPositiveButton && button != mNegativeButton ) { throw new IllegalArgumentException ( "Method must be passed one of mPositiveButton or " + "mNegativeButton" ) ; } if ( button . getVisibility ( ) != View . VISIBLE ) { return ; } mButtonPanel . post ( ( ) -> { Rect rect = new Rect ( ) ; button . getHitRect ( rect ) ; int hitWidth = Math . abs ( rect . right - rect . left ) ; TouchDelegate touchDelegate = null ; if ( hitWidth < mButtonMinWidth ) { int amountToIncrease = ( mButtonMinWidth - hitWidth ) / 2 ; rect . left -= amountToIncrease ; rect . right += amountToIncrease ; touchDelegate = new TouchDelegate ( rect , button ) ; } if ( button == mPositiveButton ) { mButtonPanelTouchDelegate . setPositiveButtonDelegate ( touchDelegate ) ; } else { mButtonPanelTouchDelegate . setNegativeButtonDelegate ( touchDelegate ) ; } } ) ; }
Checks if the given view that represents a positive or negative button currently meets the
 minimum touch target size that is dictated by {@link #mButtonMinWidth}.
Checks if the given view that represents a positive or negative button currently meets the minimum touch target size that is dictated by { @link #mButtonMinWidth } .
// The TouchDelegate needs to be set after the panel has been laid out in order to get the // hit Rect. // If the button does not meet the minimum requirements for touch target size, then // expand its hit area with a TouchDelegate.