Skip to content

Commit

Permalink
Fix fitsSystemWindows related bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Jan 5, 2018
1 parent 8f5b49c commit 3462fee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public class IntroductionActivity extends AppCompatActivity {
private ArrayList<Slide> slides;
private Style style;

private ViewGroup root;
private ViewPager pager;
private ViewGroup bottomBarContainer;
private AppCompatImageButton previous;
private AppCompatImageButton next;
private FrameLayout indicatorContainer;
Expand All @@ -65,8 +67,8 @@ public class IntroductionActivity extends AppCompatActivity {

private boolean showPreviousButton;
private boolean showIndicator;
private String skipText;
private boolean allowBackPress;
private String skipText;

private int orientation;

Expand Down Expand Up @@ -96,7 +98,19 @@ protected void onCreate(Bundle savedInstanceState) {
select(previousPagerPosition);
}

//Workaround for fitsSystemWindows in a ViewPager
// Workarounds for fitsSystemWindows in a ViewPager.
ViewCompat.setOnApplyWindowInsetsListener(root, (v, insets) -> {
WindowInsetsCompat newInsets = ViewCompat.onApplyWindowInsets(root, insets);

if (newInsets.isConsumed()) {
return newInsets;
}

ViewCompat.dispatchApplyWindowInsets(bottomBarContainer, newInsets);

return newInsets.isConsumed() ? newInsets.consumeSystemWindowInsets() : newInsets;
});

ViewCompat.setOnApplyWindowInsetsListener(pager, (view, insets) -> {
WindowInsetsCompat newInsets = ViewCompat.onApplyWindowInsets(view, insets);

Expand Down Expand Up @@ -176,9 +190,10 @@ private void applyStyle() {
}

private void findViews() {
ViewGroup root = findViewById(R.id.introduction_activity_root);
root = findViewById(R.id.introduction_activity_root);
pager = findViewById(R.id.introduction_activity_pager);
indicatorContainer = findViewById(R.id.introduction_activity_container_indicator);
bottomBarContainer = findViewById(R.id.introduction_activity_bottom_bar_container);
skip = findViewById(R.id.introduction_activity_skip);

if (OrientationUtils.isRTL(this)) {
Expand Down
1 change: 1 addition & 0 deletions introduction/src/main/res/layout/introduction_activity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:layout_height="wrap_content" />

<FrameLayout
android:id="@+id/introduction_activity_bottom_bar_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
Expand Down

0 comments on commit 3462fee

Please sign in to comment.