mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
If an author is deleted and is clicked, don't switch to view user (#1287)
* If an author is deleted and is clicked, don't switch to the view user detail activity, since it'll just error. * Fix a canStartActivity check.
This commit is contained in:
parent
206296db5e
commit
c0deb78734
@ -195,6 +195,9 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
if (privateMessage.getAuthor().equals(mAccountName)) {
|
if (privateMessage.getAuthor().equals(mAccountName)) {
|
||||||
setTitle(privateMessage.getDestination());
|
setTitle(privateMessage.getDestination());
|
||||||
mToolbar.setOnClickListener(view -> {
|
mToolbar.setOnClickListener(view -> {
|
||||||
|
if (privateMessage.isDestinationDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
@ -202,6 +205,9 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
} else {
|
} else {
|
||||||
setTitle(privateMessage.getAuthor());
|
setTitle(privateMessage.getAuthor());
|
||||||
mToolbar.setOnClickListener(view -> {
|
mToolbar.setOnClickListener(view -> {
|
||||||
|
if (privateMessage.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
@ -1584,11 +1584,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVi
|
|||||||
|
|
||||||
authorTextView.setOnClickListener(view -> {
|
authorTextView.setOnClickListener(view -> {
|
||||||
Comment comment = getCurrentComment(this);
|
Comment comment = getCurrentComment(this);
|
||||||
if (comment != null) {
|
if (comment == null || comment.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
authorIconImageView.setOnClickListener(view -> {
|
authorIconImageView.setOnClickListener(view -> {
|
||||||
|
@ -565,8 +565,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (post.getAuthorIconUrl() == null) {
|
if (post.getAuthorIconUrl() == null) {
|
||||||
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor();
|
String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor();
|
||||||
mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> {
|
mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> {
|
||||||
if (mActivity != null && getItemCount() > 0) {
|
if (mActivity != null && getItemCount() > 0) {
|
||||||
if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) {
|
if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -1118,8 +1118,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (post.getAuthorIconUrl() == null) {
|
if (post.getAuthorIconUrl() == null) {
|
||||||
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor();
|
String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor();
|
||||||
mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> {
|
mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> {
|
||||||
if (mActivity != null && getItemCount() > 0 && authorName.equals(subredditOrUserName)) {
|
if (mActivity != null && getItemCount() > 0 && authorName.equals(subredditOrUserName)) {
|
||||||
if (iconUrl == null || iconUrl.equals("")) {
|
if (iconUrl == null || iconUrl.equals("")) {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -2219,13 +2219,14 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post == null || post.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
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());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mDisplaySubredditName) {
|
if (mDisplaySubredditName) {
|
||||||
@ -3496,7 +3497,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy
|
|||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||||
post.getSubredditName());
|
post.getSubredditName());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else {
|
} else if (!post.isAuthorDeleted()) {
|
||||||
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());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
|
@ -219,6 +219,9 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
});
|
});
|
||||||
|
|
||||||
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||||
|
if (message.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
|
@ -466,7 +466,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle());
|
((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle());
|
||||||
if (mPost.getSubredditNamePrefixed().startsWith("u/")) {
|
if (mPost.getSubredditNamePrefixed().startsWith("u/")) {
|
||||||
if (mPost.getAuthorIconUrl() == null) {
|
if (mPost.getAuthorIconUrl() == null) {
|
||||||
String authorName = mPost.getAuthor().equals("[deleted]") ? mPost.getSubredditNamePrefixed().substring(2) : mPost.getAuthor();
|
String authorName = mPost.isAuthorDeleted() ? mPost.getSubredditNamePrefixed().substring(2) : mPost.getAuthor();
|
||||||
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase, authorName, mOauthRetrofit, iconImageUrl -> {
|
LoadUserData.loadUserData(mExecutor, new Handler(), mRedditDataRoomDatabase, authorName, mOauthRetrofit, iconImageUrl -> {
|
||||||
if (mActivity != null && getItemCount() > 0) {
|
if (mActivity != null && getItemCount() > 0) {
|
||||||
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
if (iconImageUrl == null || iconImageUrl.equals("")) {
|
||||||
@ -1110,6 +1110,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler
|
|||||||
});
|
});
|
||||||
|
|
||||||
mUserTextView.setOnClickListener(view -> {
|
mUserTextView.setOnClickListener(view -> {
|
||||||
|
if (mPost.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
|
@ -596,8 +596,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (post.getAuthorIconUrl() == null) {
|
if (post.getAuthorIconUrl() == null) {
|
||||||
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor();
|
String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor();
|
||||||
mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> {
|
mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> {
|
||||||
if (mActivity != null && getItemCount() > 0) {
|
if (mActivity != null && getItemCount() > 0) {
|
||||||
if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) {
|
if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -1171,8 +1171,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (post.getAuthorIconUrl() == null) {
|
if (post.getAuthorIconUrl() == null) {
|
||||||
String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor();
|
String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor();
|
||||||
mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> {
|
mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> {
|
||||||
if (mActivity != null && getItemCount() > 0 && authorName.equals(subredditOrUserName)) {
|
if (mActivity != null && getItemCount() > 0 && authorName.equals(subredditOrUserName)) {
|
||||||
if (iconUrl == null || iconUrl.equals("")) {
|
if (iconUrl == null || iconUrl.equals("")) {
|
||||||
mGlide.load(R.drawable.subreddit_default_icon)
|
mGlide.load(R.drawable.subreddit_default_icon)
|
||||||
@ -2316,19 +2316,21 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
});
|
});
|
||||||
|
|
||||||
userTextView.setOnClickListener(view -> {
|
userTextView.setOnClickListener(view -> {
|
||||||
if (canStartActivity) {
|
if (!canStartActivity) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int position = getBindingAdapterPosition();
|
int position = getBindingAdapterPosition();
|
||||||
if (position < 0) {
|
if (position < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Post post = getItem(position);
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post == null || post.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
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());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (mDisplaySubredditName) {
|
if (mDisplaySubredditName) {
|
||||||
@ -3635,7 +3637,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
|
|||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY,
|
||||||
post.getSubredditName());
|
post.getSubredditName());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else {
|
} else if (!post.isAuthorDeleted()) {
|
||||||
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());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
|
@ -182,6 +182,9 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
});
|
});
|
||||||
|
|
||||||
((ReceivedMessageViewHolder) holder).userAvatarImageView.setOnClickListener(view -> {
|
((ReceivedMessageViewHolder) holder).userAvatarImageView.setOnClickListener(view -> {
|
||||||
|
if (message.isAuthorDeleted()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Intent intent = new Intent(mViewPrivateMessagesActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mViewPrivateMessagesActivity, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor());
|
||||||
mViewPrivateMessagesActivity.startActivity(intent);
|
mViewPrivateMessagesActivity.startActivity(intent);
|
||||||
|
@ -159,6 +159,10 @@ public class Comment implements Parcelable {
|
|||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAuthorDeleted() {
|
||||||
|
return author != null && author.equals("[deleted]");
|
||||||
|
}
|
||||||
|
|
||||||
public void setAuthor(String author) {
|
public void setAuthor(String author) {
|
||||||
this.author = author;
|
this.author = author;
|
||||||
}
|
}
|
||||||
|
@ -123,10 +123,19 @@ public class Message implements Parcelable {
|
|||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAuthorDeleted() {
|
||||||
|
return author != null && author.equals("[deleted]");
|
||||||
|
}
|
||||||
|
|
||||||
public String getDestination() {
|
public String getDestination() {
|
||||||
return destination;
|
return destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDestinationDeleted()
|
||||||
|
{
|
||||||
|
return destination != null && destination.equals("[deleted]");
|
||||||
|
}
|
||||||
|
|
||||||
public String getParentFullName() {
|
public String getParentFullName() {
|
||||||
return parentFullName;
|
return parentFullName;
|
||||||
}
|
}
|
||||||
|
@ -230,6 +230,10 @@ public class Post implements Parcelable {
|
|||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAuthorDeleted() {
|
||||||
|
return author != null && author.equals("[deleted]");
|
||||||
|
}
|
||||||
|
|
||||||
public void setAuthor(String author) {
|
public void setAuthor(String author) {
|
||||||
this.author = author;
|
this.author = author;
|
||||||
this.authorNamePrefixed = "u/" + author;
|
this.authorNamePrefixed = "u/" + author;
|
||||||
|
Loading…
Reference in New Issue
Block a user