Fix link icon not shown in no preview ImageView.

This commit is contained in:
Alex Ning 2020-11-19 00:18:26 +08:00
parent ccde986d84
commit 91a979049d
4 changed files with 19 additions and 10 deletions

View File

@ -401,8 +401,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
@Override @Override
public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) { public int getMovementFlags(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder) {
if (!(viewHolder instanceof CommentAndPostRecyclerViewAdapter.PostDetailBaseViewHolder) && if (!(viewHolder instanceof CommentAndPostRecyclerViewAdapter.CommentViewHolder)) {
!(viewHolder instanceof CommentAndPostRecyclerViewAdapter.CommentViewHolder)) {
return makeMovementFlags(0, 0); return makeMovementFlags(0, 0);
} }
int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END; int swipeFlags = ItemTouchHelper.START | ItemTouchHelper.END;
@ -1839,9 +1838,6 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (mSlidrInterface != null) { if (mSlidrInterface != null) {
mSlidrInterface.lock(); mSlidrInterface.lock();
} }
if (touchHelper != null) {
touchHelper.attachToRecyclerView(null);
}
} }
public void unlockSwipeRightToGoBack() { public void unlockSwipeRightToGoBack() {

View File

@ -923,9 +923,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
} else if (holder instanceof PostDetailNoPreviewViewHolder) { } else if (holder instanceof PostDetailNoPreviewViewHolder) {
if (mPost.getPostType() == Post.LINK_TYPE || mPost.getPostType() == Post.NO_PREVIEW_LINK_TYPE) { if (mPost.getPostType() == Post.LINK_TYPE || mPost.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.link);
String noPreviewLinkDomain = Uri.parse(mPost.getUrl()).getHost(); String noPreviewLinkDomain = Uri.parse(mPost.getUrl()).getHost();
((PostDetailNoPreviewViewHolder) holder).mLinkTextView.setVisibility(View.VISIBLE); ((PostDetailNoPreviewViewHolder) holder).mLinkTextView.setVisibility(View.VISIBLE);
((PostDetailNoPreviewViewHolder) holder).mLinkTextView.setText(noPreviewLinkDomain); ((PostDetailNoPreviewViewHolder) holder).mLinkTextView.setText(noPreviewLinkDomain);
((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_link);
} else { } else {
((PostDetailNoPreviewViewHolder) holder).mLinkTextView.setVisibility(View.GONE); ((PostDetailNoPreviewViewHolder) holder).mLinkTextView.setVisibility(View.GONE);
switch (mPost.getPostType()) { switch (mPost.getPostType()) {
@ -941,10 +943,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.gif); ((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.gif);
((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_image_24dp); ((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_image_24dp);
break; break;
case Post.LINK_TYPE:
case Post.NO_PREVIEW_LINK_TYPE:
((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.link);
break;
case Post.GALLERY_TYPE: case Post.GALLERY_TYPE:
((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.gallery); ((PostDetailNoPreviewViewHolder) holder).mTypeTextView.setText(R.string.gallery);
((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_gallery_24dp); ((PostDetailNoPreviewViewHolder) holder).mNoPreviewPostTypeImageView.setImageResource(R.drawable.ic_gallery_24dp);

View File

@ -630,6 +630,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostWithPreviewTypeViewHolder) holder).linkTextView.setVisibility(View.VISIBLE); ((PostWithPreviewTypeViewHolder) holder).linkTextView.setVisibility(View.VISIBLE);
String domain = Uri.parse(post.getUrl()).getHost(); String domain = Uri.parse(post.getUrl()).getHost();
((PostWithPreviewTypeViewHolder) holder).linkTextView.setText(domain); ((PostWithPreviewTypeViewHolder) holder).linkTextView.setText(domain);
if (post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_link);
}
} else if (post.getPostType() == Post.GALLERY_TYPE) { } else if (post.getPostType() == Post.GALLERY_TYPE) {
((PostWithPreviewTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gallery)); ((PostWithPreviewTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gallery));
} }
@ -665,6 +669,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
loadImage(holder, post, preview); loadImage(holder, post, preview);
} else { } else {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE); ((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setVisibility(View.VISIBLE);
if (post.getPostType() == Post.VIDEO_TYPE) {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_outline_video_24dp);
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else if (post.getPostType() == Post.IMAGE_TYPE || post.getPostType() == Post.GIF_TYPE) {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_image_24dp);
((PostWithPreviewTypeViewHolder) holder).videoOrGifIndicatorImageView.setVisibility(View.GONE);
} else if (post.getPostType() == Post.LINK_TYPE) {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_link);
} else if (post.getPostType() == Post.GALLERY_TYPE) {
((PostWithPreviewTypeViewHolder) holder).noPreviewLinkImageView.setImageResource(R.drawable.ic_gallery_24dp);
}
} }
} }
} else if (holder instanceof PostTextTypeViewHolder) { } else if (holder instanceof PostTextTypeViewHolder) {

View File

@ -506,7 +506,7 @@
<string name="settings_disable_image_preview_title">Disable Image Preview in Data Saving Mode</string> <string name="settings_disable_image_preview_title">Disable Image Preview in Data Saving Mode</string>
<string name="settings_swipe_action_swipe_left_title">Swipe Left</string> <string name="settings_swipe_action_swipe_left_title">Swipe Left</string>
<string name="settings_swipe_action_swipe_right_title">Swipe Right</string> <string name="settings_swipe_action_swipe_right_title">Swipe Right</string>
<string name="settings_swipe_action_info_summary">Not applicable to post feed with more than 1 column.</string> <string name="settings_swipe_action_info_summary">Not applicable to post feed with more than 1 column or post detail.</string>
<string name="no_link_available">Cannot get the link</string> <string name="no_link_available">Cannot get the link</string>