mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Validate index before performing onClick in PostRecyclerViewAdapter.
This commit is contained in:
parent
fd175178a2
commit
7d1aa07b9d
@ -1353,11 +1353,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
shareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
shareButton.setColorFilter(mPostIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
cardView.setOnClickListener(view -> {
|
cardView.setOnClickListener(view -> {
|
||||||
if (canStartActivity) {
|
int position = getAdapterPosition();
|
||||||
|
if (position > 0 && canStartActivity) {
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
|
|
||||||
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, getItem(getAdapterPosition()));
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, getItem(position));
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_LIST_POSITION, getAdapterPosition());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
@ -1365,7 +1366,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
userTextView.setOnClickListener(view -> {
|
userTextView.setOnClickListener(view -> {
|
||||||
if (canStartActivity) {
|
if (canStartActivity) {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
|
||||||
@ -1377,7 +1382,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
if (mDisplaySubredditName) {
|
if (mDisplaySubredditName) {
|
||||||
subredditTextView.setOnClickListener(view -> {
|
subredditTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (canStartActivity) {
|
if (canStartActivity) {
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
@ -1399,7 +1408,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
iconGifImageView.setOnClickListener(view -> subredditTextView.performClick());
|
iconGifImageView.setOnClickListener(view -> subredditTextView.performClick());
|
||||||
} else {
|
} else {
|
||||||
subredditTextView.setOnClickListener(view -> {
|
subredditTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (canStartActivity) {
|
if (canStartActivity) {
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
@ -1422,7 +1435,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
if (!(mActivity instanceof FilteredThingActivity)) {
|
if (!(mActivity instanceof FilteredThingActivity)) {
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
|
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
|
||||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
|
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
|
||||||
@ -1432,7 +1449,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
typeTextView.setOnClickListener(view -> {
|
typeTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
mCallback.typeChipClicked(post.getPostType());
|
mCallback.typeChipClicked(post.getPostType());
|
||||||
}
|
}
|
||||||
@ -1440,7 +1461,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
}
|
}
|
||||||
|
|
||||||
upvoteButton.setOnClickListener(view -> {
|
upvoteButton.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
@ -1514,7 +1539,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
downvoteButton.setOnClickListener(view -> {
|
downvoteButton.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
@ -1588,7 +1617,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
saveButton.setOnClickListener(view -> {
|
saveButton.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
@ -1640,7 +1673,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
shareButton.setOnClickListener(view -> {
|
shareButton.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
shareLink(post);
|
shareLink(post);
|
||||||
}
|
}
|
||||||
@ -1752,7 +1789,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
fullscreenButton.setOnClickListener(view -> {
|
fullscreenButton.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||||
@ -1955,7 +1996,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
errorTextView.setTextColor(mPrimaryTextColor);
|
errorTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||||
@ -2063,7 +2108,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
errorTextView.setTextColor(mPrimaryTextColor);
|
errorTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.getPostType() == Post.IMAGE_TYPE) {
|
if (post.getPostType() == Post.IMAGE_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class);
|
||||||
@ -2172,7 +2221,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
errorTextView.setTextColor(mPrimaryTextColor);
|
errorTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(post.getUrl());
|
Uri uri = Uri.parse(post.getUrl());
|
||||||
@ -2268,7 +2321,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
|
noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
|
||||||
|
|
||||||
noPreviewLinkImageView.setOnClickListener(view -> {
|
noPreviewLinkImageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(post.getUrl());
|
Uri uri = Uri.parse(post.getUrl());
|
||||||
@ -2373,7 +2430,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
errorTextView.setTextColor(mPrimaryTextColor);
|
errorTextView.setTextColor(mPrimaryTextColor);
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
|
Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class);
|
||||||
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
|
intent.putParcelableArrayListExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery());
|
||||||
@ -2607,7 +2668,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
noPreviewLinkImageFrameLayout.setClipToOutline(true);
|
noPreviewLinkImageFrameLayout.setClipToOutline(true);
|
||||||
|
|
||||||
itemView.setOnClickListener(view -> {
|
itemView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null && canStartActivity) {
|
if (post != null && canStartActivity) {
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
|
|
||||||
@ -2619,7 +2684,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
nameTextView.setOnClickListener(view -> {
|
nameTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null && canStartActivity) {
|
if (post != null && canStartActivity) {
|
||||||
canStartActivity = false;
|
canStartActivity = false;
|
||||||
if (mDisplaySubredditName) {
|
if (mDisplaySubredditName) {
|
||||||
@ -2645,7 +2714,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
iconGifImageView.setOnClickListener(view -> nameTextView.performClick());
|
iconGifImageView.setOnClickListener(view -> nameTextView.performClick());
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null && !(mActivity instanceof FilteredThingActivity)) {
|
if (post != null && !(mActivity instanceof FilteredThingActivity)) {
|
||||||
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
|
Intent intent = new Intent(mActivity, FilteredThingActivity.class);
|
||||||
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
|
intent.putExtra(FilteredThingActivity.EXTRA_NAME, post.getSubredditNamePrefixed().substring(2));
|
||||||
@ -2656,14 +2729,22 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
typeTextView.setOnClickListener(view -> {
|
typeTextView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null && !(mActivity instanceof FilteredThingActivity)) {
|
if (post != null && !(mActivity instanceof FilteredThingActivity)) {
|
||||||
mCallback.typeChipClicked(post.getPostType());
|
mCallback.typeChipClicked(post.getPostType());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
imageView.setOnClickListener(view -> {
|
imageView.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
switch (post.getPostType()) {
|
switch (post.getPostType()) {
|
||||||
case Post.IMAGE_TYPE: {
|
case Post.IMAGE_TYPE: {
|
||||||
@ -2709,7 +2790,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
noPreviewLinkImageFrameLayout.setOnClickListener(view -> {
|
noPreviewLinkImageFrameLayout.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(post.getUrl());
|
Uri uri = Uri.parse(post.getUrl());
|
||||||
@ -2729,7 +2814,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.isArchived()) {
|
if (post.isArchived()) {
|
||||||
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
|
||||||
@ -2803,7 +2892,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.isArchived()) {
|
if (post.isArchived()) {
|
||||||
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mActivity, R.string.archived_post_vote_unavailable, Toast.LENGTH_SHORT).show();
|
||||||
@ -2877,7 +2970,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
if (post.isSaved()) {
|
if (post.isSaved()) {
|
||||||
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
@ -2924,7 +3021,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
});
|
});
|
||||||
|
|
||||||
shareButton.setOnClickListener(view -> {
|
shareButton.setOnClickListener(view -> {
|
||||||
Post post = getItem(getAdapterPosition());
|
int position = getAdapterPosition();
|
||||||
|
if (position < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Post post = getItem(position);
|
||||||
if (post != null) {
|
if (post != null) {
|
||||||
shareLink(post);
|
shareLink(post);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user