aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2021-04-21 02:06:32 +0000
committerAlex Ning <chineseperson5@gmail.com>2021-04-21 02:06:32 +0000
commit3263cca5825d17caed009d2b277b3b351ff1da9a (patch)
tree3a555ace3f3567187cf5d80758b946f30ebcc35c /app/src/main
parent9ad6d705e6e83c3b9768a0fc34557286bc5eccbd (diff)
downloadinfinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.tar
infinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.tar.gz
infinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.tar.bz2
infinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.tar.lz
infinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.tar.xz
infinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.tar.zst
infinity-for-reddit-3263cca5825d17caed009d2b277b3b351ff1da9a.zip
Fix the FAB shown in subreddit page in SubscribedThingListingActivity.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java4
-rw-r--r--app/src/main/res/layout/activity_subscribed_thing_listing.xml1
3 files changed, 19 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
index c4a90904..2d457dc4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java
@@ -79,7 +79,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
@BindView(R.id.view_pager_subscribed_thing_listing_activity)
ViewPager viewPager;
@BindView(R.id.fab_subscribed_thing_listing_activity)
- public FloatingActionButton fab;
+ FloatingActionButton fab;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@@ -189,6 +189,9 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(3);
+ if (viewPager.getCurrentItem() != 2) {
+ fab.hide();
+ }
viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
@@ -197,7 +200,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
fab.hide();
} else {
lockSwipeRightToGoBack();
- if (position == 1) {
+ if (position != 2) {
fab.hide();
} else {
fab.show();
@@ -276,6 +279,18 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
}
}
+ public void showFabInMultiredditTab() {
+ if (viewPager.getCurrentItem() == 2) {
+ fab.show();
+ }
+ }
+
+ public void hideFabInMultiredditTab() {
+ if (viewPager.getCurrentItem() == 2) {
+ fab.hide();
+ }
+ }
+
private void loadMultiReddits() {
FetchMyMultiReddits.fetchMyMultiReddits(mOauthRetrofit, mAccessToken, new FetchMyMultiReddits.FetchMyMultiRedditsListener() {
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java
index 9c86135c..fc0723eb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java
@@ -144,9 +144,9 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (dy > 0) {
- ((SubscribedThingListingActivity) mActivity).fab.hide();
+ ((SubscribedThingListingActivity) mActivity).hideFabInMultiredditTab();
} else {
- ((SubscribedThingListingActivity) mActivity).fab.show();
+ ((SubscribedThingListingActivity) mActivity).showFabInMultiredditTab();
}
}
});
diff --git a/app/src/main/res/layout/activity_subscribed_thing_listing.xml b/app/src/main/res/layout/activity_subscribed_thing_listing.xml
index 6ff42767..d1f49996 100644
--- a/app/src/main/res/layout/activity_subscribed_thing_listing.xml
+++ b/app/src/main/res/layout/activity_subscribed_thing_listing.xml
@@ -57,7 +57,6 @@
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:layout_gravity="bottom|end"
- android:visibility="gone"
app:srcCompat="@drawable/ic_add_day_night_24dp" />
</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file