Example usage for android.view WindowInsets getSystemWindowInsetBottom

List of usage examples for android.view WindowInsets getSystemWindowInsetBottom

Introduction

In this page you can find the example usage for android.view WindowInsets getSystemWindowInsetBottom.

Prototype

public int getSystemWindowInsetBottom() 

Source Link

Document

Returns the bottom system window inset in pixels.

Usage

From source file:com.nightlynexus.dire.widget.ScrimInsetsFrameLayout.java

@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
@Override//from  www.  jav a 2  s  .c o  m
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    mInsets = new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
            insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());
    setWillNotDraw(mInsetForeground == null);
    ViewCompat.postInvalidateOnAnimation(this);
    if (mOnInsetsCallback != null) {
        mOnInsetsCallback.onInsetsChanged(mInsets);
    }
    return insets;
}

From source file:com.github.shareme.gwsmaterialdrawer.library.widget.ScrimInsetsScrollView.java

@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
@Override/*from w ww .  jav a2s  .  co  m*/
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    insets = super.onApplyWindowInsets(insets);
    handleWindowInsets(new Rect(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
            insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom()));
    return insets;
}

From source file:com.facebook.react.modules.statusbar.StatusBarModule.java

@ReactMethod
public void setTranslucent(final boolean translucent, final Promise res) {
    final Activity activity = getCurrentActivity();
    if (activity == null) {
        res.reject(ERROR_NO_ACTIVITY, ERROR_NO_ACTIVITY_MESSAGE);
        return;/*w  ww.ja  v  a 2  s  . c  om*/
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        UiThreadUtil.runOnUiThread(new Runnable() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void run() {
                // If the status bar is translucent hook into the window insets calculations
                // and consume all the top insets so no padding will be added under the status bar.
                View decorView = activity.getWindow().getDecorView();
                if (translucent) {
                    decorView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
                        @Override
                        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
                            WindowInsets defaultInsets = v.onApplyWindowInsets(insets);
                            return defaultInsets.replaceSystemWindowInsets(
                                    defaultInsets.getSystemWindowInsetLeft(), 0,
                                    defaultInsets.getSystemWindowInsetRight(),
                                    defaultInsets.getSystemWindowInsetBottom());
                        }
                    });
                } else {
                    decorView.setOnApplyWindowInsetsListener(null);
                }

                ViewCompat.requestApplyInsets(decorView);
                res.resolve(null);
            }
        });
    }
}

From source file:fr.outadev.skinswitch.DetailActivity.java

@TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
private void applySystemWindowsBottomInset() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        View containerView = findViewById(R.id.container);
        containerView.setFitsSystemWindows(true);

        containerView.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

            @Override//w w  w . j  a  v  a 2 s  .  c  om
            public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) {
                DisplayMetrics metrics = getResources().getDisplayMetrics();

                if (metrics.widthPixels < metrics.heightPixels) {
                    view.setPadding(0, 0, 0, windowInsets.getSystemWindowInsetBottom());
                } else {
                    view.setPadding(0, 0, windowInsets.getSystemWindowInsetRight(), 0);
                }

                return windowInsets.consumeSystemWindowInsets();
            }

        });
    }
}

From source file:com.example.android.xyztouristattractions.ui.ShopsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    final FrameLayout topFrameLayout = (FrameLayout) findViewById(R.id.topFrameLayout);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mGridViewPager = (GridViewPager) findViewById(R.id.gridViewPager);
    mDotsPageIndicator = (DotsPageIndicator) findViewById(R.id.dotsPageIndicator);
    mAdapter = new ShopsGridPagerAdapter(this, mShops);
    mAdapter.setOnChromeFadeListener(this);
    mGridViewPager.setAdapter(mAdapter);
    mDotsPageIndicator.setPager(mGridViewPager);
    mDotsPageIndicator.setOnPageChangeListener(mAdapter);

    topFrameLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override//from  w  ww  .j  av  a  2 s. c  om
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // Call through to super implementation
            insets = topFrameLayout.onApplyWindowInsets(insets);

            boolean round = insets.isRound();

            // Store system window insets regardless of screen shape
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());

            if (round) {
                // On a round screen calculate the square inset to use.
                // Alternatively could use BoxInsetLayout, although calculating
                // the inset ourselves lets us position views outside the center
                // box. For example, slightly lower on the round screen (by giving
                // up some horizontal space).
                mInsets = Utils.calculateBottomInsetsOnRoundDevice(getWindowManager().getDefaultDisplay(),
                        mInsets);

                // Boost the dots indicator up by the bottom inset
                FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mDotsPageIndicator
                        .getLayoutParams();
                params.bottomMargin = mInsets.bottom;
                mDotsPageIndicator.setLayoutParams(params);
            }

            mAdapter.setInsets(mInsets);
            return insets;
        }
    });

    // Set up the DismissOverlayView
    mDismissOverlayView = (DismissOverlayView) findViewById(R.id.dismiss_overlay);
    mDismissOverlayView.setIntroText(getString(R.string.exit_intro_text));
    mDismissOverlayView.showIntroIfNecessary();
    mGestureDetector = new GestureDetectorCompat(this, new LongPressListener());

    Uri shopsUri = getIntent().getParcelableExtra(Constants.EXTRA_SHOPS_URI);
    if (shopsUri != null) {
        new FetchDataAsyncTask(this).execute(shopsUri);
        UtilityService.clearNotification(this);
        UtilityService.clearRemoteNotifications(this);
    } else {
        finish();
    }
}

From source file:com.example.android.xyztouristattractions.ui.AttractionsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    final FrameLayout topFrameLayout = (FrameLayout) findViewById(R.id.topFrameLayout);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mGridViewPager = (GridViewPager) findViewById(R.id.gridViewPager);
    mDotsPageIndicator = (DotsPageIndicator) findViewById(R.id.dotsPageIndicator);
    mAdapter = new AttractionsGridPagerAdapter(this, mAttractions);
    mAdapter.setOnChromeFadeListener(this);
    mGridViewPager.setAdapter(mAdapter);

    topFrameLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override//from w w  w .  j av  a 2s.c  o m
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // Call through to super implementation
            insets = topFrameLayout.onApplyWindowInsets(insets);

            boolean round = insets.isRound();

            // Store system window insets regardless of screen shape
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());

            if (round) {
                // On a round screen calculate the square inset to use.
                // Alternatively could use BoxInsetLayout, although calculating
                // the inset ourselves lets us position views outside the center
                // box. For example, slightly lower on the round screen (by giving
                // up some horizontal space).
                mInsets = Utils.calculateBottomInsetsOnRoundDevice(getWindowManager().getDefaultDisplay(),
                        mInsets);

                // Boost the dots indicator up by the bottom inset
                FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mDotsPageIndicator
                        .getLayoutParams();
                params.bottomMargin = mInsets.bottom;
                mDotsPageIndicator.setLayoutParams(params);
            }

            mAdapter.setInsets(mInsets);
            return insets;
        }
    });

    // Set up the DismissOverlayView
    mDismissOverlayView = (DismissOverlayView) findViewById(R.id.dismiss_overlay);
    mDismissOverlayView.setIntroText(getString(R.string.exit_intro_text));
    mDismissOverlayView.showIntroIfNecessary();
    mGestureDetector = new GestureDetectorCompat(this, new LongPressListener());

    Uri attractionsUri = getIntent().getParcelableExtra(Constants.EXTRA_ATTRACTIONS_URI);
    if (attractionsUri != null) {
        new FetchDataAsyncTask(this).execute(attractionsUri);
        UtilityService.clearNotification(this);
        UtilityService.clearRemoteNotifications(this);
    } else {
        finish();
    }
}

From source file:com.asburymotors.android.disneysocal.ui.AttractionsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);
    final FrameLayout topFrameLayout = (FrameLayout) findViewById(R.id.topFrameLayout);
    mProgressBar = (ProgressBar) findViewById(R.id.progressBar);
    mGridViewPager = (GridViewPager) findViewById(R.id.gridViewPager);
    mDotsPageIndicator = (DotsPageIndicator) findViewById(R.id.dotsPageIndicator);
    mAdapter = new AttractionsGridPagerAdapter(this, mAttractions);
    mAdapter.setOnChromeFadeListener(this);
    mGridViewPager.setAdapter(mAdapter);
    mDotsPageIndicator.setPager(mGridViewPager);
    mDotsPageIndicator.setOnPageChangeListener(mAdapter);

    topFrameLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override//  w  w w.  j a  v  a  2 s .com
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            // Call through to super implementation
            insets = topFrameLayout.onApplyWindowInsets(insets);

            boolean round = insets.isRound();

            // Store system window insets regardless of screen shape
            mInsets.set(insets.getSystemWindowInsetLeft(), insets.getSystemWindowInsetTop(),
                    insets.getSystemWindowInsetRight(), insets.getSystemWindowInsetBottom());

            if (round) {
                // On a round screen calculate the square inset to use.
                // Alternatively could use BoxInsetLayout, although calculating
                // the inset ourselves lets us position views outside the center
                // box. For example, slightly lower on the round screen (by giving
                // up some horizontal space).
                mInsets = Utils.calculateBottomInsetsOnRoundDevice(getWindowManager().getDefaultDisplay(),
                        mInsets);

                // Boost the dots indicator up by the bottom inset
                FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mDotsPageIndicator
                        .getLayoutParams();
                params.bottomMargin = mInsets.bottom;
                mDotsPageIndicator.setLayoutParams(params);
            }

            mAdapter.setInsets(mInsets);
            return insets;
        }
    });

    // Set up the DismissOverlayView
    mDismissOverlayView = (DismissOverlayView) findViewById(R.id.dismiss_overlay);
    mDismissOverlayView.setIntroText(getString(R.string.exit_intro_text));
    mDismissOverlayView.showIntroIfNecessary();
    mGestureDetector = new GestureDetectorCompat(this, new LongPressListener());

    Uri attractionsUri = getIntent().getParcelableExtra(Constants.EXTRA_ATTRACTIONS_URI);
    if (attractionsUri != null) {
        new FetchDataAsyncTask(this).execute(attractionsUri);
        UtilityService.clearNotification(this);
        UtilityService.clearRemoteNotifications(this);
    } else {
        finish();
    }
}

From source file:io.plaidapp.ui.PlayerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_dribbble_player);
    ButterKnife.bind(this);
    circleTransform = new CircleTransform(this);
    chromeFader = new ElasticDragDismissFrameLayout.SystemChromeFader(this);

    final Intent intent = getIntent();
    if (intent.hasExtra(EXTRA_PLAYER)) {
        player = intent.getParcelableExtra(EXTRA_PLAYER);
        bindPlayer();//from www.ja  va 2  s.co m
    } else if (intent.hasExtra(EXTRA_PLAYER_NAME)) {
        String name = intent.getStringExtra(EXTRA_PLAYER_NAME);
        playerName.setText(name);
        if (intent.hasExtra(EXTRA_PLAYER_ID)) {
            long userId = intent.getLongExtra(EXTRA_PLAYER_ID, 0L);
            loadPlayer(userId);
        } else if (intent.hasExtra(EXTRA_PLAYER_USERNAME)) {
            String username = intent.getStringExtra(EXTRA_PLAYER_USERNAME);
            loadPlayer(username);
        }
    } else if (intent.getData() != null) {
        // todo support url intents
    }

    // setup immersive mode i.e. draw behind the system chrome & adjust insets
    draggableFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
            | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    draggableFrame.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            final ViewGroup.MarginLayoutParams lpFrame = (ViewGroup.MarginLayoutParams) draggableFrame
                    .getLayoutParams();
            lpFrame.leftMargin += insets.getSystemWindowInsetLeft(); // landscape
            lpFrame.rightMargin += insets.getSystemWindowInsetRight(); // landscape
            ((ViewGroup.MarginLayoutParams) avatar.getLayoutParams()).topMargin += insets
                    .getSystemWindowInsetTop();
            ViewUtils.setPaddingTop(container, insets.getSystemWindowInsetTop());
            ViewUtils.setPaddingBottom(shots, insets.getSystemWindowInsetBottom());
            // clear this listener so insets aren't re-applied
            draggableFrame.setOnApplyWindowInsetsListener(null);
            return insets;
        }
    });
    setExitSharedElementCallback(FeedAdapter.createSharedElementReenterCallback(this));
}

From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java

@Override
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    mSystemWindowInsetBottom = insets.getSystemWindowInsetBottom();

    if (mSystemWindowInsetBottom != 0) {
        MarginLayoutParams layoutParams = (MarginLayoutParams) getLayoutParams();
        layoutParams.bottomMargin = mSystemWindowInsetBottom;
        setLayoutParams(layoutParams);//from  w  ww.  j  av  a 2s . co m
    }

    return super.onApplyWindowInsets(insets);
}

From source file:liam.franco.selene.activities.AboutActivity.java

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);
    ButterKnife.bind(this);
    App.BUS.register(this);

    setSupportActionBar(toolbar);//  ww w .j a  v  a2 s.  co  m
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
    }

    UIUtils.setTranslucentNavigationFlag(this, true);
    UIUtils.setTranslucentStatusFlag(this, true);

    parentLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
            | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);

    parentLayout.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
        @Override
        public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
            int navBarHeight = UIUtils.getNavigationBarHeight(App.CONTEXT);

            // 1 = portrait, 2 = landscape
            int orientation = App.RESOURCES.getConfiguration().orientation;

            ViewGroup.MarginLayoutParams bar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams();
            bar.topMargin += insets.getSystemWindowInsetTop();
            bar.rightMargin += insets.getSystemWindowInsetRight();
            toolbar.setLayoutParams(bar);

            // making sure it's all inside bounds because of our transparent status and nav bars
            scrollableLayout.setPadding(scrollableLayout.getPaddingLeft(), scrollableLayout.getPaddingTop(),
                    scrollableLayout.getPaddingRight()
                            + (orientation == 1 ? insets.getSystemWindowInsetRight() : navBarHeight),
                    scrollableLayout.getPaddingBottom()
                            + (orientation == 1 ? navBarHeight : insets.getSystemWindowInsetBottom()));

            parentLayout.setOnApplyWindowInsetsListener(null);
            return insets.consumeSystemWindowInsets();
        }
    });

    liamList.addItemDecoration(new SimpleDividerItemDecoration(this));
    liamAdapter = new FastItemAdapter<>();
    liamList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    liamList.setAdapter(liamAdapter);

    franciscoList.addItemDecoration(new SimpleDividerItemDecoration(this));
    franciscoAdapter = new FastItemAdapter<>();
    franciscoList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    franciscoList.setAdapter(franciscoAdapter);

    libsList.addItemDecoration(new SimpleDividerItemDecoration(this));
    libsAdapter = new FastItemAdapter<>();
    libsList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    libsList.setAdapter(libsAdapter);

    mutateMoreList.addItemDecoration(new SimpleDividerItemDecoration(this));
    mutateMoreAdapter = new FastItemAdapter<>();
    mutateMoreList.setLayoutManager(new UnscrollableLinearLayoutManager(this));
    mutateMoreList.setAdapter(mutateMoreAdapter);

    initAboutEntries();
}