diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-07-18 13:56:39 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-07-18 13:56:39 +0000 |
commit | 685a39ba58fab82cc0486e49394a0f398bba8254 (patch) | |
tree | 0917aad044057f680147b6377e70757edf75415c /app/src/main/java/ml | |
parent | 3a621e290190e67f777e4f442398a4db120aa7af (diff) | |
download | infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.tar infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.tar.gz infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.tar.bz2 infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.tar.lz infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.tar.xz infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.tar.zst infinity-for-reddit-685a39ba58fab82cc0486e49394a0f398bba8254.zip |
Fix UI issues in post and comment item. Fix Reddit gallery post cannot be opened in PostCompactLayout when clicking the imageview.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index 45e6cc1d..b558db87 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -795,7 +795,11 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView if (post.getPostType() != Post.GIF_TYPE && post.getPostType() != Post.VIDEO_TYPE) { ((PostCompactBaseViewHolder) holder).progressBar.setVisibility(View.VISIBLE); } - ((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE); + if (post.getPostType() == Post.GALLERY_TYPE && post.getPreviewUrl() == null || post.getPreviewUrl().equals("")) { + ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE); + } else { + ((PostCompactBaseViewHolder) holder).imageView.setVisibility(View.VISIBLE); + } loadImage(holder, post); } @@ -845,6 +849,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostCompactBaseViewHolder) holder).linkTextView.setText(noPreviewLinkDomain); ((PostCompactBaseViewHolder) holder).noPreviewLinkImageFrameLayout.setVisibility(View.VISIBLE); break; + case Post.GALLERY_TYPE: + ((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.gallery); + break; case Post.TEXT_TYPE: ((PostCompactBaseViewHolder) holder).typeTextView.setText(R.string.text); break; @@ -2547,7 +2554,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ImageView imageView; ImageView playButtonImageView; FrameLayout noPreviewLinkImageFrameLayout; - ImageView noPreviewLinkImageView; Barrier imageBarrier; ConstraintLayout bottomConstraintLayout; ImageView upvoteButton; @@ -2598,7 +2604,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView this.imageView = imageView; this.playButtonImageView = playButtonImageView; this.noPreviewLinkImageFrameLayout = noPreviewLinkImageFrameLayout; - this.noPreviewLinkImageView = noPreviewLinkImageView; this.imageBarrier = imageBarrier; this.bottomConstraintLayout = bottomConstraintLayout; this.upvoteButton = upvoteButton; @@ -2784,6 +2789,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId()); intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); + break; + } + case Post.GALLERY_TYPE: { + Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class); + intent.putExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery()); + mActivity.startActivity(intent); } } } @@ -2796,15 +2807,21 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } Post post = getItem(position); if (post != null) { - Intent intent = new Intent(mActivity, LinkResolverActivity.class); - Uri uri = Uri.parse(post.getUrl()); - if (uri.getScheme() == null && uri.getHost() == null) { - intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl())); + if (post.getPostType() == Post.GALLERY_TYPE) { + Intent intent = new Intent(mActivity, ViewRedditGalleryActivity.class); + intent.putExtra(ViewRedditGalleryActivity.EXTRA_REDDIT_GALLERY, post.getGallery()); + mActivity.startActivity(intent); } else { - intent.setData(uri); + Intent intent = new Intent(mActivity, LinkResolverActivity.class); + Uri uri = Uri.parse(post.getUrl()); + if (uri.getScheme() == null && uri.getHost() == null) { + intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl())); + } else { + intent.setData(uri); + } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW()); + mActivity.startActivity(intent); } - intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW()); - mActivity.startActivity(intent); } }); |