Hide the fab in ViewPostDetailActivity when the recyclerview is scrolled to the bottom. Fix the fab shows under the nav bar in ViewPostDetailActivity.

This commit is contained in:
Alex Ning 2020-02-19 22:43:33 +08:00
parent bbc69b45e6
commit 97993709e2

View File

@ -243,7 +243,11 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (navBarResourceId > 0) { if (navBarResourceId > 0) {
mRecyclerView.setPadding(0, 0, 0, resources.getDimensionPixelSize(navBarResourceId)); int navBarHeight = resources.getDimensionPixelSize(navBarResourceId);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
params.bottomMargin = navBarHeight;
fab.setLayoutParams(params);
mRecyclerView.setPadding(0, 0, 0, navBarHeight);
showToast = true; showToast = true;
} }
} }
@ -272,17 +276,21 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
if (!mIsSmoothScrolling && !mLockFab) { if (!mIsSmoothScrolling && !mLockFab) {
if (dy > 0) { if (!recyclerView.canScrollVertically(1)) {
if (mSwipeUpToHideFab) { fab.hide();
fab.show();
} else {
fab.hide();
}
} else { } else {
if (mSwipeUpToHideFab) { if (dy > 0) {
fab.hide(); if (mSwipeUpToHideFab) {
fab.show();
} else {
fab.hide();
}
} else { } else {
fab.show(); if (mSwipeUpToHideFab) {
fab.hide();
} else {
fab.show();
}
} }
} }
} }
@ -311,17 +319,21 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
if (!mIsSmoothScrolling && !mLockFab) { if (!mIsSmoothScrolling && !mLockFab) {
if (dy > 0) { if (!recyclerView.canScrollVertically(1)) {
if (mSwipeUpToHideFab) { fab.hide();
fab.show();
} else {
fab.hide();
}
} else { } else {
if (mSwipeUpToHideFab) { if (dy > 0) {
fab.hide(); if (mSwipeUpToHideFab) {
fab.show();
} else {
fab.hide();
}
} else { } else {
fab.show(); if (mSwipeUpToHideFab) {
fab.hide();
} else {
fab.show();
}
} }
} }
} }
@ -657,17 +669,21 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
if (!mIsSmoothScrolling && !mLockFab) { if (!mIsSmoothScrolling && !mLockFab) {
if (dy > 0) { if (!recyclerView.canScrollVertically(1)) {
if (mSwipeUpToHideFab) { fab.hide();
fab.show();
} else {
fab.hide();
}
} else { } else {
if (mSwipeUpToHideFab) { if (dy > 0) {
fab.hide(); if (mSwipeUpToHideFab) {
fab.show();
} else {
fab.hide();
}
} else { } else {
fab.show(); if (mSwipeUpToHideFab) {
fab.hide();
} else {
fab.show();
}
} }
} }
} }
@ -753,17 +769,21 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy); super.onScrolled(recyclerView, dx, dy);
if (!mIsSmoothScrolling && !mLockFab) { if (!mIsSmoothScrolling && !mLockFab) {
if (dy > 0) { if (!recyclerView.canScrollVertically(1)) {
if (mSwipeUpToHideFab) { fab.hide();
fab.show();
} else {
fab.hide();
}
} else { } else {
if (mSwipeUpToHideFab) { if (dy > 0) {
fab.hide(); if (mSwipeUpToHideFab) {
fab.show();
} else {
fab.hide();
}
} else { } else {
fab.show(); if (mSwipeUpToHideFab) {
fab.hide();
} else {
fab.show();
}
} }
} }
} }