Minor bugs fixed.

This commit is contained in:
Alex Ning 2020-12-25 00:02:12 +08:00
parent 3938d9734f
commit 4ebd10cd8c
3 changed files with 51 additions and 12 deletions

View File

@ -69,7 +69,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback, public class SearchResultActivity extends BaseActivity implements SortTypeSelectionCallback,
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface, PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface,
FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback, FABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback, RandomBottomSheetFragment.RandomOptionSelectionCallback,
PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostFragmentContentScrollingInterface { PostTypeBottomSheetFragment.PostTypeSelectionCallback, PostFragmentContentScrollingInterface {
static final String EXTRA_QUERY = "QK"; static final String EXTRA_QUERY = "QK";
static final String EXTRA_SUBREDDIT_NAME = "ESN"; 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: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class); Intent intent = new Intent(this, SearchActivity.class);
if (mSubredditName != null && !mSubredditName.equals("")) {
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName); intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
}
startActivity(intent); startActivity(intent);
break; break;
} }
@ -525,7 +527,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
Intent intent = new Intent(this, SearchActivity.class); Intent intent = new Intent(this, SearchActivity.class);
if (mSubredditName != null && !mSubredditName.equals("")) {
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName); intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
}
startActivity(intent); startActivity(intent);
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: { case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
@ -651,6 +655,13 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
fab.hide(); 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 { private class SectionsPagerAdapter extends FragmentStateAdapter {
public SectionsPagerAdapter(FragmentActivity fa) { public SectionsPagerAdapter(FragmentActivity fa) {

View File

@ -30,17 +30,18 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
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.BaseActivity;
import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity; import ml.docilealligator.infinityforreddit.activities.SearchSubredditsResultActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity; import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.adapters.SubredditListingRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.adapters.SubredditListingRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; 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.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.subreddit.SubredditListingViewModel; import ml.docilealligator.infinityforreddit.subreddit.SubredditListingViewModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -156,6 +157,19 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
mSubredditListingRecyclerView.setAdapter(mAdapter); 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( SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(
accessToken == null ? mRetrofit : mOauthRetrofit, query, sortType, accessToken, nsfw); accessToken == null ? mRetrofit : mOauthRetrofit, query, sortType, accessToken, nsfw);
mSubredditListingViewModel = new ViewModelProvider(this, factory).get(SubredditListingViewModel.class); mSubredditListingViewModel = new ViewModelProvider(this, factory).get(SubredditListingViewModel.class);

View File

@ -29,15 +29,16 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; 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.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState; import ml.docilealligator.infinityforreddit.NetworkState;
import ml.docilealligator.infinityforreddit.PostFragmentContentScrollingInterface;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType; 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.user.UserListingViewModel;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import retrofit2.Retrofit; import retrofit2.Retrofit;
@ -135,6 +136,19 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
mUserListingRecyclerView.setAdapter(mAdapter); 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, UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mRetrofit, mQuery,
sortType, nsfw); sortType, nsfw);
mUserListingViewModel = new ViewModelProvider(this, factory).get(UserListingViewModel.class); mUserListingViewModel = new ViewModelProvider(this, factory).get(UserListingViewModel.class);