aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-22 09:56:11 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-22 09:56:11 +0000
commita52f608af91450f7d3aba643f637ae046e7534a1 (patch)
treefc27f5dd70a5959739bfd19cd80319a819379fa8 /app
parent7b754328fc59cd590d56625f1519c19122971920 (diff)
downloadinfinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.tar
infinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.tar.gz
infinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.tar.bz2
infinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.tar.lz
infinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.tar.xz
infinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.tar.zst
infinity-for-reddit-a52f608af91450f7d3aba643f637ae046e7534a1.zip
Hide FAB when RecyclerView in PostFragment is scrolling down.
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java8
3 files changed, 44 insertions, 1 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 8be70369..f19f54b4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -399,6 +399,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
@Override
public void onPageSelected(int position) {
+ fab.show();
if(isInLazyMode) {
if(position == sectionsPagerAdapter.getCurrentLazyModeFragmentPosition()) {
sectionsPagerAdapter.resumeLazyMode();
@@ -793,6 +794,14 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
}
}
+ public void postScrollUp() {
+ fab.show();
+ }
+
+ public void postScrollDown() {
+ fab.hide();
+ }
+
@Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) {
if(!getClass().getName().equals(event.excludeActivityClassName)) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
index cade1c5a..a1267632 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
@@ -189,11 +189,37 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return false;
});
+ if(activity instanceof MainActivity) {
+ mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ if (dy > 0) {
+ ((MainActivity) activity).postScrollDown();
+ } else if (dy < 0) {
+ ((MainActivity) activity).postScrollUp();
+ }
+
+ }
+ });
+ } else if(activity instanceof ViewSubredditDetailActivity) {
+ mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ if (dy > 0) {
+ ((ViewSubredditDetailActivity) activity).postScrollDown();
+ } else if (dy < 0) {
+ ((ViewSubredditDetailActivity) activity).postScrollUp();
+ }
+
+ }
+ });
+ }
+
int postType = getArguments().getInt(EXTRA_POST_TYPE);
String sortType = getArguments().getString(EXTRA_SORT_TYPE);
int filter = getArguments().getInt(EXTRA_FILTER);
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
- boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, true);
+ boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
PostViewModel.Factory factory;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
index d37998e2..bf718932 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -566,6 +566,14 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
}
}
+ public void postScrollUp() {
+ fab.show();
+ }
+
+ public void postScrollDown() {
+ fab.hide();
+ }
+
@Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) {
if(!getClass().getName().equals(event.excludeActivityClassName)) {