Java Code Examples for android.view.View#dispatchApplyWindowInsets()

The following examples show how to use android.view.View#dispatchApplyWindowInsets() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CompatSceneLayout.java    From scene with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) {
    StatusBarView statusBarView = findViewById(R.id.scene_status_bar);
    if (statusBarView != null) {
        if (statusBarView.getParent() != this) {
            throw new IllegalStateException("StatusBarView parent must be " + getClass().getSimpleName());
        }
        insets = statusBarView.dispatchApplyWindowInsets(insets);
    }

    if (insets.isConsumed()) {
        return insets;
    }

    NavigationBarView navigationBarView = findViewById(R.id.scene_navigation_bar);
    if (navigationBarView != null) {
        if (navigationBarView.getParent() != this) {
            throw new IllegalStateException("NavigationBarView parent must be " + getClass().getSimpleName());
        }
        insets = navigationBarView.dispatchApplyWindowInsets(insets);
    }

    if (insets.isConsumed()) {
        return insets;
    }

    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        View childView = getChildAt(i);
        if (childView == statusBarView || childView == navigationBarView) {
            continue;
        }
        insets = childView.dispatchApplyWindowInsets(insets);
        if (insets.isConsumed()) {
            break;
        }
    }
    return insets;
}
 
Example 2
Source File: DrawerLayoutContainer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 3
Source File: DrawerLayoutContainer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity)
{
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT)
    {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    }
    else if (drawerGravity == Gravity.RIGHT)
    {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 4
Source File: ViewCompatLollipop.java    From letv with Apache License 2.0 5 votes vote down vote up
public static WindowInsetsCompat dispatchApplyWindowInsets(View v, WindowInsetsCompat insets) {
    if (!(insets instanceof WindowInsetsCompatApi21)) {
        return insets;
    }
    WindowInsets unwrapped = ((WindowInsetsCompatApi21) insets).unwrap();
    WindowInsets result = v.dispatchApplyWindowInsets(unwrapped);
    if (result != unwrapped) {
        return new WindowInsetsCompatApi21(result);
    }
    return insets;
}
 
Example 5
Source File: DrawerLayoutCompatApi21.java    From 920-text-editor-v2 with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 6
Source File: DrawerLayout.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
@Override
public void dispatchChildInsets(View child, Object insets, int drawerGravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (drawerGravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (drawerGravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	child.dispatchApplyWindowInsets(wi);
}
 
Example 7
Source File: DrawerLayoutCompatApi21.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (gravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
                wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (gravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
                wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 8
Source File: DrawerLayoutCompatApi21.java    From debugdrawer with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
	WindowInsets wi = (WindowInsets) insets;
	if (gravity == Gravity.LEFT) {
		wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
				wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
	} else if (gravity == Gravity.RIGHT) {
		wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
				wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
	}
	child.dispatchApplyWindowInsets(wi);
}
 
Example 9
Source File: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}
 
Example 10
Source File: DrawerLayoutCompatApi21.java    From u2020 with Apache License 2.0 5 votes vote down vote up
public static void dispatchChildInsets(View child, Object insets, int gravity) {
  WindowInsets wi = (WindowInsets) insets;
  if (gravity == Gravity.LEFT) {
    wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(),
        wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
  } else if (gravity == Gravity.RIGHT) {
    wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(),
        wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
  }
  child.dispatchApplyWindowInsets(wi);
}
 
Example 11
Source File: CatchSystemInsets.java    From cathode with Apache License 2.0 5 votes vote down vote up
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  if (insets != null) {
    for (int i = 0, childCount = getChildCount(); i < childCount; i++) {
      View child = getChildAt(i);
      child.dispatchApplyWindowInsets(insets);
    }
  }

  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
 
Example 12
Source File: DrawerLayoutContainer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
    WindowInsets wi = (WindowInsets) insets;
    if (drawerGravity == Gravity.LEFT) {
        wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
    } else if (drawerGravity == Gravity.RIGHT) {
        wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
    }
    child.dispatchApplyWindowInsets(wi);
}