From 478b2db4e583ff4577e421f1f115ef8d4d7626ef Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:48:23 -0400 Subject: Fix app crashes when loading multireddit posts. Rename some variables in MultiRedditListingFragment. --- .../activities/SubscribedThingListingActivity.java | 8 ++------ .../fragments/MultiRedditListingFragment.java | 12 ++++++------ .../infinityforreddit/post/PostPagingSource.java | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'app/src/main') 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 f674d09d..8b3f70a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -191,12 +191,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti isThingSelectionMode = getIntent().getBooleanExtra(EXTRA_THING_SELECTION_MODE, false); thingSelectionType = getIntent().getIntExtra(EXTRA_THING_SELECTION_TYPE, EXTRA_THING_SELECTION_TYPE_ALL); - if (isThingSelectionMode) { - switch (thingSelectionType) { - case EXTRA_THING_SELECTION_TYPE_SUBREDDIT: - getSupportActionBar().setTitle(R.string.subreddit_selection_activity_label); - break; - } + if (isThingSelectionMode && thingSelectionType == EXTRA_THING_SELECTION_TYPE_SUBREDDIT) { + getSupportActionBar().setTitle(R.string.subreddit_selection_activity_label); } if (isThingSelectionMode && thingSelectionType != EXTRA_THING_SELECTION_TYPE_ALL) { 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 316dc871..e95a99ea 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java @@ -146,8 +146,8 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm new MultiRedditViewModel.Factory(mRedditDataRoomDatabase, mActivity.accountName)) .get(MultiRedditViewModel.class); - mMultiRedditViewModel.getAllMultiReddits().observe(getViewLifecycleOwner(), subscribedUserData -> { - if (subscribedUserData == null || subscribedUserData.size() == 0) { + mMultiRedditViewModel.getAllMultiReddits().observe(getViewLifecycleOwner(), multiReddits -> { + if (multiReddits == null || multiReddits.size() == 0) { binding.recyclerViewMultiRedditListingFragment.setVisibility(View.GONE); binding.fetchMultiRedditListingInfoLinearLayoutMultiRedditListingFragment.setVisibility(View.VISIBLE); mGlide.load(R.drawable.error_image).into(binding.fetchMultiRedditListingInfoImageViewMultiRedditListingFragment); @@ -156,16 +156,16 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm binding.recyclerViewMultiRedditListingFragment.setVisibility(View.VISIBLE); mGlide.clear(binding.fetchMultiRedditListingInfoImageViewMultiRedditListingFragment); } - adapter.setMultiReddits(subscribedUserData); + adapter.setMultiReddits(multiReddits); }); - mMultiRedditViewModel.getAllFavoriteMultiReddits().observe(getViewLifecycleOwner(), favoriteSubscribedUserData -> { - if (favoriteSubscribedUserData != null && favoriteSubscribedUserData.size() > 0) { + mMultiRedditViewModel.getAllFavoriteMultiReddits().observe(getViewLifecycleOwner(), favoriteMultiReddits -> { + if (favoriteMultiReddits != null && favoriteMultiReddits.size() > 0) { binding.fetchMultiRedditListingInfoLinearLayoutMultiRedditListingFragment.setVisibility(View.GONE); binding.recyclerViewMultiRedditListingFragment.setVisibility(View.VISIBLE); mGlide.clear(binding.fetchMultiRedditListingInfoImageViewMultiRedditListingFragment); } - adapter.setFavoriteMultiReddits(favoriteSubscribedUserData); + adapter.setFavoriteMultiReddits(favoriteMultiReddits); }); return binding.getRoot(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java index 72038fba..1611dd99 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostPagingSource.java @@ -118,7 +118,7 @@ public class PostPagingSource extends ListenableFuturePagingSource this.sharedPreferences = sharedPreferences; this.postFeedScrolledPositionSharedPreferences = postFeedScrolledPositionSharedPreferences; if (path.endsWith("/")) { - multiRedditPath = path.substring(0, multiRedditPath.length() - 1); + multiRedditPath = path.substring(0, path.length() - 1); } else { multiRedditPath = path; } -- cgit v1.2.3