List of usage examples for android.view WindowInsets getSystemWindowInsetRight
public int getSystemWindowInsetRight()
From source file:com.nightlynexus.dire.widget.ScrimInsetsFrameLayout.java
@TargetApi(Build.VERSION_CODES.KITKAT_WATCH) @Override//from w w w . jav a2 s .com 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 w w .ja v a 2 s.c o 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 w w .jav a2 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: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/* ww w . java 2 s . 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 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 a va2 s. 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//from w w w . j av a 2s . co 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: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/*from w w w . j av a2s . c o m*/ 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: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 w w w.j a va 2 s.c om*/ } 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: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);/*from w w w . ja v a 2 s .c o 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(); }
From source file:us.phyxsi.gameshelf.ui.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); ButterKnife.bind(this); drawer.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); setActionBar(toolbar);//from w w w . j a v a2 s . c o m if (savedInstanceState == null) { animateToolbar(); } bggPrefs = BGGPrefs.get(this); dataManager = new DataManager(this) { @Override public void onDataLoaded(List<? extends Boardgame> data) { adapter.addAndResort(data); checkEmptyState(); } }; adapter = new FeedAdapter(this, HomeActivity.this, dataManager, columns); grid.setAdapter(adapter); layoutManager = new GridLayoutManager(this, columns); layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { return adapter.getItemColumnSpan(position); } }); grid.setLayoutManager(layoutManager); grid.addOnScrollListener(gridScroll); // grid.addOnScrollListener(new InfiniteScrollListener(layoutManager) { // @Override // public void onLoadMore() { // // TODO: Load more items // } // }); grid.setHasFixedSize(true); // drawer layout treats fitsSystemWindows specially so we have to handle insets ourselves drawer.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { // inset the toolbar down by the status bar height ViewGroup.MarginLayoutParams lpToolbar = (ViewGroup.MarginLayoutParams) toolbar.getLayoutParams(); lpToolbar.topMargin += insets.getSystemWindowInsetTop(); lpToolbar.rightMargin += insets.getSystemWindowInsetRight(); toolbar.setLayoutParams(lpToolbar); // inset the grid top by statusbar+toolbar & the bottom by the navbar (don't clip) grid.setPadding(grid.getPaddingLeft(), insets.getSystemWindowInsetTop() + ViewUtils.getActionBarSize(HomeActivity.this), grid.getPaddingRight() + insets.getSystemWindowInsetRight(), // landscape grid.getPaddingBottom()); // inset the fab for the navbar ViewGroup.MarginLayoutParams lpFab = (ViewGroup.MarginLayoutParams) fab.getLayoutParams(); lpFab.bottomMargin += insets.getSystemWindowInsetBottom(); // portrait lpFab.rightMargin += insets.getSystemWindowInsetRight(); // landscape fab.setLayoutParams(lpFab); // we place a background behind the status bar to combine with it's semi-transparent // color to get the desired appearance. Set it's height to the status bar height View statusBarBackground = findViewById(R.id.status_bar_background); FrameLayout.LayoutParams lpStatus = (FrameLayout.LayoutParams) statusBarBackground .getLayoutParams(); lpStatus.height = insets.getSystemWindowInsetTop(); statusBarBackground.setLayoutParams(lpStatus); // clear this listener so insets aren't re-applied drawer.setOnApplyWindowInsetsListener(null); return insets.consumeSystemWindowInsets(); } }); setupTaskDescription(); dataManager.loadFromDatabase(); checkEmptyState(); checkConnectivity(); }