mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 20:37:12 +01:00
Click a flair to see filtered posts. Fix filtering posts that contain certain flairs.
This commit is contained in:
parent
e4c9f7b927
commit
68d8aaf61d
@ -63,6 +63,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
public static final String EXTRA_NAME = "ESN";
|
||||
public static final String EXTRA_QUERY = "EQ";
|
||||
public static final String EXTRA_FILTER = "EF";
|
||||
public static final String EXTRA_CONTAIN_FLAIR = "ECF";
|
||||
public static final String EXTRA_POST_TYPE = "EPT";
|
||||
public static final String EXTRA_USER_WHERE = "EUW";
|
||||
|
||||
@ -213,6 +214,11 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
break;
|
||||
}
|
||||
|
||||
String flair = getIntent().getStringExtra(EXTRA_CONTAIN_FLAIR);
|
||||
if (flair != null) {
|
||||
postFilter.containFlairs = flair;
|
||||
}
|
||||
|
||||
if (postType == PostDataSource.TYPE_USER) {
|
||||
userWhere = getIntent().getStringExtra(EXTRA_USER_WHERE);
|
||||
if (userWhere != null && !PostDataSource.USER_WHERE_SUBMITTED.equals(userWhere) && mMenu != null) {
|
||||
@ -262,7 +268,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
|
||||
private void bindView(PostFilter postFilter, boolean initializeFragment) {
|
||||
switch (postType) {
|
||||
case PostDataSource.TYPE_FRONT_PAGE:
|
||||
getSupportActionBar().setTitle(name);
|
||||
getSupportActionBar().setTitle(R.string.home);
|
||||
break;
|
||||
case PostDataSource.TYPE_SEARCH:
|
||||
getSupportActionBar().setTitle(R.string.search);
|
||||
|
@ -2182,6 +2182,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
mFlairTextView.setOnClickListener(view -> {
|
||||
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_CONTAIN_FLAIR, mPost.getFlair());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
mNSFWTextView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mActivity, FilteredPostsActivity.class);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_NAME, mSubredditNamePrefixed.substring(2));
|
||||
|
@ -2014,6 +2014,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
|
||||
void typeChipClicked(int filter);
|
||||
|
||||
void flairChipClicked(String flair);
|
||||
|
||||
void nsfwChipClicked();
|
||||
|
||||
void currentlyBindItem(int position);
|
||||
@ -2304,6 +2306,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
mCallback.typeChipClicked(post.getPostType());
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
int position = getBindingAdapterPosition();
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
Post post = getItem(position);
|
||||
if (post != null) {
|
||||
mCallback.flairChipClicked(post.getFlair());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
upvoteButton.setOnClickListener(view -> {
|
||||
@ -3257,6 +3270,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
});
|
||||
|
||||
flairTextView.setOnClickListener(view -> {
|
||||
int position = getBindingAdapterPosition();
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
Post post = getItem(position);
|
||||
if (post != null && !(mActivity instanceof FilteredPostsActivity)) {
|
||||
mCallback.flairChipClicked(post.getFlair());
|
||||
}
|
||||
});
|
||||
|
||||
imageView.setOnClickListener(view -> {
|
||||
int position = getBindingAdapterPosition();
|
||||
if (position < 0) {
|
||||
|
@ -457,6 +457,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flairChipClicked(String flair) {
|
||||
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_CONTAIN_FLAIR, flair);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
@ -525,6 +535,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flairChipClicked(String flair) {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_NAME, subredditName);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_CONTAIN_FLAIR, flair);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
@ -592,6 +611,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flairChipClicked(String flair) {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_NAME, multiRedditPath);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_CONTAIN_FLAIR, flair);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
@ -660,6 +688,16 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flairChipClicked(String flair) {
|
||||
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_CONTAIN_FLAIR, flair);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
@ -709,16 +747,22 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
@Override
|
||||
public void typeChipClicked(int 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 flairChipClicked(String flair) {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_CONTAIN_FLAIR, flair);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
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);
|
||||
@ -762,16 +806,22 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
@Override
|
||||
public void typeChipClicked(int 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 flairChipClicked(String flair) {
|
||||
Intent intent = new Intent(activity, FilteredPostsActivity.class);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_POST_TYPE, postType);
|
||||
intent.putExtra(FilteredPostsActivity.EXTRA_CONTAIN_FLAIR, flair);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nsfwChipClicked() {
|
||||
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);
|
||||
|
@ -213,10 +213,20 @@ public class PostFilter implements Parcelable {
|
||||
}
|
||||
if (postFilter.containFlairs != null && !postFilter.containFlairs.equals("")) {
|
||||
String[] flairs = postFilter.containFlairs.split(",", 0);
|
||||
for (String f : flairs) {
|
||||
if (!f.trim().equals("") && post.getFlair().equalsIgnoreCase(f.trim())) {
|
||||
return false;
|
||||
if (flairs.length > 0) {
|
||||
boolean match = false;
|
||||
for (int i = 0; i < flairs.length; i++) {
|
||||
String flair = flairs[i].trim();
|
||||
if (flair.equals("") && i == flairs.length - 1) {
|
||||
return false;
|
||||
}
|
||||
if (!flair.equals("") && post.getFlair().equalsIgnoreCase(flair)) {
|
||||
match = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return match;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user