android.support.v4.view.OnApplyWindowInsetsListener Java Examples

The following examples show how to use android.support.v4.view.OnApplyWindowInsetsListener. 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: StatusBarCompatLollipop.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static void setStatusBarColor(Activity activity, int statusColor) {
    Window window = activity.getWindow();
    window.clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
    window.addFlags(Integer.MIN_VALUE);
    window.setStatusBarColor(statusColor);
    window.getDecorView().setSystemUiVisibility(0);
    View mChildView = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
            public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                return insets;
            }
        });
        ViewCompat.setFitsSystemWindows(mChildView, true);
        ViewCompat.requestApplyInsets(mChildView);
    }
}
 
Example #2
Source File: StatusBarCompatLollipop.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
    Window window = activity.getWindow();
    window.addFlags(Integer.MIN_VALUE);
    if (hideStatusBarBackground) {
        window.clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
        window.setStatusBarColor(0);
        window.getDecorView().setSystemUiVisibility(FimiAppContext.UI_HEIGHT);
    } else {
        window.addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
        window.getDecorView().setSystemUiVisibility(0);
    }
    View mChildView = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
            public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                return insets;
            }
        });
        ViewCompat.setFitsSystemWindows(mChildView, false);
        ViewCompat.requestApplyInsets(mChildView);
    }
}
 
Example #3
Source File: StatusBarCompatLollipop.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public static void setStatusBarColorForCollapsingToolbar(Activity activity, AppBarLayout appBarLayout, CollapsingToolbarLayout collapsingToolbarLayout, Toolbar toolbar, int statusColor) {
    Window window = activity.getWindow();
    window.clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
    window.addFlags(Integer.MIN_VALUE);
    window.setStatusBarColor(0);
    window.getDecorView().setSystemUiVisibility(0);
    View mChildView = ((ViewGroup) window.findViewById(16908290)).getChildAt(0);
    if (mChildView != null) {
        ViewCompat.setOnApplyWindowInsetsListener(mChildView, new OnApplyWindowInsetsListener() {
            public WindowInsetsCompat onApplyWindowInsets(View v, WindowInsetsCompat insets) {
                return insets;
            }
        });
        ViewCompat.setFitsSystemWindows(mChildView, true);
        ViewCompat.requestApplyInsets(mChildView);
    }
    ((View) appBarLayout.getParent()).setFitsSystemWindows(true);
    appBarLayout.setFitsSystemWindows(true);
    collapsingToolbarLayout.setFitsSystemWindows(true);
    collapsingToolbarLayout.getChildAt(0).setFitsSystemWindows(true);
    toolbar.setFitsSystemWindows(false);
    collapsingToolbarLayout.setStatusBarScrimColor(statusColor);
}
 
Example #4
Source File: SystemBarMetrics.java    From ShaderEditor with MIT License 6 votes vote down vote up
private static void setWindowInsets(final View mainLayout,
		final Rect windowInsets) {
	ViewCompat.setOnApplyWindowInsetsListener(mainLayout, new OnApplyWindowInsetsListener() {
		@Override
		public WindowInsetsCompat onApplyWindowInsets(View v,
				WindowInsetsCompat insets) {
			if (insets.hasSystemWindowInsets()) {
				int left = insets.getSystemWindowInsetLeft();
				int top = insets.getSystemWindowInsetTop();
				int right = insets.getSystemWindowInsetRight();
				int bottom = insets.getSystemWindowInsetBottom();
				mainLayout.setPadding(left, top, right, bottom);
				if (windowInsets != null) {
					windowInsets.set(left, top, right, bottom);
				}
			}
			return insets.consumeSystemWindowInsets();
		}
	});
}