Show and open r/u_ style subreddits in posts.

This commit is contained in:
Docile-Alligator 2022-02-28 18:01:30 +08:00
parent 405317b4cb
commit 2e67298813
2 changed files with 19 additions and 44 deletions

View File

@ -588,7 +588,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
} }
if (!mHideSubredditAndUserPrefix) { if (!mHideSubredditAndUserPrefix) {
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditNamePrefixed()); ((PostDetailBaseViewHolder) holder).mSubredditTextView.setText("r/" + mPost.getSubredditName());
((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthorNamePrefixed()); ((PostDetailBaseViewHolder) holder).mUserTextView.setText(mPost.getAuthorNamePrefixed());
} else { } else {
((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditName()); ((PostDetailBaseViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditName());
@ -1191,14 +1191,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
mSubredditTextView.setOnClickListener(view -> { mSubredditTextView.setOnClickListener(view -> {
Intent intent; Intent intent;
if (mPost.getSubredditNamePrefixed().equals("u/" + mPost.getAuthor())) {
intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
} else {
intent = new Intent(mActivity, ViewSubredditDetailActivity.class); intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
mPost.getSubredditNamePrefixed().substring(2)); mPost.getSubredditName());
}
mActivity.startActivity(intent); mActivity.startActivity(intent);
}); });

View File

@ -483,7 +483,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostBaseViewHolder) holder).subredditTextView.setText(post.getSubredditName()); ((PostBaseViewHolder) holder).subredditTextView.setText(post.getSubredditName());
((PostBaseViewHolder) holder).userTextView.setText(post.getAuthor()); ((PostBaseViewHolder) holder).userTextView.setText(post.getAuthor());
} else { } else {
((PostBaseViewHolder) holder).subredditTextView.setText(post.getSubredditNamePrefixed()); ((PostBaseViewHolder) holder).subredditTextView.setText("r/" + post.getSubredditName());
((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed); ((PostBaseViewHolder) holder).userTextView.setText(authorPrefixed);
} }
@ -1081,9 +1081,9 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mSubredditColor); ((PostCompactBaseViewHolder) holder).nameTextView.setTextColor(mSubredditColor);
if (mHideSubredditAndUserPrefix) { if (mHideSubredditAndUserPrefix) {
((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditName); ((PostCompactBaseViewHolder) holder).nameTextView.setText(post.getSubredditName());
} else { } else {
((PostCompactBaseViewHolder) holder).nameTextView.setText(subredditNamePrefixed); ((PostCompactBaseViewHolder) holder).nameTextView.setText("r/" + post.getSubredditName());
} }
} else { } else {
if (post.getAuthorIconUrl() == null) { if (post.getAuthorIconUrl() == null) {
@ -2201,19 +2201,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post != null) { if (post != null) {
if (canStartActivity) { if (canStartActivity) {
canStartActivity = false; canStartActivity = false;
if (post.getSubredditNamePrefixed().startsWith("u/")) {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
post.getSubredditNamePrefixed().substring(2));
mActivity.startActivity(intent);
} else {
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class); Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
post.getSubredditName()); post.getSubredditName());
mActivity.startActivity(intent); mActivity.startActivity(intent);
} }
} }
}
}); });
iconGifImageView.setOnClickListener(view -> subredditTextView.performClick()); iconGifImageView.setOnClickListener(view -> subredditTextView.performClick());
@ -2227,18 +2220,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post != null) { if (post != null) {
if (canStartActivity) { if (canStartActivity) {
canStartActivity = false; canStartActivity = false;
if (post.getSubredditNamePrefixed().startsWith("u/")) {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());
mActivity.startActivity(intent);
} else {
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class); Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
post.getSubredditName()); post.getSubredditName());
mActivity.startActivity(intent); mActivity.startActivity(intent);
} }
} }
}
}); });
iconGifImageView.setOnClickListener(view -> userTextView.performClick()); iconGifImageView.setOnClickListener(view -> userTextView.performClick());
@ -3278,17 +3265,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (post != null && canStartActivity) { if (post != null && canStartActivity) {
canStartActivity = false; canStartActivity = false;
if (mDisplaySubredditName) { if (mDisplaySubredditName) {
if (post.getSubredditNamePrefixed().startsWith("u/")) {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY,
post.getSubredditNamePrefixed().substring(2));
mActivity.startActivity(intent);
} else {
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class); Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
post.getSubredditNamePrefixed().substring(2)); post.getSubredditName());
mActivity.startActivity(intent); mActivity.startActivity(intent);
}
} else { } else {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor());