By what i can replace ViewTreeObserver.OnComputeInternalInsetsListener that is declared as hidden?

456 views Asked by At

I try to import in my library some android internal source code. however i have some trouble to import this part of code :

    private final ViewTreeObserver.OnComputeInternalInsetsListener mInsetsComputer =
            new ViewTreeObserver.OnComputeInternalInsetsListener() {
                public void onComputeInternalInsets(
                        ViewTreeObserver.InternalInsetsInfo info) {
                    info.contentInsets.setEmpty();
                    info.visibleInsets.setEmpty();
                    info.touchableRegion.set(mTouchableRegion);
                    info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo
                            .TOUCHABLE_INSETS_REGION);
                }
            };

it's because in ViewTreeObserver.java OnComputeInternalInsetsListener is declared as hidden

/**
 * Interface definition for a callback to be invoked when layout has
 * completed and the client can compute its interior insets.
 * 
 * We are not yet ready to commit to this API and support it, so
 * @hide
 */
public interface OnComputeInternalInsetsListener {
    /**
     * Callback method to be invoked when layout has completed and the
     * client can compute its interior insets.
     *
     * @param inoutInfo Should be filled in by the implementation with
     * the information about the insets of the window.  This is called
     * with whatever values the previous OnComputeInternalInsetsListener
     * returned, if there are multiple such listeners in the window.
     */
    public void onComputeInternalInsets(InternalInsetsInfo inoutInfo);
} 

later i use it like this

    /**
     * Make the touchable area of this popup be the area specified by mTouchableRegion.
     * This should be called after the popup window has been dismissed (dismiss/hide)
     * and is probably being re-shown with a new content root view.
     */
    private void setTouchableSurfaceInsetsComputer() {

        ViewTreeObserver viewTreeObserver = mPopupWindow.getContentView()
                .getRootView()
                .getViewTreeObserver();
        viewTreeObserver.removeOnComputeInternalInsetsListener(mInsetsComputer);
        viewTreeObserver.addOnComputeInternalInsetsListener(mInsetsComputer);

    }

so by what i can replace ViewTreeObserver.OnComputeInternalInsetsListener, removeOnComputeInternalInsetsListener and addOnComputeInternalInsetsListener ? i don't even know the purpose of these functions ...

0

There are 0 answers