diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java index e969f1a0..30200a01 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPrivateMessagesActivity.java @@ -195,6 +195,9 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit if (privateMessage.getAuthor().equals(mAccountName)) { setTitle(privateMessage.getDestination()); mToolbar.setOnClickListener(view -> { + if (privateMessage.isDestinationDeleted()) { + return; + } Intent intent = new Intent(this, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getDestination()); startActivity(intent); @@ -202,6 +205,9 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit } else { setTitle(privateMessage.getAuthor()); mToolbar.setOnClickListener(view -> { + if (privateMessage.isAuthorDeleted()) { + return; + } Intent intent = new Intent(this, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, privateMessage.getAuthor()); startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java index 75ddc811..20c5521d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/CommentsRecyclerViewAdapter.java @@ -1584,11 +1584,12 @@ public class CommentsRecyclerViewAdapter extends RecyclerView.Adapter { Comment comment = getCurrentComment(this); - if (comment != null) { - Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); - intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor()); - mActivity.startActivity(intent); + if (comment == null || comment.isAuthorDeleted()) { + return; } + Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); + intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getAuthor()); + mActivity.startActivity(intent); }); authorIconImageView.setOnClickListener(view -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java index a254bef3..39639da2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/HistoryPostRecyclerViewAdapter.java @@ -565,8 +565,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter { + String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor(); + mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> { if (mActivity != null && getItemCount() > 0) { if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) { mGlide.load(R.drawable.subreddit_default_icon) @@ -1118,8 +1118,8 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter { + String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor(); + mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> { if (mActivity != null && getItemCount() > 0 && authorName.equals(subredditOrUserName)) { if (iconUrl == null || iconUrl.equals("")) { mGlide.load(R.drawable.subreddit_default_icon) @@ -2219,12 +2219,13 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter { + if (message.isAuthorDeleted()) { + return; + } Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor()); mActivity.startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 35606d65..db468d42 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -466,7 +466,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { if (mActivity != null && getItemCount() > 0) { if (iconImageUrl == null || iconImageUrl.equals("")) { @@ -1110,6 +1110,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter { + if (mPost.isAuthorDeleted()) { + return; + } Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, mPost.getAuthor()); 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 0f171394..1f9f9af8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -596,8 +596,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor(); + mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> { if (mActivity != null && getItemCount() > 0) { if (iconUrl == null || iconUrl.equals("") && authorName.equals(subredditOrUserName)) { mGlide.load(R.drawable.subreddit_default_icon) @@ -1171,8 +1171,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + String authorName = post.isAuthorDeleted() ? post.getSubredditName() : post.getAuthor(); + mFragment.loadIcon(authorName, post.isAuthorDeleted(), (subredditOrUserName, iconUrl) -> { if (mActivity != null && getItemCount() > 0 && authorName.equals(subredditOrUserName)) { if (iconUrl == null || iconUrl.equals("")) { mGlide.load(R.drawable.subreddit_default_icon) @@ -2316,19 +2316,21 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { - if (canStartActivity) { - int position = getBindingAdapterPosition(); - if (position < 0) { - return; - } - Post post = getItem(position); - if (post != null) { - canStartActivity = false; - Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); - intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor()); - mActivity.startActivity(intent); - } + if (!canStartActivity) { + return; } + int position = getBindingAdapterPosition(); + if (position < 0) { + return; + } + Post post = getItem(position); + if (post == null || post.isAuthorDeleted()) { + return; + } + canStartActivity = false; + Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); + intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor()); + mActivity.startActivity(intent); }); if (mDisplaySubredditName) { @@ -3635,7 +3637,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + if (message.isAuthorDeleted()) { + return; + } Intent intent = new Intent(mViewPrivateMessagesActivity, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, message.getAuthor()); mViewPrivateMessagesActivity.startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java index fd06e0e7..c296b8ac 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/Comment.java @@ -159,6 +159,10 @@ public class Comment implements Parcelable { return author; } + public boolean isAuthorDeleted() { + return author != null && author.equals("[deleted]"); + } + public void setAuthor(String author) { this.author = author; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/message/Message.java b/app/src/main/java/ml/docilealligator/infinityforreddit/message/Message.java index eb3524c9..a39624a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/message/Message.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/message/Message.java @@ -123,10 +123,19 @@ public class Message implements Parcelable { return author; } + public boolean isAuthorDeleted() { + return author != null && author.equals("[deleted]"); + } + public String getDestination() { return destination; } + public boolean isDestinationDeleted() + { + return destination != null && destination.equals("[deleted]"); + } + public String getParentFullName() { return parentFullName; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java index 090e7005..230921bb 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/Post.java @@ -230,6 +230,10 @@ public class Post implements Parcelable { return author; } + public boolean isAuthorDeleted() { + return author != null && author.equals("[deleted]"); + } + public void setAuthor(String author) { this.author = author; this.authorNamePrefixed = "u/" + author;