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

The following examples show how to use android.view.View#dispatchApplyWindowInsets() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: scene   File: CompatSceneLayout.java    License: 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
@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
@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 Project: letv   File: ViewCompatLollipop.java    License: 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
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 Project: Dashchan   File: DrawerLayout.java    License: 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
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
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
@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 Project: u2020   File: DrawerLayoutCompatApi21.java    License: 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 Project: cathode   File: CatchSystemInsets.java    License: 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
@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);
}