diff options
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
10 files changed, 68 insertions, 32 deletions
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<RecyclerVi authorTextView.setOnClickListener(view -> { 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<Post, Recy } } else { if (post.getAuthorIconUrl() == null) { - String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor(); - mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> { + 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<Post, Recy } } else { if (post.getAuthorIconUrl() == null) { - String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor(); - mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> { + 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<Post, Recy 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 (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); } }); @@ -3496,7 +3497,7 @@ public class HistoryPostRecyclerViewAdapter extends PagingDataAdapter<Post, Recy intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, post.getSubredditName()); mActivity.startActivity(intent); - } else { + } else if (!post.isAuthorDeleted()) { Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor()); mActivity.startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java index 915cc292..1eea5041 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MessageRecyclerViewAdapter.java @@ -219,6 +219,9 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl }); ((DataViewHolder) holder).authorTextView.setOnClickListener(view -> { + 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<Recycler ((PostDetailBaseViewHolder) holder).mTitleTextView.setText(mPost.getTitle()); if (mPost.getSubredditNamePrefixed().startsWith("u/")) { 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 -> { if (mActivity != null && getItemCount() > 0) { if (iconImageUrl == null || iconImageUrl.equals("")) { @@ -1110,6 +1110,9 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler }); mUserTextView.setOnClickListener(view -> { + 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<Post, RecyclerVie } } else { if (post.getAuthorIconUrl() == null) { - String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor(); - mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> { + 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<Post, RecyclerVie } } else { if (post.getAuthorIconUrl() == null) { - String authorName = post.getAuthor().equals("[deleted]") ? post.getSubredditName() : post.getAuthor(); - mFragment.loadIcon(authorName, post.getAuthor().equals("[deleted]"), (subredditOrUserName, iconUrl) -> { + 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<Post, RecyclerVie }); userTextView.setOnClickListener(view -> { - 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<Post, RecyclerVie intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, post.getSubredditName()); mActivity.startActivity(intent); - } else { + } else if (!post.isAuthorDeleted()) { Intent intent = new Intent(mActivity, ViewUserDetailActivity.class); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, post.getAuthor()); mActivity.startActivity(intent); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java index 2dc24c71..e617340f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PrivateMessagesDetailRecyclerViewAdapter.java @@ -182,6 +182,9 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt }); ((ReceivedMessageViewHolder) holder).userAvatarImageView.setOnClickListener(view -> { + 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; |