aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java7
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java37
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java77
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java58
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java61
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java24
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java20
-rw-r--r--app/src/main/res/layout/fragment_post_type_bottom_sheet.xml35
-rw-r--r--app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml77
-rw-r--r--app/src/main/res/layout/fragment_search_user_and_subreddit_sort_type_bottom_sheet.xml36
-rw-r--r--app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml18
-rw-r--r--app/src/main/res/menu/search_result_activity.xml11
-rw-r--r--app/src/main/res/values-night/colors.xml4
-rw-r--r--app/src/main/res/values/colors.xml2
-rw-r--r--app/src/main/res/values/dimens.xml1
-rw-r--r--app/src/main/res/values/strings.xml6
30 files changed, 524 insertions, 138 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java
index b7c5a73e..9b96e087 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchSubredditData.java
@@ -2,10 +2,11 @@ package ml.docilealligator.infinityforreddit;
import android.util.Log;
+import androidx.annotation.NonNull;
+
import java.util.ArrayList;
import SubredditDatabase.SubredditData;
-import androidx.annotation.NonNull;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
@@ -56,10 +57,10 @@ class FetchSubredditData {
});
}
- static void fetchSubredditListingData(Retrofit retrofit, String query, String after, final FetchSubredditListingDataListener fetchSubredditListingDataListener) {
+ static void fetchSubredditListingData(Retrofit retrofit, String query, String after, String sortType, final FetchSubredditListingDataListener fetchSubredditListingDataListener) {
RedditAPI api = retrofit.create(RedditAPI.class);
- Call<String> subredditDataCall = api.searchSubreddits(query, after);
+ Call<String> subredditDataCall = api.searchSubreddits(query, after, sortType);
subredditDataCall.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java
index 7f2e2528..8eadcd89 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FetchUserData.java
@@ -2,10 +2,11 @@ package ml.docilealligator.infinityforreddit;
import android.util.Log;
+import androidx.annotation.NonNull;
+
import java.util.ArrayList;
import User.UserData;
-import androidx.annotation.NonNull;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
@@ -55,11 +56,11 @@ public class FetchUserData {
});
}
- public static void fetchUserListingData(Retrofit retrofit, String query, String after,
+ public static void fetchUserListingData(Retrofit retrofit, String query, String after, String sortType,
FetchUserListingDataListener fetchUserListingDataListener) {
RedditAPI api = retrofit.create(RedditAPI.class);
- Call<String> userInfo = api.searchUsers(query, after);
+ Call<String> userInfo = api.searchUsers(query, after, sortType);
userInfo.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
index 08dba87e..f32613f4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java
@@ -114,7 +114,12 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
startActivityForResult(loginIntent, LOGIN_ACTIVITY_REQUEST_CODE);
} else {
if (savedInstanceState == null) {
- replaceFragment(PostDataSource.SORT_TYPE_BEST);
+ mFragment = new PostFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
+ bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_BEST);
+ mFragment.setArguments(bundle);
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit();
} else {
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE);
getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit();
@@ -176,15 +181,6 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
fab.setOnClickListener(view -> postTypeBottomSheetFragment.show(getSupportFragmentManager(), postTypeBottomSheetFragment.getTag()));
}
- private void replaceFragment(String sortType) {
- mFragment = new PostFragment();
- Bundle bundle = new Bundle();
- bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_FRONT_PAGE);
- bundle.putString(PostFragment.EXTRA_SORT_TYPE, sortType);
- mFragment.setArguments(bundle);
- getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_content_main, mFragment).commit();
- }
-
private void loadUserData() {
if (!mFetchUserInfoSuccess) {
FetchMyInfo.fetchMyInfo(mOauthRetrofit, mAuthInfoSharedPreferences, new FetchMyInfo.FetchUserMyListener() {
@@ -330,7 +326,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe
@Override
public void sortTypeSelected(String sortType) {
- replaceFragment(sortType);
+ ((PostFragment) mFragment).changeSortType(sortType);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
index 2a96524e..b596fc75 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSource.java
@@ -31,6 +31,8 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
static final String SORT_TYPE_RISING = "rising";
static final String SORT_TYPE_TOP = "top";
static final String SORT_TYPE_CONTROVERSIAL = "controversial";
+ static final String SORT_TYPE_RELEVANCE = "relevance";
+ static final String SORT_TYPE_COMMENTS = "comments";
private Retrofit retrofit;
private String accessToken;
@@ -459,7 +461,7 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
Call<String> getPost;
if(subredditName == null) {
- getPost = api.searchPosts(query, null, RedditUtils.getOAuthHeader(accessToken));
+ getPost = api.searchPosts(query, null, sortType, RedditUtils.getOAuthHeader(accessToken));
} else {
getPost = api.searchPostsInSpecificSubreddit(subredditName, query, null, RedditUtils.getOAuthHeader(accessToken));
}
@@ -467,6 +469,7 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
getPost.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
+ Log.i("initial", call.request().url().toString());
if(response.isSuccessful()) {
ParsePost.parsePosts(response.body(), locale, -1,
new ParsePost.ParsePostsListingListener() {
@@ -507,7 +510,7 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
Call<String> getPost;
if(subredditName == null) {
- getPost = api.searchPosts(subredditName, params.key, RedditUtils.getOAuthHeader(accessToken));
+ getPost = api.searchPosts(query, params.key, sortType, RedditUtils.getOAuthHeader(accessToken));
} else {
getPost = api.searchPostsInSpecificSubreddit(subredditName, query, params.key, RedditUtils.getOAuthHeader(accessToken));
}
@@ -515,6 +518,7 @@ class PostDataSource extends PageKeyedDataSource<String, Post> {
getPost.enqueue(new Callback<String>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
+ Log.i("after", call.request().url().toString());
if(response.isSuccessful()) {
ParsePost.parsePosts(response.body(), locale, -1, new ParsePost.ParsePostsListingListener() {
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java
index 31e91c54..79a533e0 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostDataSourceFactory.java
@@ -90,4 +90,8 @@ class PostDataSourceFactory extends DataSource.Factory {
PostDataSource getPostDataSource() {
return postDataSource;
}
+
+ void changeSortType(String sortType) {
+ this.sortType = sortType;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
index 7196e640..f78d00b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFragment.java
@@ -287,6 +287,10 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
return rootView;
}
+ void changeSortType(String sortType) {
+ mPostViewModel.changeSortType(sortType);
+ }
+
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java
index 3c5548f8..c824567f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostViewModel.java
@@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit;
import androidx.annotation.NonNull;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
@@ -18,6 +19,7 @@ public class PostViewModel extends ViewModel {
private LiveData<NetworkState> paginationNetworkState;
private LiveData<NetworkState> initialLoadingState;
private LiveData<PagedList<Post>> posts;
+ private MutableLiveData<String> sortTypeLiveData;
public PostViewModel(Retrofit retrofit, String accessToken, Locale locale, int postType, String sortType,
PostDataSource.OnPostFetchedCallback onPostFetchedCallback) {
@@ -27,13 +29,20 @@ public class PostViewModel extends ViewModel {
(Function<PostDataSource, LiveData<NetworkState>>) PostDataSource::getInitialLoadStateLiveData);
paginationNetworkState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
(Function<PostDataSource, LiveData<NetworkState>>) PostDataSource::getPaginationNetworkStateLiveData);
+
+ sortTypeLiveData = new MutableLiveData<>();
+ sortTypeLiveData.postValue(sortType);
+
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setEnablePlaceholders(false)
.setPageSize(25)
.build();
- posts = (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
+ posts = Transformations.switchMap(sortTypeLiveData, sort -> {
+ postDataSourceFactory.changeSortType(sortTypeLiveData.getValue());
+ return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
+ });
}
public PostViewModel(Retrofit retrofit, String accessToken, Locale locale, String subredditName, int postType,
@@ -41,9 +50,12 @@ public class PostViewModel extends ViewModel {
postDataSourceFactory = new PostDataSourceFactory(retrofit, accessToken, locale, subredditName, postType, sortType, onPostFetchedCallback);
initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
- dataSource -> dataSource.getInitialLoadStateLiveData());
+ (Function<PostDataSource, LiveData<NetworkState>>) PostDataSource::getInitialLoadStateLiveData);
paginationNetworkState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
- dataSource -> dataSource.getPaginationNetworkStateLiveData());
+ (Function<PostDataSource, LiveData<NetworkState>>) PostDataSource::getPaginationNetworkStateLiveData);
+
+ sortTypeLiveData = new MutableLiveData<>();
+ sortTypeLiveData.postValue(sortType);
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
@@ -51,7 +63,10 @@ public class PostViewModel extends ViewModel {
.setPageSize(25)
.build();
- posts = (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
+ posts = Transformations.switchMap(sortTypeLiveData, sort -> {
+ postDataSourceFactory.changeSortType(sortTypeLiveData.getValue());
+ return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
+ });
}
public PostViewModel(Retrofit retrofit, String accessToken, Locale locale, String subredditName, int postType,
@@ -61,7 +76,7 @@ public class PostViewModel extends ViewModel {
initialLoadingState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
dataSource -> dataSource.getInitialLoadStateLiveData());
paginationNetworkState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
- dataSource -> dataSource.getPaginationNetworkStateLiveData());
+ (Function<PostDataSource, LiveData<NetworkState>>) PostDataSource::getPaginationNetworkStateLiveData);
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
@@ -82,13 +97,19 @@ public class PostViewModel extends ViewModel {
paginationNetworkState = Transformations.switchMap(postDataSourceFactory.getPostDataSourceLiveData(),
dataSource -> dataSource.getPaginationNetworkStateLiveData());
+ sortTypeLiveData = new MutableLiveData<>();
+ sortTypeLiveData.postValue(sortType);
+
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setEnablePlaceholders(false)
.setPageSize(25)
.build();
- posts = (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
+ posts = Transformations.switchMap(sortTypeLiveData, sort -> {
+ postDataSourceFactory.changeSortType(sortTypeLiveData.getValue());
+ return (new LivePagedListBuilder(postDataSourceFactory, pagedListConfig)).build();
+ });
}
LiveData<PagedList<Post>> getPosts() {
@@ -115,6 +136,10 @@ public class PostViewModel extends ViewModel {
postDataSourceFactory.getPostDataSource().retryLoadingMore();
}
+ void changeSortType(String sortType) {
+ sortTypeLiveData.postValue(sortType);
+ }
+
public static class Factory extends ViewModelProvider.NewInstanceFactory {
private Retrofit retrofit;
private String accessToken;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
index 0aba1d50..f0a9ac5b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditAPI.java
@@ -66,13 +66,13 @@ public interface RedditAPI {
Call<String> getInfo(@Path("subredditNamePrefixed") String subredditNamePrefixed, @Query("id") String id);
@GET("subreddits/search.json?raw_json=1&include_over_18=on")
- Call<String> searchSubreddits(@Query("q") String subredditName, @Query("after") String after);
+ Call<String> searchSubreddits(@Query("q") String subredditName, @Query("after") String after, @Query("sort") String sort);
@GET("search.json?raw_json=1&type=user&include_over_18=on")
- Call<String> searchUsers(@Query("q") String profileName, @Query("after") String after);
+ Call<String> searchUsers(@Query("q") String profileName, @Query("after") String after, @Query("sort") String sort);
@GET("search.json?raw_json=1&type=link&include_over_18=on")
- Call<String> searchPosts(@Query("q") String query, @Query("after") String after,
+ Call<String> searchPosts(@Query("q") String query, @Query("after") String after, @Query("sort") String sort,
@HeaderMap Map<String, String> headers);
@GET("r/{subredditName}/search.json?raw_json=1&type=link&restrict_sr=true&include_over_18=on")
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java
new file mode 100644
index 00000000..1bc862cc
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchPostSortTypeBottomSheetFragment.java
@@ -0,0 +1,77 @@
+package ml.docilealligator.infinityforreddit;
+
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.fragment.app.Fragment;
+
+import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class SearchPostSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ interface SearchSortTypeSelectionCallback {
+ void searchSortTypeSelected(String sortType);
+ }
+
+ static final String EXTRA_FRAGMENT_POSITION = "EFP";
+
+ @BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment) TextView relevanceTypeTextView;
+ @BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment) TextView hotTypeTextView;
+ @BindView(R.id.top_type_text_view_search_sort_type_bottom_sheet_fragment) TextView topTypeTextView;
+ @BindView(R.id.new_type_text_view_search_sort_type_bottom_sheet_fragment) TextView newTypeTextView;
+ @BindView(R.id.comments_type_text_view_search_sort_type_bottom_sheet_fragment) TextView commentsTypeTextView;
+
+ public SearchPostSortTypeBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false);
+ ButterKnife.bind(this, rootView);
+
+ Activity activity = getActivity();
+
+ relevanceTypeTextView.setOnClickListener(view -> {
+ ((SearchSortTypeSelectionCallback) activity).searchSortTypeSelected(PostDataSource.SORT_TYPE_RELEVANCE);
+ dismiss();
+ });
+
+ hotTypeTextView.setOnClickListener(view -> {
+ ((SearchSortTypeSelectionCallback) activity).searchSortTypeSelected(PostDataSource.SORT_TYPE_HOT);
+ dismiss();
+ });
+
+ topTypeTextView.setOnClickListener(view -> {
+ ((SearchSortTypeSelectionCallback) activity).searchSortTypeSelected(PostDataSource.SORT_TYPE_TOP);
+ dismiss();
+ });
+
+ newTypeTextView.setOnClickListener(view -> {
+ ((SearchSortTypeSelectionCallback) activity).searchSortTypeSelected(PostDataSource.SORT_TYPE_NEW);
+ dismiss();
+ });
+
+ commentsTypeTextView.setOnClickListener(view -> {
+ ((SearchSortTypeSelectionCallback) activity).searchSortTypeSelected(PostDataSource.SORT_TYPE_COMMENTS);
+ dismiss();
+ });
+
+ return rootView;
+ }
+
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java
index b8f304bd..a63f1de2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchResultActivity.java
@@ -19,7 +19,8 @@ import com.google.android.material.tabs.TabLayout;
import butterknife.BindView;
import butterknife.ButterKnife;
-public class SearchResultActivity extends AppCompatActivity {
+public class SearchResultActivity extends AppCompatActivity implements SearchPostSortTypeBottomSheetFragment.SearchSortTypeSelectionCallback,
+ SearchUserAndSubredditSortTypeBottomSheetFragment.SearchUserAndSubredditSortTypeSelectionCallback {
static final String EXTRA_QUERY = "QK";
static final String EXTRA_SUBREDDIT_NAME = "ESN";
@@ -32,6 +33,9 @@ public class SearchResultActivity extends AppCompatActivity {
private SectionsPagerAdapter sectionsPagerAdapter;
+ private SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment;
+ private SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -45,8 +49,16 @@ public class SearchResultActivity extends AppCompatActivity {
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(sectionsPagerAdapter);
viewPager.setOffscreenPageLimit(2);
+
tabLayout.setupWithViewPager(viewPager);
+ searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment();
+ Bundle bundle = new Bundle();
+ bundle.putInt(SearchPostSortTypeBottomSheetFragment.EXTRA_FRAGMENT_POSITION, viewPager.getCurrentItem());
+ searchPostSortTypeBottomSheetFragment.setArguments(bundle);
+
+ searchUserAndSubredditSortTypeBottomSheetFragment = new SearchUserAndSubredditSortTypeBottomSheetFragment();
+
// Get the intent, verify the action and get the query
Intent intent = getIntent();
String query = intent.getExtras().getString(EXTRA_QUERY);
@@ -73,6 +85,21 @@ public class SearchResultActivity extends AppCompatActivity {
case android.R.id.home:
onBackPressed();
return true;
+ case R.id.action_sort_search_result_activity:
+ switch (viewPager.getCurrentItem()) {
+ case 0: {
+ searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
+ break;
+ }
+ case 1:
+ case 2:
+ Bundle bundle = new Bundle();
+ bundle.putInt(SearchUserAndSubredditSortTypeBottomSheetFragment.EXTRA_FRAGMENT_POSITION, viewPager.getCurrentItem());
+ searchUserAndSubredditSortTypeBottomSheetFragment.setArguments(bundle);
+ searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
+ break;
+ }
+ return true;
case R.id.action_search_search_result_activity:
Intent intent = new Intent(this, SearchActivity.class);
finish();
@@ -85,7 +112,18 @@ public class SearchResultActivity extends AppCompatActivity {
return super.onOptionsItemSelected(item);
}
+ @Override
+ public void searchSortTypeSelected(String sortType) {
+ sectionsPagerAdapter.changeSortType(sortType, 0);
+ }
+
+ @Override
+ public void searchUserAndSubredditSortTypeSelected(String sortType, int fragmentPosition) {
+ sectionsPagerAdapter.changeSortType(sortType, fragmentPosition);
+ }
+
private class SectionsPagerAdapter extends FragmentPagerAdapter {
+
private PostFragment postFragment;
private SubredditListingFragment subredditListingFragment;
private UserListingFragment userListingFragment;
@@ -102,7 +140,7 @@ public class SearchResultActivity extends AppCompatActivity {
PostFragment mFragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SEARCH);
- bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_BEST);
+ bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_RELEVANCE);
bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, mSubredditName);
bundle.putString(PostFragment.EXTRA_QUERY, mQuery);
mFragment.setArguments(bundle);
@@ -115,8 +153,7 @@ public class SearchResultActivity extends AppCompatActivity {
mFragment.setArguments(bundle);
return mFragment;
}
- default:
- {
+ default: {
UserListingFragment mFragment = new UserListingFragment();
Bundle bundle = new Bundle();
bundle.putString(UserListingFragment.QUERY_KEY, mQuery);
@@ -162,6 +199,19 @@ public class SearchResultActivity extends AppCompatActivity {
return fragment;
}
+ void changeSortType(String sortType, int fragmentPosition) {
+ switch (fragmentPosition) {
+ case 0:
+ postFragment.changeSortType(sortType);
+ break;
+ case 1:
+ subredditListingFragment.changeSortType(sortType);
+ break;
+ case 2:
+ userListingFragment.changeSortType(sortType);
+ }
+ }
+
public void refresh() {
if(postFragment != null) {
((FragmentCommunicator) postFragment).refresh();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java
new file mode 100644
index 00000000..ae652fd4
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SearchUserAndSubredditSortTypeBottomSheetFragment.java
@@ -0,0 +1,61 @@
+package ml.docilealligator.infinityforreddit;
+
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.fragment.app.Fragment;
+
+import com.deishelon.roundedbottomsheet.RoundedBottomSheetDialogFragment;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class SearchUserAndSubredditSortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
+
+ interface SearchUserAndSubredditSortTypeSelectionCallback {
+ void searchUserAndSubredditSortTypeSelected(String sortType, int fragmentPosition);
+ }
+
+ static final String EXTRA_FRAGMENT_POSITION = "EFP";
+
+ @BindView(R.id.relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) TextView relevanceTypeTextView;
+ @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) TextView activityTypeTextView;
+
+ public SearchUserAndSubredditSortTypeBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false);
+ ButterKnife.bind(this, rootView);
+
+ Activity activity = getActivity();
+
+ int position = getArguments().getInt(EXTRA_FRAGMENT_POSITION);
+
+ relevanceTypeTextView.setOnClickListener(view -> {
+ ((SearchUserAndSubredditSortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(PostDataSource.SORT_TYPE_RELEVANCE, position);
+ dismiss();
+ });
+
+ activityTypeTextView.setOnClickListener(view -> {
+ ((SearchUserAndSubredditSortTypeSelectionCallback) activity).searchUserAndSubredditSortTypeSelected(PostDataSource.SORT_TYPE_HOT, position);
+ dismiss();
+ });
+
+ return rootView;
+ }
+
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java
index 8e25c271..16fbb961 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SortTypeBottomSheetFragment.java
@@ -78,7 +78,7 @@ public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
});
controversialTypeTextView.setOnClickListener(view -> {
- ((SortTypeSelectionCallback) activity).sortTypeSelected(PostDataSource.SORT_TYPE_BEST);
+ ((SortTypeSelectionCallback) activity).sortTypeSelected(PostDataSource.SORT_TYPE_CONTROVERSIAL);
dismiss();
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java
index 80e024d6..261c390b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSource.java
@@ -1,11 +1,12 @@
package ml.docilealligator.infinityforreddit;
-import java.util.ArrayList;
-
-import SubredditDatabase.SubredditData;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import androidx.paging.PageKeyedDataSource;
+
+import java.util.ArrayList;
+
+import SubredditDatabase.SubredditData;
import retrofit2.Retrofit;
public class SubredditListingDataSource extends PageKeyedDataSource<String, SubredditData> {
@@ -15,6 +16,7 @@ public class SubredditListingDataSource extends PageKeyedDataSource<String, Subr
}
private Retrofit retrofit;
private String query;
+ private String sortType;
private OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback;
private MutableLiveData<NetworkState> paginationNetworkStateLiveData;
@@ -25,10 +27,11 @@ public class SubredditListingDataSource extends PageKeyedDataSource<String, Subr
private LoadParams<String> params;
private LoadCallback<String, SubredditData> callback;
- SubredditListingDataSource(Retrofit retrofit, String query,
+ SubredditListingDataSource(Retrofit retrofit, String query, String sortType,
OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback) {
this.retrofit = retrofit;
this.query = query;
+ this.sortType = sortType;
this.onSubredditListingDataFetchedCallback = onSubredditListingDataFetchedCallback;
paginationNetworkStateLiveData = new MutableLiveData();
initialLoadStateLiveData = new MutableLiveData();
@@ -49,7 +52,7 @@ public class SubredditListingDataSource extends PageKeyedDataSource<String, Subr
initialLoadStateLiveData.postValue(NetworkState.LOADING);
- FetchSubredditData.fetchSubredditListingData(retrofit, query, null, new FetchSubredditData.FetchSubredditListingDataListener() {
+ FetchSubredditData.fetchSubredditListingData(retrofit, query, null, sortType, new FetchSubredditData.FetchSubredditListingDataListener() {
@Override
public void onFetchSubredditListingDataSuccess(ArrayList<SubredditData> subredditData, String after) {
if(subredditData.size() == 0) {
@@ -83,7 +86,7 @@ public class SubredditListingDataSource extends PageKeyedDataSource<String, Subr
return;
}
- FetchSubredditData.fetchSubredditListingData(retrofit, query, params.key, new FetchSubredditData.FetchSubredditListingDataListener() {
+ FetchSubredditData.fetchSubredditListingData(retrofit, query, params.key, sortType, new FetchSubredditData.FetchSubredditListingDataListener() {
@Override
public void onFetchSubredditListingDataSuccess(ArrayList<SubredditData> subredditData, String after) {
callback.onResult(subredditData, after);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java
index bc64c052..f31cff7a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingDataSourceFactory.java
@@ -8,15 +8,17 @@ import retrofit2.Retrofit;
public class SubredditListingDataSourceFactory extends DataSource.Factory {
private Retrofit retrofit;
private String query;
+ private String sortType;
private SubredditListingDataSource.OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback;
private SubredditListingDataSource subredditListingDataSource;
private MutableLiveData<SubredditListingDataSource> subredditListingDataSourceMutableLiveData;
- SubredditListingDataSourceFactory(Retrofit retrofit, String query,
+ SubredditListingDataSourceFactory(Retrofit retrofit, String query, String sortType,
SubredditListingDataSource.OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback) {
this.retrofit = retrofit;
this.query = query;
+ this.sortType = sortType;
this.onSubredditListingDataFetchedCallback = onSubredditListingDataFetchedCallback;
subredditListingDataSourceMutableLiveData = new MutableLiveData<>();
}
@@ -25,7 +27,7 @@ public class SubredditListingDataSourceFactory extends DataSource.Factory {
@Override
public DataSource create() {
subredditListingDataSource = new SubredditListingDataSource(retrofit,
- query, onSubredditListingDataFetchedCallback);
+ query, sortType, onSubredditListingDataFetchedCallback);
subredditListingDataSourceMutableLiveData.postValue(subredditListingDataSource);
return subredditListingDataSource;
}
@@ -37,4 +39,8 @@ public class SubredditListingDataSourceFactory extends DataSource.Factory {
SubredditListingDataSource getSubredditListingDataSource() {
return subredditListingDataSource;
}
+
+ void changeSortType(String sortType) {
+ this.sortType = sortType;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java
index 1972be71..2168bddd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingFragment.java
@@ -10,6 +10,12 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.ViewModelProviders;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
import com.bumptech.glide.Glide;
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
@@ -17,11 +23,6 @@ import javax.inject.Inject;
import javax.inject.Named;
import SubscribedSubredditDatabase.SubscribedSubredditRoomDatabase;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import androidx.fragment.app.Fragment;
-import androidx.lifecycle.ViewModelProviders;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Retrofit;
@@ -79,7 +80,7 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
mQuery = getArguments().getString(QUERY_KEY);
SubredditListingViewModel.Factory factory = new SubredditListingViewModel.Factory(mRetrofit, mQuery,
- new SubredditListingDataSource.OnSubredditListingDataFetchedCallback() {
+ PostDataSource.SORT_TYPE_RELEVANCE, new SubredditListingDataSource.OnSubredditListingDataFetchedCallback() {
@Override
public void hasSubreddit() {
mFetchSubredditListingInfoLinearLayout.setVisibility(View.GONE);
@@ -87,11 +88,8 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
@Override
public void noSubreddit() {
- mFetchSubredditListingInfoLinearLayout.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- //Do nothing
- }
+ mFetchSubredditListingInfoLinearLayout.setOnClickListener(view -> {
+ //Do nothing
});
showErrorView(R.string.no_subreddits);
}
@@ -135,6 +133,10 @@ public class SubredditListingFragment extends Fragment implements FragmentCommun
}
}
+ void changeSortType(String sortType) {
+ mSubredditListingViewModel.changeSortType(sortType);
+ }
+
@Override
public void refresh() {
mSubredditListingViewModel.refresh();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java
index 1ebb2dc3..3c304b90 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SubredditListingViewModel.java
@@ -1,14 +1,16 @@
package ml.docilealligator.infinityforreddit;
-import SubredditDatabase.SubredditData;
import androidx.annotation.NonNull;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList;
+
+import SubredditDatabase.SubredditData;
import retrofit2.Retrofit;
public class SubredditListingViewModel extends ViewModel {
@@ -16,22 +18,30 @@ public class SubredditListingViewModel extends ViewModel {
private LiveData<NetworkState> paginationNetworkState;
private LiveData<NetworkState> initialLoadingState;
private LiveData<PagedList<SubredditData>> subreddits;
+ private MutableLiveData<String> sortTypeLiveData;
- SubredditListingViewModel(Retrofit retrofit, String query,
+ SubredditListingViewModel(Retrofit retrofit, String query, String sortType,
SubredditListingDataSource.OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback) {
- subredditListingDataSourceFactory = new SubredditListingDataSourceFactory(retrofit, query, onSubredditListingDataFetchedCallback);
+ subredditListingDataSourceFactory = new SubredditListingDataSourceFactory(retrofit, query, sortType, onSubredditListingDataFetchedCallback);
initialLoadingState = Transformations.switchMap(subredditListingDataSourceFactory.getSubredditListingDataSourceMutableLiveData(),
(Function<SubredditListingDataSource, LiveData<NetworkState>>) SubredditListingDataSource::getInitialLoadStateLiveData);
paginationNetworkState = Transformations.switchMap(subredditListingDataSourceFactory.getSubredditListingDataSourceMutableLiveData(),
(Function<SubredditListingDataSource, LiveData<NetworkState>>) SubredditListingDataSource::getPaginationNetworkStateLiveData);
+
+ sortTypeLiveData = new MutableLiveData<>();
+ sortTypeLiveData.postValue(sortType);
+
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setEnablePlaceholders(false)
.setPageSize(25)
.build();
- subreddits = (new LivePagedListBuilder(subredditListingDataSourceFactory, pagedListConfig)).build();
+ subreddits = Transformations.switchMap(sortTypeLiveData, sort -> {
+ subredditListingDataSourceFactory.changeSortType(sortTypeLiveData.getValue());
+ return new LivePagedListBuilder(subredditListingDataSourceFactory, pagedListConfig).build();
+ });
}
LiveData<PagedList<SubredditData>> getSubreddits() {
@@ -58,22 +68,28 @@ public class SubredditListingViewModel extends ViewModel {
subredditListingDataSourceFactory.getSubredditListingDataSource().retryLoadingMore();
}
+ void changeSortType(String sortType) {
+ sortTypeLiveData.postValue(sortType);
+ }
+
public static class Factory extends ViewModelProvider.NewInstanceFactory {
private Retrofit retrofit;
private String query;
+ private String sortType;
private SubredditListingDataSource.OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback;
- public Factory(Retrofit retrofit, String query,
+ public Factory(Retrofit retrofit, String query, String sortType,
SubredditListingDataSource.OnSubredditListingDataFetchedCallback onSubredditListingDataFetchedCallback) {
this.retrofit = retrofit;
this.query = query;
+ this.sortType = sortType;
this.onSubredditListingDataFetchedCallback = onSubredditListingDataFetchedCallback;
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
- return (T) new SubredditListingViewModel(retrofit, query, onSubredditListingDataFetchedCallback);
+ return (T) new SubredditListingViewModel(retrofit, query, sortType, onSubredditListingDataFetchedCallback);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java
index 9273c32b..e2873052 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSource.java
@@ -1,11 +1,12 @@
package ml.docilealligator.infinityforreddit;
-import java.util.ArrayList;
-
-import User.UserData;
import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import androidx.paging.PageKeyedDataSource;
+
+import java.util.ArrayList;
+
+import User.UserData;
import retrofit2.Retrofit;
public class UserListingDataSource extends PageKeyedDataSource<String, UserData> {
@@ -13,8 +14,10 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
void hasUser();
void noUser();
}
+
private Retrofit retrofit;
private String query;
+ private String sortType;
private UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback;
private MutableLiveData<NetworkState> paginationNetworkStateLiveData;
@@ -25,10 +28,11 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
private PageKeyedDataSource.LoadParams<String> params;
private PageKeyedDataSource.LoadCallback<String, UserData> callback;
- UserListingDataSource(Retrofit retrofit, String query,
+ UserListingDataSource(Retrofit retrofit, String query, String sortType,
UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback) {
this.retrofit = retrofit;
this.query = query;
+ this.sortType = sortType;
this.onUserListingDataFetchedCallback = onUserListingDataFetchedCallback;
paginationNetworkStateLiveData = new MutableLiveData();
initialLoadStateLiveData = new MutableLiveData();
@@ -49,7 +53,7 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
initialLoadStateLiveData.postValue(NetworkState.LOADING);
- FetchUserData.fetchUserListingData(retrofit, query, null, new FetchUserData.FetchUserListingDataListener() {
+ FetchUserData.fetchUserListingData(retrofit, query, null, sortType, new FetchUserData.FetchUserListingDataListener() {
@Override
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
if(UserData.size() == 0) {
@@ -83,7 +87,7 @@ public class UserListingDataSource extends PageKeyedDataSource<String, UserData>
return;
}
- FetchUserData.fetchUserListingData(retrofit, query, params.key, new FetchUserData.FetchUserListingDataListener() {
+ FetchUserData.fetchUserListingData(retrofit, query, params.key, sortType, new FetchUserData.FetchUserListingDataListener() {
@Override
public void onFetchUserListingDataSuccess(ArrayList<UserData> UserData, String after) {
callback.onResult(UserData, after);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java
index 99e1fcfb..c014687c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingDataSourceFactory.java
@@ -8,15 +8,17 @@ import retrofit2.Retrofit;
public class UserListingDataSourceFactory extends DataSource.Factory {
private Retrofit retrofit;
private String query;
+ private String sortType;
private UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback;
private UserListingDataSource userListingDataSource;
private MutableLiveData<UserListingDataSource> userListingDataSourceMutableLiveData;
- UserListingDataSourceFactory(Retrofit retrofit, String query,
+ UserListingDataSourceFactory(Retrofit retrofit, String query, String sortType,
UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback) {
this.retrofit = retrofit;
this.query = query;
+ this.sortType = sortType;
this.onUserListingDataFetchedCallback = onUserListingDataFetchedCallback;
userListingDataSourceMutableLiveData = new MutableLiveData<>();
}
@@ -25,7 +27,7 @@ public class UserListingDataSourceFactory extends DataSource.Factory {
@Override
public DataSource create() {
userListingDataSource = new UserListingDataSource(retrofit,
- query, onUserListingDataFetchedCallback);
+ query, sortType, onUserListingDataFetchedCallback);
userListingDataSourceMutableLiveData.postValue(userListingDataSource);
return userListingDataSource;
}
@@ -37,4 +39,8 @@ public class UserListingDataSourceFactory extends DataSource.Factory {
UserListingDataSource getUserListingDataSource() {
return userListingDataSource;
}
+
+ void changeSortType(String sortType) {
+ this.sortType = sortType;
+ }
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java
index 78153fdc..4b111a51 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingFragment.java
@@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit;
-import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -11,6 +10,12 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
+import androidx.coordinatorlayout.widget.CoordinatorLayout;
+import androidx.fragment.app.Fragment;
+import androidx.lifecycle.ViewModelProviders;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
import com.bumptech.glide.Glide;
import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar;
@@ -18,11 +23,6 @@ import javax.inject.Inject;
import javax.inject.Named;
import SubscribedUserDatabase.SubscribedUserRoomDatabase;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
-import androidx.fragment.app.Fragment;
-import androidx.lifecycle.ViewModelProviders;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.ButterKnife;
import retrofit2.Retrofit;
@@ -85,11 +85,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
mQuery = getArguments().getString(QUERY_KEY);
- String accessToken = getActivity().getSharedPreferences(SharedPreferencesUtils.AUTH_CODE_FILE_KEY, Context.MODE_PRIVATE)
- .getString(SharedPreferencesUtils.ACCESS_TOKEN_KEY, "");
-
UserListingViewModel.Factory factory = new UserListingViewModel.Factory(mRetrofit, mQuery,
- new UserListingDataSource.OnUserListingDataFetchedCallback() {
+ PostDataSource.SORT_TYPE_RELEVANCE, new UserListingDataSource.OnUserListingDataFetchedCallback() {
@Override
public void hasUser() {
mFetchUserListingInfoLinearLayout.setVisibility(View.GONE);
@@ -97,11 +94,8 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
@Override
public void noUser() {
- mFetchUserListingInfoLinearLayout.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- //Do nothing
- }
+ mFetchUserListingInfoLinearLayout.setOnClickListener(view -> {
+ //Do nothing
});
showErrorView(R.string.no_users);
}
@@ -145,6 +139,10 @@ public class UserListingFragment extends Fragment implements FragmentCommunicato
}
}
+ void changeSortType(String sortType) {
+ mUserListingViewModel.changeSortType(sortType);
+ }
+
@Override
public void refresh() {
mUserListingViewModel.refresh();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java
index 6a1804db..45317ccf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/UserListingViewModel.java
@@ -1,41 +1,51 @@
package ml.docilealligator.infinityforreddit;
-import User.UserData;
import androidx.annotation.NonNull;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
+import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import androidx.paging.LivePagedListBuilder;
import androidx.paging.PagedList;
+
+import User.UserData;
import retrofit2.Retrofit;
public class UserListingViewModel extends ViewModel {
private UserListingDataSourceFactory UserListingDataSourceFactory;
private LiveData<NetworkState> paginationNetworkState;
private LiveData<NetworkState> initialLoadingState;
- private LiveData<PagedList<UserData>> Users;
+ private LiveData<PagedList<UserData>> users;
+ private MutableLiveData<String> sortTypeLiveData;
- UserListingViewModel(Retrofit retrofit, String query,
+ UserListingViewModel(Retrofit retrofit, String query, String sortType,
UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback) {
- UserListingDataSourceFactory = new UserListingDataSourceFactory(retrofit, query, onUserListingDataFetchedCallback);
+ UserListingDataSourceFactory = new UserListingDataSourceFactory(retrofit, query, sortType, onUserListingDataFetchedCallback);
initialLoadingState = Transformations.switchMap(UserListingDataSourceFactory.getUserListingDataSourceMutableLiveData(),
(Function<UserListingDataSource, LiveData<NetworkState>>) UserListingDataSource::getInitialLoadStateLiveData);
paginationNetworkState = Transformations.switchMap(UserListingDataSourceFactory.getUserListingDataSourceMutableLiveData(),
(Function<UserListingDataSource, LiveData<NetworkState>>) UserListingDataSource::getPaginationNetworkStateLiveData);
+
+ sortTypeLiveData = new MutableLiveData<>();
+ sortTypeLiveData.postValue(sortType);
+
PagedList.Config pagedListConfig =
(new PagedList.Config.Builder())
.setEnablePlaceholders(false)
.setPageSize(25)
.build();
- Users = (new LivePagedListBuilder(UserListingDataSourceFactory, pagedListConfig)).build();
+ users = Transformations.switchMap(sortTypeLiveData, sort -> {
+ UserListingDataSourceFactory.changeSortType(sortTypeLiveData.getValue());
+ return (new LivePagedListBuilder(UserListingDataSourceFactory, pagedListConfig)).build();
+ });
}
LiveData<PagedList<UserData>> getUsers() {
- return Users;
+ return users;
}
LiveData<NetworkState> getPaginationNetworkState() {
@@ -58,22 +68,28 @@ public class UserListingViewModel extends ViewModel {
UserListingDataSourceFactory.getUserListingDataSource().retryLoadingMore();
}
+ void changeSortType(String sortType) {
+ sortTypeLiveData.postValue(sortType);
+ }
+
public static class Factory extends ViewModelProvider.NewInstanceFactory {
private Retrofit retrofit;
private String query;
+ private String sortType;
private UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback;
- public Factory(Retrofit retrofit, String query,
+ public Factory(Retrofit retrofit, String query, String sortType,
UserListingDataSource.OnUserListingDataFetchedCallback onUserListingDataFetchedCallback) {
this.retrofit = retrofit;
this.query = query;
+ this.sortType = sortType;
this.onUserListingDataFetchedCallback = onUserListingDataFetchedCallback;
}
@NonNull
@Override
public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
- return (T) new UserListingViewModel(retrofit, query, onUserListingDataFetchedCallback);
+ return (T) new UserListingViewModel(retrofit, query, sortType, onUserListingDataFetchedCallback);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
index 9996a4af..ef58c820 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewSubredditDetailActivity.java
@@ -253,7 +253,13 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
});
if(savedInstanceState == null) {
- replaceFragment(PostDataSource.SORT_TYPE_BEST);
+ mFragment = new PostFragment();
+ Bundle bundle = new Bundle();
+ bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, subredditName);
+ bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
+ bundle.putString(PostFragment.EXTRA_SORT_TYPE, PostDataSource.SORT_TYPE_BEST);
+ mFragment.setArguments(bundle);
+ getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit();
} else {
mFragment = getSupportFragmentManager().getFragment(savedInstanceState, FRAGMENT_OUT_STATE_KEY);
if(mFragment == null) {
@@ -330,16 +336,6 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
return false;
}
- private void replaceFragment(String sortType) {
- mFragment = new PostFragment();
- Bundle bundle = new Bundle();
- bundle.putString(PostFragment.EXTRA_SUBREDDIT_NAME, subredditName);
- bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
- bundle.putString(PostFragment.EXTRA_SORT_TYPE, sortType);
- mFragment.setArguments(bundle);
- getSupportFragmentManager().beginTransaction().replace(R.id.frame_layout_view_subreddit_detail_activity, mFragment).commit();
- }
-
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
@@ -353,7 +349,7 @@ public class ViewSubredditDetailActivity extends AppCompatActivity implements So
@Override
public void sortTypeSelected(String sortType) {
- replaceFragment(sortType);
+ ((PostFragment) mFragment).changeSortType(sortType);
}
@Override
diff --git a/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml
index 1e3659d1..81f20963 100644
--- a/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_post_type_bottom_sheet.xml
@@ -1,18 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_width="match_parent"
android:layout_height="match_parent"
- android:paddingBottom="8dp">
-
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="24dp"
- android:paddingBottom="16dp"
- android:paddingStart="32dp"
- android:paddingEnd="32dp"
- android:text="@string/bottom_sheet_post_type"
- android:textSize="18sp" />
+ android:paddingBottom="8dp"
+ android:orientation="vertical">
<LinearLayout
android:id="@+id/text_type_linear_layout_post_type_bottom_sheet_fragment"
@@ -30,7 +21,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
- android:layout_marginEnd="32dp"
+ android:layout_marginEnd="48dp"
android:src="@drawable/ic_outline_text_24px"
android:tint="@color/primaryTextColor" />
@@ -38,7 +29,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:text="@string/bottom_sheet_post_text" />
+ android:text="@string/bottom_sheet_post_text"
+ android:textColor="@color/primaryTextColor" />
</LinearLayout>
@@ -58,7 +50,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
- android:layout_marginEnd="32dp"
+ android:layout_marginEnd="48dp"
android:src="@drawable/ic_link"
android:tint="@color/primaryTextColor" />
@@ -66,7 +58,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:text="@string/bottom_sheet_post_link" />
+ android:text="@string/bottom_sheet_post_link"
+ android:textColor="@color/primaryTextColor" />
</LinearLayout>
@@ -86,7 +79,7 @@
android:layout_width="18dp"
android:layout_height="18dp"
android:layout_gravity="center_vertical"
- android:layout_marginEnd="32dp"
+ android:layout_marginEnd="48dp"
android:src="@drawable/ic_menu_gallery"
android:tint="@color/primaryTextColor" />
@@ -94,7 +87,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:text="@string/bottom_sheet_post_image" />
+ android:text="@string/bottom_sheet_post_image"
+ android:textColor="@color/primaryTextColor" />
</LinearLayout>
@@ -114,7 +108,7 @@
<ImageView
android:layout_width="18dp"
android:layout_height="18dp"
- android:layout_marginEnd="32dp"
+ android:layout_marginEnd="48dp"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_outline_video_label_24px"
android:tint="@color/primaryTextColor" />
@@ -123,7 +117,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
- android:text="@string/bottom_sheet_post_video" />
+ android:text="@string/bottom_sheet_post_video"
+ android:textColor="@color/primaryTextColor" />
</LinearLayout>
diff --git a/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml
new file mode 100644
index 00000000..1db23d62
--- /dev/null
+++ b/app/src/main/res/layout/fragment_search_post_sort_type_bottom_sheet.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="8dp">
+
+ <TextView
+ android:id="@+id/relevance_type_text_view_search_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_relevance"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/hot_type_text_view_search_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_hot"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/top_type_text_view_search_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_top"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/new_type_text_view_search_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_new"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/comments_type_text_view_search_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_comments"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_search_user_and_subreddit_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_search_user_and_subreddit_sort_type_bottom_sheet.xml
new file mode 100644
index 00000000..acc7e65a
--- /dev/null
+++ b/app/src/main/res/layout/fragment_search_user_and_subreddit_sort_type_bottom_sheet.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="8dp"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_relevance"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+ <TextView
+ android:id="@+id/activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/sort_activity"
+ android:textColor="@color/primaryTextColor"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:paddingStart="32dp"
+ android:paddingEnd="32dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml b/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml
index d3977d81..e059a36b 100644
--- a/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml
+++ b/app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml
@@ -5,21 +5,11 @@
android:paddingBottom="8dp">
<TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="24dp"
- android:paddingBottom="16dp"
- android:paddingStart="32dp"
- android:paddingEnd="32dp"
- android:text="@string/sort"
- android:textColor="@color/primaryTextColor"
- android:textSize="18sp" />
-
- <TextView
android:id="@+id/best_type_text_view_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_best"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -33,6 +23,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_hot"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -46,6 +37,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_new"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -59,6 +51,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_random"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -72,6 +65,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_rising"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -85,6 +79,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_top"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
@@ -98,6 +93,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/sort_controversial"
+ android:textColor="@color/primaryTextColor"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingStart="32dp"
diff --git a/app/src/main/res/menu/search_result_activity.xml b/app/src/main/res/menu/search_result_activity.xml
index 1fe4fd88..b4db6c93 100644
--- a/app/src/main/res/menu/search_result_activity.xml
+++ b/app/src/main/res/menu/search_result_activity.xml
@@ -2,15 +2,22 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
- android:id="@+id/action_search_search_result_activity"
+ android:id="@+id/action_sort_search_result_activity"
android:orderInCategory="1"
android:title="@string/action_search"
+ android:icon="@drawable/ic_outline_sort_24px"
+ app:showAsAction="ifRoom" />
+
+ <item
+ android:id="@+id/action_search_search_result_activity"
+ android:orderInCategory="2"
+ android:title="@string/action_search"
android:icon="@drawable/ic_search_white_24dp"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_refresh_search_result_activity"
- android:orderInCategory="2"
+ android:orderInCategory="3"
android:title="@string/action_refresh"
app:showAsAction="never" />
</menu> \ No newline at end of file
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index 6b6e8290..a08dfe08 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -23,4 +23,8 @@
<color name="backgroundColor">#121212</color>
<color name="backgroundColorPrimaryDark">#1565C0</color>
+
+ <color name="roundedBottomSheetPrimaryBackground">#242424</color>
+
+ <color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color>
</resources>
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index a4f27cd2..ff024d93 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -24,5 +24,7 @@
<color name="backgroundColorPrimaryDark">@color/colorPrimaryDark</color>
+ <color name="roundedBottomSheetPrimaryBackground">#FFFFFF</color>
+
<color name="roundedBottomSheetPrimaryNavigationBarColor">#000000</color>
</resources>
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index ddc21110..eabd373e 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -7,7 +7,6 @@
<dimen name="fab_margin">16dp</dimen>
<dimen name="app_bar_height">180dp</dimen>
<dimen name="text_margin">16dp</dimen>
- <dimen name="roundedBottomSheetCornerRadiusTopPadding">0dp</dimen>
<dimen name="roundedBottomSheetCornerRadiusLeftPadding">0dp</dimen>
<dimen name="roundedBottomSheetCornerRadiusRightPadding">0dp</dimen>
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 80775602..8be8345e 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -142,7 +142,7 @@
<string name="sort_rising">Rising</string>
<string name="sort_top">Top</string>
<string name="sort_controversial">Controversial</string>
-
- <!-- TODO: Remove or change this placeholder text -->
- <string name="hello_blank_fragment">Hello blank fragment</string>
+ <string name="sort_relevance">Relevance</string>
+ <string name="sort_comments">Comments</string>
+ <string name="sort_activity">Activity</string>
</resources>