aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java20
3 files changed, 50 insertions, 11 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
index 3703a2c1..49f95985 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
@@ -69,7 +69,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface,
- FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback,
+ FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback, RandomBottomSheetFragment.RandomOptionSelectionCallback,
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostFragmentContentScrollingInterface {
static final String EXTRA_QUERY = "QK";
static final String EXTRA_SUBREDDIT_NAME = "ESN";
@@ -329,7 +329,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ if (mSubredditName != null && !mSubredditName.equals("")) {
+ intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ }
startActivity(intent);
break;
}
@@ -525,7 +527,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ if (mSubredditName != null && !mSubredditName.equals("")) {
+ intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ }
startActivity(intent);
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
@@ -651,6 +655,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
fab.hide();
}
+ @Override
+ public void randomOptionSelected(int option) {
+ Intent intent = new Intent(this, FetchRandomSubredditOrPostActivity.class);
+ intent.putExtra(FetchRandomSubredditOrPostActivity.EXTRA_RANDOM_OPTION, option);
+ startActivity(intent);
+ }
+
private class SectionsPagerAdapter extends FragmentStateAdapter {
public SectionsPagerAdapter(FragmentActivity fa) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
index 14bfbf0a..2924b393 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubredditListingFragment.java
@@ -30,17 +30,18 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.activities.BaseActivity;
-import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity;
-import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
-import ml.docilealligator.infinityforreddit.adapters.SubredditListingRecyclerViewAdapter;
-import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState;
+import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
+import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity;
+import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
+import ml.docilealligator.infinityforreddit.adapters.SubredditListingRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.subreddit.SubredditListingViewModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
@@ -156,6 +157,19 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
mSubredditListingRecyclerView.setAdapter(mAdapter);
+ if (mActivity instanceof PostFragmentContentScrollingInterface) {
+ mSubredditListingRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ if (dy > 0) {
+ ((PostFragmentContentScrollingInterface) mActivity).contentScrollDown();
+ } else if (dy < 0) {
+ ((PostFragmentContentScrollingInterface) mActivity).contentScrollUp();
+ }
+ }
+ });
+ }
+
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(
accessToken == null ? mRetrofit : mOauthRetrofit, query, sortType, accessToken, nsfw);
mSubredditListingViewModel = new ViewModelProvider(this, factory).get(SubredditListingViewModel.class);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
index 6d833f4e..c663bd63 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/UserListingFragment.java
@@ -29,15 +29,16 @@ import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.activities.BaseActivity;
-import ml.docilealligator.infinityforreddit.adapters.UserListingRecyclerViewAdapter;
-import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState;
+import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
+import ml.docilealligator.infinityforreddit.activities.BaseActivity;
+import ml.docilealligator.infinityforreddit.adapters.UserListingRecyclerViewAdapter;
+import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.user.UserListingViewModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
@@ -135,6 +136,19 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
mUserListingRecyclerView.setAdapter(mAdapter);
+ if (mActivity instanceof PostFragmentContentScrollingInterface) {
+ mUserListingRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
+ @Override
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
+ if (dy > 0) {
+ ((PostFragmentContentScrollingInterface) mActivity).contentScrollDown();
+ } else if (dy < 0) {
+ ((PostFragmentContentScrollingInterface) mActivity).contentScrollUp();
+ }
+ }
+ });
+ }
+
UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mRetrofit, mQuery,
sortType, nsfw);
mUserListingViewModel = new ViewModelProvider(this, factory).get(UserListingViewModel.class);