List of usage examples for android.view WindowInsets isRound
public boolean isRound()
From source file:net.waynepiekarski.screeninfo.MyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my); final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub); mMyOutputManager = new MyOutputManager(this); stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() { @Override//from ww w .ja v a 2 s . c o m public void onLayoutInflated(WatchViewStub stub) { Logging.debug("onLayoutInflated for WatchViewStub"); mTextView = (TextView) stub.findViewById(R.id.text); mOverlayView = (OverlayView) stub.findViewById(R.id.overlay); mDismissOverlayView = (DismissOverlayView) stub.findViewById(R.id.dismiss); mMyOutputManager.setTextView(mTextView); // Recursive add a listener for every View in the hierarchy, this is the only way to get all clicks ListenerHelper.recursiveSetOnClickListener(stub, MyActivity.this); // Prevent display from sleeping getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // Add a listener to handle closing the app on a long press to the activity mDismissOverlayView.setIntroText("Long press to exit"); mDismissOverlayView.showIntroIfNecessary(); mGestureDetector = new GestureDetectorCompat(MyActivity.this, new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { Logging.debug("Detected long press, showing exit overlay"); mDismissOverlayView.show(); } }); // Allow OverlayView to send the Canvas and View dimensions to MyOutputManager mOverlayView.setMyOutputManager(mMyOutputManager); } }); stub.setOnApplyWindowInsetsListener(new WatchViewStub.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View view, WindowInsets windowInsets) { Logging.debug("onApplyWindowInsets for WatchViewStub, round=" + windowInsets.isRound()); stub.onApplyWindowInsets(windowInsets); mMyOutputManager.handleWindowInsets(windowInsets); // WatchViewStub seems to call onApplyWindowInsets() multiple times before // the layout is inflated, so make sure we check the reference is valid. if (mOverlayView != null) mOverlayView.setRound(windowInsets.isRound()); return windowInsets; } }); }
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/* w w w .jav a 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 ww w. ja va 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: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 a v a2 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 attractionsUri = getIntent().getParcelableExtra(Constants.EXTRA_ATTRACTIONS_URI); if (attractionsUri != null) { new FetchDataAsyncTask(this).execute(attractionsUri); UtilityService.clearNotification(this); UtilityService.clearRemoteNotifications(this); } else { finish(); } }