aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java152
-rw-r--r--app/src/main/res/layout/fragment_sort_type_bottom_sheet.xml19
6 files changed, 58 insertions, 128 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
index f97944c3..1a3bfa31 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/FilteredThingActivity.java
@@ -252,7 +252,6 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
Bundle multiRedditBundle = new Bundle();
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
- multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle);
break;
case PostDataSource.TYPE_USER:
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
index 2272e448..5daee793 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/MainActivity.java
@@ -723,7 +723,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
} else {
bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, false);
}
- bundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
sortTypeBottomSheetFragment.setArguments(bundle);
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
return true;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
index 91c7512a..b2280232 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewMultiRedditDetailActivity.java
@@ -164,7 +164,6 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
Bundle bottomSheetBundle = new Bundle();
bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
- bottomSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_RANDOM_TYPE, true);
sortTypeBottomSheetFragment.setArguments(bottomSheetBundle);
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java
index ee5ba39f..d86bb207 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/BottomSheetFragment/SortTypeBottomSheetFragment.java
@@ -29,15 +29,12 @@ import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragment {
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
- public static final String EXTRA_NO_RANDOM_TYPE = "ENRT";
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
TextView bestTypeTextView;
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
TextView hotTypeTextView;
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
TextView newTypeTextView;
- @BindView(R.id.random_type_text_view_sort_type_bottom_sheet_fragment)
- TextView randomTypeTextView;
@BindView(R.id.rising_type_text_view_sort_type_bottom_sheet_fragment)
TextView risingTypeTextView;
@BindView(R.id.top_type_text_view_sort_type_bottom_sheet_fragment)
@@ -79,15 +76,6 @@ public class SortTypeBottomSheetFragment extends RoundedBottomSheetDialogFragmen
dismiss();
});
- if (getArguments() == null || (getArguments().containsKey(EXTRA_NO_RANDOM_TYPE) && getArguments().getBoolean(EXTRA_NO_RANDOM_TYPE))) {
- randomTypeTextView.setVisibility(View.GONE);
- } else {
- randomTypeTextView.setOnClickListener(view -> {
- ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RANDOM));
- dismiss();
- });
- }
-
risingTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.RISING));
dismiss();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java
index e0c4a9a3..d444a0b6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post/PostDataSource.java
@@ -247,56 +247,38 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) {
- if (sortType.getType().value.equals(SortType.Type.RANDOM.value)) {
- ParsePost.parsePost(response.body(), locale, new ParsePost.ParsePostListener() {
- @Override
- public void onParsePostSuccess(Post post) {
- ArrayList<Post> singlePostList = new ArrayList<>();
- singlePostList.add(post);
- callback.onResult(singlePostList, null, null);
- hasPostLiveData.postValue(true);
- initialLoadStateLiveData.postValue(NetworkState.LOADED);
- }
-
- @Override
- public void onParsePostFail() {
- initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data"));
- }
- });
- } else {
- ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
- new ParsePost.ParsePostsListingListener() {
- @Override
- public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
- String nextPageKey;
- if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
- nextPageKey = null;
- } else {
- nextPageKey = lastItem;
- }
-
- if (newPosts.size() != 0) {
- postLinkedHashSet.addAll(newPosts);
- callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
- hasPostLiveData.postValue(true);
- } else if (nextPageKey != null) {
- loadBestPostsInitial(callback, nextPageKey);
- return;
- } else {
- postLinkedHashSet.addAll(newPosts);
- callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
- hasPostLiveData.postValue(false);
- }
-
- initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
+ new ParsePost.ParsePostsListingListener() {
+ @Override
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
+ String nextPageKey;
+ if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
+ nextPageKey = null;
+ } else {
+ nextPageKey = lastItem;
}
- @Override
- public void onParsePostsListingFail() {
- initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
+ if (newPosts.size() != 0) {
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
+ hasPostLiveData.postValue(true);
+ } else if (nextPageKey != null) {
+ loadBestPostsInitial(callback, nextPageKey);
+ return;
+ } else {
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
+ hasPostLiveData.postValue(false);
}
- });
- }
+
+ initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ }
+
+ @Override
+ public void onParsePostsListingFail() {
+ initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
+ }
+ });
} else {
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
"code: " + response.code() + " message: " + response.message()));
@@ -388,56 +370,38 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull retrofit2.Response<String> response) {
if (response.isSuccessful()) {
- if (sortType.getType().value.equals(SortType.Type.RANDOM.value)) {
- ParsePost.parsePost(response.body(), locale, new ParsePost.ParsePostListener() {
- @Override
- public void onParsePostSuccess(Post post) {
- ArrayList<Post> singlePostList = new ArrayList<>();
- singlePostList.add(post);
- callback.onResult(singlePostList, null, null);
- hasPostLiveData.postValue(true);
- initialLoadStateLiveData.postValue(NetworkState.LOADED);
- }
-
- @Override
- public void onParsePostFail() {
- initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing data"));
- }
- });
- } else {
- ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
- new ParsePost.ParsePostsListingListener() {
- @Override
- public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
- String nextPageKey;
- if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
- nextPageKey = null;
- } else {
- nextPageKey = lastItem;
- }
-
- if (newPosts.size() != 0) {
- postLinkedHashSet.addAll(newPosts);
- callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
- hasPostLiveData.postValue(true);
- } else if (nextPageKey != null) {
- loadSubredditPostsInitial(callback, nextPageKey);
- return;
- } else {
- postLinkedHashSet.addAll(newPosts);
- callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
- hasPostLiveData.postValue(false);
- }
-
- initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ ParsePost.parsePosts(response.body(), locale, -1, filter, nsfw,
+ new ParsePost.ParsePostsListingListener() {
+ @Override
+ public void onParsePostsListingSuccess(LinkedHashSet<Post> newPosts, String lastItem) {
+ String nextPageKey;
+ if (lastItem == null || lastItem.equals("") || lastItem.equals("null")) {
+ nextPageKey = null;
+ } else {
+ nextPageKey = lastItem;
}
- @Override
- public void onParsePostsListingFail() {
- initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
+ if (newPosts.size() != 0) {
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
+ hasPostLiveData.postValue(true);
+ } else if (nextPageKey != null) {
+ loadSubredditPostsInitial(callback, nextPageKey);
+ return;
+ } else {
+ postLinkedHashSet.addAll(newPosts);
+ callback.onResult(new ArrayList<>(newPosts), null, nextPageKey);
+ hasPostLiveData.postValue(false);
}
- });
- }
+
+ initialLoadStateLiveData.postValue(NetworkState.LOADED);
+ }
+
+ @Override
+ public void onParsePostsListingFail() {
+ initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED, "Error parsing posts"));
+ }
+ });
} else {
initialLoadStateLiveData.postValue(new NetworkState(NetworkState.Status.FAILED,
"code: " + response + " message: " + response.message()));
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 d5c9e34d..91c0ed62 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
@@ -69,25 +69,6 @@
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
- android:id="@+id/random_type_text_view_sort_type_bottom_sheet_fragment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?attr/selectableItemBackground"
- android:clickable="true"
- android:drawableStart="@drawable/ic_random_24"
- android:drawablePadding="48dp"
- android:focusable="true"
- android:fontFamily="?attr/font_family"
- android:paddingStart="32dp"
- android:paddingTop="16dp"
- android:paddingEnd="32dp"
- android:paddingBottom="16dp"
- android:text="@string/sort_random"
- android:textColor="?attr/primaryTextColor"
- android:textSize="?attr/font_default"
- app:drawableTint="?attr/primaryTextColor" />
-
- <androidx.appcompat.widget.AppCompatTextView
android:id="@+id/rising_type_text_view_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"