aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-12-23 03:54:20 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-12-23 03:54:20 +0000
commit6747efbccb05e48f4d7759c923755287fedabbf3 (patch)
tree95e4695d0ffe0af44cb6a697bef1660ca478557f
parente4b7556844bbf5f11f3d68f0c7bde86c85a8ac9a (diff)
downloadinfinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.tar
infinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.tar.gz
infinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.tar.bz2
infinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.tar.lz
infinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.tar.xz
infinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.tar.zst
infinity-for-reddit-6747efbccb05e48f4d7759c923755287fedabbf3.zip
Send PostFilter to CustomizePostFilterActivity. Rename FilteredThingActivity to FilteredPostsActivity.
Diffstat (limited to '')
-rw-r--r--app/src/main/AndroidManifest.xml2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java (renamed from app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java)5
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java138
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java4
9 files changed, 105 insertions, 86 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 68bdf08c..4374f488 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -199,7 +199,7 @@
android:theme="@style/AppTheme.Slidable"
android:windowSoftInputMode="adjustResize" />
<activity
- android:name=".activities.FilteredThingActivity"
+ android:name=".activities.FilteredPostsActivity"
android:parentActivityName=".activities.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<activity
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 9f6fca2e..dc7be5e3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -16,7 +16,7 @@ import ml.docilealligator.infinityforreddit.activities.EditCommentActivity;
import ml.docilealligator.infinityforreddit.activities.EditMultiRedditActivity;
import ml.docilealligator.infinityforreddit.activities.EditPostActivity;
import ml.docilealligator.infinityforreddit.activities.FetchRandomSubredditOrPostActivity;
-import ml.docilealligator.infinityforreddit.activities.FilteredThingActivity;
+import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.GiveAwardActivity;
import ml.docilealligator.infinityforreddit.activities.InboxActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
@@ -119,7 +119,7 @@ public interface AppComponent {
void inject(SubmitPostService submitPostService);
- void inject(FilteredThingActivity filteredPostsActivity);
+ void inject(FilteredPostsActivity filteredPostsActivity);
void inject(SearchResultActivity searchResultActivity);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
index 7c7f450c..b1fe0162 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/FragmentCommunicator.java
@@ -42,6 +42,10 @@ public interface FragmentCommunicator {
default void changePostFilter(PostFilter postFilter) {
}
+ default PostFilter getPostFilter() {
+ return null;
+ }
+
default void filterPosts() {
};
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
index 4b06c261..680e1e59 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostFilter.java
@@ -100,7 +100,7 @@ public class PostFilter implements Parcelable {
if (postFilter.excludesSubreddits != null && !postFilter.excludesSubreddits.equals("")) {
String[] subreddits = postFilter.excludesSubreddits.split(",", 0);
for (String s : subreddits) {
- if (post.getSubredditName().equals(s)) {
+ if (post.getSubredditName().equalsIgnoreCase(s)) {
return false;
}
}
@@ -108,7 +108,7 @@ public class PostFilter implements Parcelable {
if (postFilter.excludesUsers != null && !postFilter.excludesUsers.equals("")) {
String[] users = postFilter.excludesUsers.split(",", 0);
for (String u : users) {
- if (post.getAuthor().equals(u)) {
+ if (post.getAuthor().equalsIgnoreCase(u)) {
return false;
}
}
@@ -116,7 +116,7 @@ public class PostFilter implements Parcelable {
if (postFilter.excludesFlairs != null && !postFilter.excludesFlairs.equals("")) {
String[] flairs = postFilter.excludesFlairs.split(",", 0);
for (String f : flairs) {
- if (post.getFlair().equals(f)) {
+ if (post.getFlair().equalsIgnoreCase(f)) {
return false;
}
}
@@ -124,7 +124,7 @@ public class PostFilter implements Parcelable {
if (postFilter.containsFlairs != null && !postFilter.containsFlairs.equals("")) {
String[] flairs = postFilter.containsFlairs.split(",", 0);
for (String f : flairs) {
- if (post.getFlair().equals(f)) {
+ if (post.getFlair().equalsIgnoreCase(f)) {
return false;
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
index bd855e40..38a1da5d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredThingActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java
@@ -53,7 +53,7 @@ import ml.docilealligator.infinityforreddit.post.PostDataSource;
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
-public class FilteredThingActivity extends BaseActivity implements SortTypeSelectionCallback,
+public class FilteredPostsActivity extends BaseActivity implements SortTypeSelectionCallback,
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, ActivityToolbarInterface,
MarkPostAsReadInterface, FilteredThingFABMoreOptionsBottomSheetFragment.FABOptionSelectionCallback {
@@ -364,6 +364,9 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
fab.setOnClickListener(view -> {
Intent intent = new Intent(this, CustomizePostFilterActivity.class);
+ if (mFragment != null) {
+ intent.putExtra(CustomizePostFilterActivity.EXTRA_POST_FILTER, mFragment.getPostFilter());
+ }
startActivityForResult(intent, CUSTOMIZE_POST_FILTER_ACTIVITY_REQUEST_CODE);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
index c18b2faa..f86a84a2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentAndPostRecyclerViewAdapter.java
@@ -86,7 +86,7 @@ import io.noties.markwon.simple.ext.SimpleExtPlugin;
import jp.wasabeef.glide.transformations.BlurTransformation;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.activities.CommentActivity;
-import ml.docilealligator.infinityforreddit.activities.FilteredThingActivity;
+import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
@@ -2135,18 +2135,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
});
mTypeTextView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, mPost.getPostType());
+ Intent intent = new Intent(mActivity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2));
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, mPost.getPostType());
mActivity.startActivity(intent);
});
mNSFWTextView.setOnClickListener(view -> {
- Intent intent = new Intent(mActivity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ Intent intent = new Intent(mActivity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2));
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, PostDataSource.TYPE_SUBREDDIT);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE);
mActivity.startActivity(intent);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
index db3ee84a..819874b7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java
@@ -76,7 +76,7 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SaveThing;
import ml.docilealligator.infinityforreddit.VoteThing;
-import ml.docilealligator.infinityforreddit.activities.FilteredThingActivity;
+import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.activities.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
@@ -1662,7 +1662,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
iconGifImageView.setOnClickListener(view -> userTextView.performClick());
}
- if (!(mActivity instanceof FilteredThingActivity)) {
+ if (!(mActivity instanceof FilteredPostsActivity)) {
nsfwTextView.setOnClickListener(view -> {
int position = getAdapterPosition();
if (position < 0) {
@@ -2655,7 +2655,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
return;
}
Post post = getItem(position);
- if (post != null && !(mActivity instanceof FilteredThingActivity)) {
+ if (post != null && !(mActivity instanceof FilteredPostsActivity)) {
mCallback.nsfwChipClicked();
}
});
@@ -2666,7 +2666,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
return;
}
Post post = getItem(position);
- if (post != null && !(mActivity instanceof FilteredThingActivity)) {
+ if (post != null && !(mActivity instanceof FilteredPostsActivity)) {
mCallback.typeChipClicked(post.getPostType());
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 6edeb8e8..4418cc43 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -70,7 +70,7 @@ 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.FilteredThingActivity;
+import ml.docilealligator.infinityforreddit.activities.FilteredPostsActivity;
import ml.docilealligator.infinityforreddit.activities.MainActivity;
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.activities.ViewUserDetailActivity;
@@ -427,14 +427,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
});
- } else if (activity instanceof FilteredThingActivity) {
+ } else if (activity instanceof FilteredPostsActivity) {
mPostRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
- ((FilteredThingActivity) activity).contentScrollDown();
+ ((FilteredPostsActivity) activity).contentScrollDown();
} else if (dy < 0) {
- ((FilteredThingActivity) activity).contentScrollUp();
+ ((FilteredPostsActivity) activity).contentScrollUp();
}
}
});
@@ -475,21 +475,21 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void typeChipClicked(int filter) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
- intent.putExtra(FilteredThingActivity.EXTRA_QUERY, query);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, filter);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredPostsActivity.EXTRA_QUERY, query);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter);
startActivity(intent);
}
@Override
public void nsfwChipClicked() {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
- intent.putExtra(FilteredThingActivity.EXTRA_QUERY, query);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredPostsActivity.EXTRA_QUERY, query);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE);
startActivity(intent);
}
@@ -534,19 +534,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void typeChipClicked(int filter) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, filter);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter);
startActivity(intent);
}
@Override
public void nsfwChipClicked() {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE);
startActivity(intent);
}
@@ -593,19 +593,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void typeChipClicked(int filter) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, filter);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter);
startActivity(intent);
}
@Override
public void nsfwChipClicked() {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE);
startActivity(intent);
}
@@ -650,21 +650,21 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void typeChipClicked(int filter) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, username);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_USER_WHERE, where);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, filter);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter);
startActivity(intent);
}
@Override
public void nsfwChipClicked() {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, username);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_USER_WHERE, where);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE);
startActivity(intent);
}
@@ -701,19 +701,19 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
@Override
public void typeChipClicked(int filter) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, activity.getString(R.string.best));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, filter);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, activity.getString(R.string.best));
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, filter);
startActivity(intent);
}
@Override
public void nsfwChipClicked() {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, activity.getString(R.string.best));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_FILTER, Post.NSFW_TYPE);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, activity.getString(R.string.best));
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_FILTER, Post.NSFW_TYPE);
startActivity(intent);
}
@@ -1258,33 +1258,41 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Override
+ public PostFilter getPostFilter() {
+ if (mPostViewModel != null) {
+ return mPostViewModel.getPostFilter();
+ }
+ return null;
+ }
+
+ @Override
public void filterPosts() {
if (postType == PostDataSource.TYPE_SEARCH) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
- intent.putExtra(FilteredThingActivity.EXTRA_QUERY, query);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredPostsActivity.EXTRA_QUERY, query);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
startActivity(intent);
} else if (postType == PostDataSource.TYPE_SUBREDDIT) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, subredditName);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
startActivity(intent);
} else if(postType == PostDataSource.TYPE_MULTI_REDDIT) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, multiRedditPath);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
startActivity(intent);
} else if (postType == PostDataSource.TYPE_USER) {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, username);
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
- intent.putExtra(FilteredThingActivity.EXTRA_USER_WHERE, where);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, username);
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
+ intent.putExtra(FilteredPostsActivity.EXTRA_USER_WHERE, where);
startActivity(intent);
} else {
- Intent intent = new Intent(activity, FilteredThingActivity.class);
- intent.putExtra(FilteredThingActivity.EXTRA_NAME, activity.getString(R.string.best));
- intent.putExtra(FilteredThingActivity.EXTRA_POST_TYPE, postType);
+ Intent intent = new Intent(activity, FilteredPostsActivity.class);
+ intent.putExtra(FilteredPostsActivity.EXTRA_NAME, activity.getString(R.string.best));
+ intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
startActivity(intent);
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java
index 716eabaf..83ffcd43 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java
@@ -200,6 +200,10 @@ public class PostViewModel extends ViewModel {
postFilterLiveData.postValue(postFilter);
}
+ public PostFilter getPostFilter() {
+ return postFilterLiveData.getValue();
+ }
+
public static class Factory extends ViewModelProvider.NewInstanceFactory {
private Retrofit retrofit;
private String accessToken;