mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-05 14:14:47 +01:00
Minor bugs fixed.
This commit is contained in:
parent
58efcce3a0
commit
ea779ff74b
@ -64,7 +64,7 @@ import pl.droidsonroids.gif.GifImageView;
|
|||||||
|
|
||||||
public class ViewGIFActivity extends AppCompatActivity {
|
public class ViewGIFActivity extends AppCompatActivity {
|
||||||
|
|
||||||
public static final String IMAGE_URL_KEY = "IUK";
|
public static final String GIF_URL_KEY = "GUK";
|
||||||
public static final String FILE_NAME_KEY = "FNK";
|
public static final String FILE_NAME_KEY = "FNK";
|
||||||
public static final String POST_TITLE_KEY = "PTK";
|
public static final String POST_TITLE_KEY = "PTK";
|
||||||
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
private static final int PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE = 0;
|
||||||
@ -120,11 +120,15 @@ public class ViewGIFActivity extends AppCompatActivity {
|
|||||||
glide = Glide.with(this);
|
glide = Glide.with(this);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
mImageUrl = intent.getStringExtra(IMAGE_URL_KEY);
|
mImageUrl = intent.getStringExtra(GIF_URL_KEY);
|
||||||
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
||||||
postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
||||||
|
|
||||||
|
if (postTitle != null) {
|
||||||
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
||||||
|
} else {
|
||||||
|
setTitle("");
|
||||||
|
}
|
||||||
|
|
||||||
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
||||||
if (!isSwiping) {
|
if (!isSwiping) {
|
||||||
|
@ -129,7 +129,11 @@ public class ViewImageActivity extends AppCompatActivity {
|
|||||||
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
mImageFileName = intent.getStringExtra(FILE_NAME_KEY);
|
||||||
postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
postTitle = intent.getStringExtra(POST_TITLE_KEY);
|
||||||
|
|
||||||
|
if (postTitle != null) {
|
||||||
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
||||||
|
} else {
|
||||||
|
setTitle("");
|
||||||
|
}
|
||||||
|
|
||||||
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
mLoadErrorLinearLayout.setOnClickListener(view -> {
|
||||||
if (!isSwiping) {
|
if (!isSwiping) {
|
||||||
|
@ -135,7 +135,11 @@ public class ViewVideoActivity extends AppCompatActivity {
|
|||||||
videoFileName = intent.getStringExtra(EXTRA_SUBREDDIT) + "-" + intent.getStringExtra(EXTRA_ID) + ".mp4";
|
videoFileName = intent.getStringExtra(EXTRA_SUBREDDIT) + "-" + intent.getStringExtra(EXTRA_ID) + ".mp4";
|
||||||
postTitle = intent.getStringExtra(EXTRA_POST_TITLE);
|
postTitle = intent.getStringExtra(EXTRA_POST_TITLE);
|
||||||
|
|
||||||
|
if (postTitle != null) {
|
||||||
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle)));
|
||||||
|
} else {
|
||||||
|
setTitle("");
|
||||||
|
}
|
||||||
|
|
||||||
final float pxHeight = getResources().getDisplayMetrics().heightPixels;
|
final float pxHeight = getResources().getDisplayMetrics().heightPixels;
|
||||||
|
|
||||||
|
@ -494,14 +494,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
if (mPost.getAuthorFlairHTML() != null && !mPost.getAuthorFlairHTML().equals("")) {
|
if (mPost.getAuthorFlairHTML() != null && !mPost.getAuthorFlairHTML().equals("")) {
|
||||||
((PostDetailViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
|
((PostDetailViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
|
||||||
Spannable flairHTML;
|
Utils.setHTMLWithImageToTextView(((PostDetailViewHolder) holder).mAuthorFlairTextView, mPost.getAuthorFlairHTML());
|
||||||
GlideImageGetter glideImageGetter = new GlideImageGetter(((PostDetailViewHolder) holder).mAuthorFlairTextView);
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
||||||
flairHTML = (Spannable) Html.fromHtml(mPost.getAuthorFlairHTML(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
|
||||||
} else {
|
|
||||||
flairHTML = (Spannable) Html.fromHtml(mPost.getAuthorFlairHTML(), glideImageGetter, null);
|
|
||||||
}
|
|
||||||
((PostDetailViewHolder) holder).mAuthorFlairTextView.setText(flairHTML);
|
|
||||||
((PostDetailViewHolder) holder).mAuthorFlairTextView.setOnClickListener(view -> ((PostDetailViewHolder) holder).mUserTextView.performClick());
|
((PostDetailViewHolder) holder).mAuthorFlairTextView.setOnClickListener(view -> ((PostDetailViewHolder) holder).mUserTextView.performClick());
|
||||||
} else if (mPost.getAuthorFlair() != null && !mPost.getAuthorFlair().equals("")) {
|
} else if (mPost.getAuthorFlair() != null && !mPost.getAuthorFlair().equals("")) {
|
||||||
((PostDetailViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
|
((PostDetailViewHolder) holder).mAuthorFlairTextView.setVisibility(View.VISIBLE);
|
||||||
@ -587,14 +580,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
if (mPost.getAwards() != null && !mPost.getAwards().equals("")) {
|
if (mPost.getAwards() != null && !mPost.getAwards().equals("")) {
|
||||||
((PostDetailViewHolder) holder).mAwardsTextView.setVisibility(View.VISIBLE);
|
((PostDetailViewHolder) holder).mAwardsTextView.setVisibility(View.VISIBLE);
|
||||||
Spannable awardsHTML;
|
Utils.setHTMLWithImageToTextView(((PostDetailViewHolder) holder).mAwardsTextView, mPost.getAwards());
|
||||||
GlideImageGetter glideImageGetter = new GlideImageGetter(((PostDetailViewHolder) holder).mAwardsTextView);
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
||||||
awardsHTML = (Spannable) Html.fromHtml(mPost.getAwards(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
|
||||||
} else {
|
|
||||||
awardsHTML = (Spannable) Html.fromHtml(mPost.getAwards(), glideImageGetter, null);
|
|
||||||
}
|
|
||||||
((PostDetailViewHolder) holder).mAwardsTextView.setText(awardsHTML);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isNSFW()) {
|
if (mPost.isNSFW()) {
|
||||||
@ -630,6 +616,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, mPost.getUrl());
|
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, mPost.getUrl());
|
||||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, mPost.getSubredditNamePrefixed().substring(2)
|
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, mPost.getSubredditNamePrefixed().substring(2)
|
||||||
+ "-" + mPost.getId().substring(3) + ".jpg");
|
+ "-" + mPost.getId().substring(3) + ".jpg");
|
||||||
|
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -663,7 +650,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, mPost.getSubredditName()
|
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, mPost.getSubredditName()
|
||||||
+ "-" + mPost.getId() + ".gif");
|
+ "-" + mPost.getId() + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.IMAGE_URL_KEY, mPost.getVideoUrl());
|
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, mPost.getVideoUrl());
|
||||||
|
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -679,6 +667,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, mPost.getVideoDownloadUrl());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName());
|
||||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId());
|
||||||
|
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -844,14 +833,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) {
|
if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) {
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
|
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
|
||||||
Spannable flairHTML;
|
Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML());
|
||||||
GlideImageGetter glideImageGetter = new GlideImageGetter(((CommentViewHolder) holder).authorFlairTextView);
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
||||||
flairHTML = (Spannable) Html.fromHtml(comment.getAuthorFlairHTML(), Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
|
||||||
} else {
|
|
||||||
flairHTML = (Spannable) Html.fromHtml(comment.getAuthorFlairHTML(), glideImageGetter, null);
|
|
||||||
}
|
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setText(flairHTML);
|
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setOnClickListener(view -> ((CommentViewHolder) holder).authorTextView.performClick());
|
((CommentViewHolder) holder).authorFlairTextView.setOnClickListener(view -> ((CommentViewHolder) holder).authorTextView.performClick());
|
||||||
} else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) {
|
} else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) {
|
||||||
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
|
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
|
||||||
@ -2217,7 +2199,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
commentMarkdownView.setTextColor(mCommentTextColor);
|
commentMarkdownView.setTextColor(mCommentTextColor);
|
||||||
authorFlairTextView.setTextColor(mAuthorFlairTextColor);
|
authorFlairTextView.setTextColor(mAuthorFlairTextColor);
|
||||||
topScoreTextView.setTextColor(mSecondaryTextColor);
|
topScoreTextView.setTextColor(mSecondaryTextColor);
|
||||||
awardsTextView.setTextColor(mCommentTextColor);
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
commentDivider.setBackgroundColor(mDividerColor);
|
commentDivider.setBackgroundColor(mDividerColor);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
@ -74,6 +74,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
private int mCommentColor;
|
private int mCommentColor;
|
||||||
private int mDividerColor;
|
private int mDividerColor;
|
||||||
private int mUsernameColor;
|
private int mUsernameColor;
|
||||||
|
private int mAuthorFlairColor;
|
||||||
private int mSubredditColor;
|
private int mSubredditColor;
|
||||||
private int mUpvotedColor;
|
private int mUpvotedColor;
|
||||||
private int mDownvotedColor;
|
private int mDownvotedColor;
|
||||||
@ -135,6 +136,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
mDividerColor = customThemeWrapper.getDividerColor();
|
mDividerColor = customThemeWrapper.getDividerColor();
|
||||||
mSubredditColor = customThemeWrapper.getSubreddit();
|
mSubredditColor = customThemeWrapper.getSubreddit();
|
||||||
mUsernameColor = customThemeWrapper.getUsername();
|
mUsernameColor = customThemeWrapper.getUsername();
|
||||||
|
mAuthorFlairColor = customThemeWrapper.getAuthorFlairTextColor();
|
||||||
mUpvotedColor = customThemeWrapper.getUpvoted();
|
mUpvotedColor = customThemeWrapper.getUpvoted();
|
||||||
mDownvotedColor = customThemeWrapper.getDownvoted();
|
mDownvotedColor = customThemeWrapper.getDownvoted();
|
||||||
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
mButtonTextColor = customThemeWrapper.getButtonTextColor();
|
||||||
@ -146,7 +148,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
if (viewType == VIEW_TYPE_DATA) {
|
if (viewType == VIEW_TYPE_DATA) {
|
||||||
return new DataViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
return new CommentViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_comment, parent, false));
|
||||||
} else if (viewType == VIEW_TYPE_ERROR) {
|
} else if (viewType == VIEW_TYPE_ERROR) {
|
||||||
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
|
return new ErrorViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_footer_error, parent, false));
|
||||||
} else {
|
} else {
|
||||||
@ -156,53 +158,65 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||||
if (holder instanceof DataViewHolder) {
|
if (holder instanceof CommentViewHolder) {
|
||||||
CommentData comment = getItem(holder.getAdapterPosition());
|
CommentData comment = getItem(holder.getAdapterPosition());
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
|
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
|
||||||
((DataViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor());
|
((CommentViewHolder) holder).authorTextView.setText("u/" + comment.getLinkAuthor());
|
||||||
((DataViewHolder) holder).authorTextView.setTextColor(mUsernameColor);
|
((CommentViewHolder) holder).authorTextView.setTextColor(mUsernameColor);
|
||||||
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
((CommentViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
|
Intent intent = new Intent(mContext, ViewUserDetailActivity.class);
|
||||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getLinkAuthor());
|
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, comment.getLinkAuthor());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
((DataViewHolder) holder).authorTextView.setText("r/" + comment.getSubredditName());
|
((CommentViewHolder) holder).authorTextView.setText("r/" + comment.getSubredditName());
|
||||||
((DataViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
((CommentViewHolder) holder).authorTextView.setTextColor(mSubredditColor);
|
||||||
((DataViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
((CommentViewHolder) holder).authorTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getSubredditName());
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getSubredditName());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mShowElapsedTime) {
|
if (comment.getAuthorFlairHTML() != null && !comment.getAuthorFlairHTML().equals("")) {
|
||||||
((DataViewHolder) holder).commentTimeTextView.setText(
|
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
|
||||||
Utils.getElapsedTime(mContext, comment.getCommentTimeMillis()));
|
Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).authorFlairTextView, comment.getAuthorFlairHTML());
|
||||||
} else {
|
} else if (comment.getAuthorFlair() != null && !comment.getAuthorFlair().equals("")) {
|
||||||
((DataViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
|
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.VISIBLE);
|
||||||
|
((CommentViewHolder) holder).authorFlairTextView.setText(comment.getAuthorFlair());
|
||||||
}
|
}
|
||||||
|
|
||||||
mMarkwon.setMarkdown(((DataViewHolder) holder).commentMarkdownView, comment.getCommentMarkdown());
|
if (mShowElapsedTime) {
|
||||||
|
((CommentViewHolder) holder).commentTimeTextView.setText(
|
||||||
|
Utils.getElapsedTime(mContext, comment.getCommentTimeMillis()));
|
||||||
|
} else {
|
||||||
|
((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
|
||||||
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
if (comment.getAwards() != null && !comment.getAwards().equals("")) {
|
||||||
|
Utils.setHTMLWithImageToTextView(((CommentViewHolder) holder).awardsTextView, comment.getAwards());
|
||||||
|
}
|
||||||
|
|
||||||
|
mMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentMarkdown());
|
||||||
|
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
switch (comment.getVoteType()) {
|
switch (comment.getVoteType()) {
|
||||||
case CommentData.VOTE_TYPE_UPVOTE:
|
case CommentData.VOTE_TYPE_UPVOTE:
|
||||||
((DataViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
break;
|
break;
|
||||||
case CommentData.VOTE_TYPE_DOWNVOTE:
|
case CommentData.VOTE_TYPE_DOWNVOTE:
|
||||||
((DataViewHolder) holder).downvoteButton
|
((CommentViewHolder) holder).downvoteButton
|
||||||
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).moreButton.setOnClickListener(view -> {
|
((CommentViewHolder) holder).moreButton.setOnClickListener(view -> {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
if (comment.getAuthor().equals(mAccountName)) {
|
if (comment.getAuthor().equals(mAccountName)) {
|
||||||
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
|
||||||
@ -214,21 +228,21 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
commentMoreBottomSheetFragment.show(((AppCompatActivity) mContext).getSupportFragmentManager(), commentMoreBottomSheetFragment.getTag());
|
commentMoreBottomSheetFragment.show(((AppCompatActivity) mContext).getSupportFragmentManager(), commentMoreBottomSheetFragment.getTag());
|
||||||
});
|
});
|
||||||
|
|
||||||
((DataViewHolder) holder).linearLayout.setOnClickListener(view -> {
|
((CommentViewHolder) holder).linearLayout.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mContext, ViewPostDetailActivity.class);
|
Intent intent = new Intent(mContext, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getLinkId());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getLinkId());
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
((DataViewHolder) holder).verticalBlock.setVisibility(View.GONE);
|
((CommentViewHolder) holder).verticalBlock.setVisibility(View.GONE);
|
||||||
|
|
||||||
((DataViewHolder) holder).commentMarkdownView.setOnClickListener(view ->
|
((CommentViewHolder) holder).commentMarkdownView.setOnClickListener(view ->
|
||||||
((DataViewHolder) holder).linearLayout.callOnClick());
|
((CommentViewHolder) holder).linearLayout.callOnClick());
|
||||||
|
|
||||||
((DataViewHolder) holder).replyButton.setVisibility(View.GONE);
|
((CommentViewHolder) holder).replyButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
((DataViewHolder) holder).upvoteButton.setOnClickListener(view -> {
|
((CommentViewHolder) holder).upvoteButton.setOnClickListener(view -> {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
@ -237,24 +251,24 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
if (previousVoteType != CommentData.VOTE_TYPE_UPVOTE) {
|
||||||
//Not upvoted before
|
//Not upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
||||||
newVoteType = RedditUtils.DIR_UPVOTE;
|
newVoteType = RedditUtils.DIR_UPVOTE;
|
||||||
((DataViewHolder) holder).upvoteButton
|
((CommentViewHolder) holder).upvoteButton
|
||||||
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Upvoted before
|
//Upvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = RedditUtils.DIR_UNVOTE;
|
||||||
((DataViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@ -262,16 +276,16 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void onVoteThingSuccess(int position) {
|
public void onVoteThingSuccess(int position) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
if (newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_UPVOTE);
|
||||||
((DataViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mUpvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mUpvotedColor);
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
((DataViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +295,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
}, comment.getFullName(), newVoteType, holder.getAdapterPosition());
|
}, comment.getFullName(), newVoteType, holder.getAdapterPosition());
|
||||||
});
|
});
|
||||||
|
|
||||||
((DataViewHolder) holder).downvoteButton.setOnClickListener(view -> {
|
((CommentViewHolder) holder).downvoteButton.setOnClickListener(view -> {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
@ -290,23 +304,23 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
int previousVoteType = comment.getVoteType();
|
int previousVoteType = comment.getVoteType();
|
||||||
String newVoteType;
|
String newVoteType;
|
||||||
|
|
||||||
((DataViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
|
||||||
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
if (previousVoteType != CommentData.VOTE_TYPE_DOWNVOTE) {
|
||||||
//Not downvoted before
|
//Not downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
||||||
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
newVoteType = RedditUtils.DIR_DOWNVOTE;
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
//Downvoted before
|
//Downvoted before
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
newVoteType = RedditUtils.DIR_UNVOTE;
|
newVoteType = RedditUtils.DIR_UNVOTE;
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
|
|
||||||
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
VoteThing.voteThing(mContext, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
|
||||||
@ -314,16 +328,16 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
public void onVoteThingSuccess(int position1) {
|
public void onVoteThingSuccess(int position1) {
|
||||||
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
if (newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_DOWNVOTE);
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mDownvotedColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mDownvotedColor);
|
||||||
} else {
|
} else {
|
||||||
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
comment.setVoteType(CommentData.VOTE_TYPE_NO_VOTE);
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
((DataViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
((CommentViewHolder) holder).scoreTextView.setText(Utils.getNVotes(mShowAbsoluteNumberOfVotes,
|
||||||
comment.getScore() + comment.getVoteType()));
|
comment.getScore() + comment.getVoteType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,26 +348,26 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
} else {
|
} else {
|
||||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
((DataViewHolder) holder).saveButton.setOnClickListener(view -> {
|
((CommentViewHolder) holder).saveButton.setOnClickListener(view -> {
|
||||||
if (comment.isSaved()) {
|
if (comment.isSaved()) {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
Toast.makeText(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -363,14 +377,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@Override
|
@Override
|
||||||
public void success() {
|
public void success() {
|
||||||
comment.setSaved(true);
|
comment.setSaved(true);
|
||||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||||
Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failed() {
|
public void failed() {
|
||||||
comment.setSaved(false);
|
comment.setSaved(false);
|
||||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
|
||||||
Toast.makeText(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
Toast.makeText(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -396,10 +410,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
if (holder instanceof DataViewHolder) {
|
if (holder instanceof CommentViewHolder) {
|
||||||
((DataViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).authorFlairTextView.setText("");
|
||||||
((DataViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
((CommentViewHolder) holder).authorFlairTextView.setVisibility(View.GONE);
|
||||||
((DataViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
((CommentViewHolder) holder).awardsTextView.setText("");
|
||||||
|
((CommentViewHolder) holder).awardsTextView.setVisibility(View.GONE);
|
||||||
|
((CommentViewHolder) holder).upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
((CommentViewHolder) holder).downvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
|
((CommentViewHolder) holder).scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,15 +453,19 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
void retryLoadingMore();
|
void retryLoadingMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
class DataViewHolder extends RecyclerView.ViewHolder {
|
class CommentViewHolder extends RecyclerView.ViewHolder {
|
||||||
@BindView(R.id.linear_layout_item_comment)
|
@BindView(R.id.linear_layout_item_comment)
|
||||||
LinearLayout linearLayout;
|
LinearLayout linearLayout;
|
||||||
@BindView(R.id.vertical_block_item_post_comment)
|
@BindView(R.id.vertical_block_item_post_comment)
|
||||||
View verticalBlock;
|
View verticalBlock;
|
||||||
@BindView(R.id.author_text_view_item_post_comment)
|
@BindView(R.id.author_text_view_item_post_comment)
|
||||||
TextView authorTextView;
|
TextView authorTextView;
|
||||||
|
@BindView(R.id.author_flair_text_view_item_post_comment)
|
||||||
|
TextView authorFlairTextView;
|
||||||
@BindView(R.id.comment_time_text_view_item_post_comment)
|
@BindView(R.id.comment_time_text_view_item_post_comment)
|
||||||
TextView commentTimeTextView;
|
TextView commentTimeTextView;
|
||||||
|
@BindView(R.id.awards_text_view_item_comment)
|
||||||
|
TextView awardsTextView;
|
||||||
@BindView(R.id.comment_markdown_view_item_post_comment)
|
@BindView(R.id.comment_markdown_view_item_post_comment)
|
||||||
TextView commentMarkdownView;
|
TextView commentMarkdownView;
|
||||||
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
||||||
@ -465,7 +487,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
@BindView(R.id.divider_item_comment)
|
@BindView(R.id.divider_item_comment)
|
||||||
View commentDivider;
|
View commentDivider;
|
||||||
|
|
||||||
DataViewHolder(View itemView) {
|
CommentViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
ButterKnife.bind(this, itemView);
|
ButterKnife.bind(this, itemView);
|
||||||
|
|
||||||
@ -494,7 +516,9 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
|
|
||||||
itemView.setBackgroundColor(mCommentBackgroundColor);
|
itemView.setBackgroundColor(mCommentBackgroundColor);
|
||||||
authorTextView.setTextColor(mUsernameColor);
|
authorTextView.setTextColor(mUsernameColor);
|
||||||
|
authorFlairTextView.setTextColor(mAuthorFlairColor);
|
||||||
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
commentTimeTextView.setTextColor(mSecondaryTextColor);
|
||||||
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
commentMarkdownView.setTextColor(mCommentColor);
|
commentMarkdownView.setTextColor(mCommentColor);
|
||||||
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
upvoteButton.setColorFilter(mCommentIconAndInfoColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
scoreTextView.setTextColor(mCommentIconAndInfoColor);
|
||||||
|
@ -453,14 +453,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
if (awards != null && !awards.equals("")) {
|
if (awards != null && !awards.equals("")) {
|
||||||
((PostViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
|
((PostViewHolder) holder).awardsTextView.setVisibility(View.VISIBLE);
|
||||||
Spannable awardsHTML;
|
Utils.setHTMLWithImageToTextView(((PostViewHolder) holder).awardsTextView, awards);
|
||||||
GlideImageGetter glideImageGetter = new GlideImageGetter(((PostViewHolder) holder).awardsTextView);
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
|
||||||
awardsHTML = (Spannable) Html.fromHtml(awards, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
|
||||||
} else {
|
|
||||||
awardsHTML = (Spannable) Html.fromHtml(awards, glideImageGetter, null);
|
|
||||||
}
|
|
||||||
((PostViewHolder) holder).awardsTextView.setText(awardsHTML);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (voteType) {
|
switch (voteType) {
|
||||||
@ -553,7 +546,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
intent.setData(gifVideoUri);
|
intent.setData(gifVideoUri);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
|
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
|
||||||
+ "-" + id + ".gif");
|
+ "-" + id + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.IMAGE_URL_KEY, post.getVideoUrl());
|
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||||
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
|
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -1118,7 +1111,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
intent.setData(gifVideoUri);
|
intent.setData(gifVideoUri);
|
||||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
|
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
|
||||||
+ "-" + id + ".gif");
|
+ "-" + id + ".gif");
|
||||||
intent.putExtra(ViewGIFActivity.IMAGE_URL_KEY, post.getVideoUrl());
|
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1691,7 +1684,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN);
|
archivedImageView.setColorFilter(mArchivedIconTint, PorterDuff.Mode.SRC_IN);
|
||||||
lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN);
|
lockedImageView.setColorFilter(mLockedIconTint, PorterDuff.Mode.SRC_IN);
|
||||||
crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN);
|
crosspostImageView.setColorFilter(mCrosspostIconTint, PorterDuff.Mode.SRC_IN);
|
||||||
awardsTextView.setTextColor(mPostTitleColor);
|
awardsTextView.setTextColor(mSecondaryTextColor);
|
||||||
linkTextView.setTextColor(mSecondaryTextColor);
|
linkTextView.setTextColor(mSecondaryTextColor);
|
||||||
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
|
progressBar.setIndeterminateTintList(ColorStateList.valueOf(mColorAccent));
|
||||||
noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
|
noPreviewLinkImageView.setBackgroundColor(mNoPreviewLinkBackgroundColor);
|
||||||
|
@ -125,9 +125,9 @@ public class ParseComment {
|
|||||||
JSONObject flairObject = flairArray.getJSONObject(i);
|
JSONObject flairObject = flairArray.getJSONObject(i);
|
||||||
String e = flairObject.getString(JSONUtils.E_KEY);
|
String e = flairObject.getString(JSONUtils.E_KEY);
|
||||||
if (e.equals("text")) {
|
if (e.equals("text")) {
|
||||||
authorFlairHTMLBuilder.append(flairObject.getString(JSONUtils.T_KEY));
|
authorFlairHTMLBuilder.append(Html.escapeHtml(flairObject.getString(JSONUtils.T_KEY)));
|
||||||
} else if (e.equals("emoji")) {
|
} else if (e.equals("emoji")) {
|
||||||
authorFlairHTMLBuilder.append("<img src=\"").append(flairObject.getString(JSONUtils.U_KEY)).append("\">");
|
authorFlairHTMLBuilder.append("<img src=\"").append(Html.escapeHtml(flairObject.getString(JSONUtils.U_KEY))).append("\">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -153,10 +153,10 @@ public class ParseComment {
|
|||||||
JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY);
|
JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY);
|
||||||
if (icons.length() > 4) {
|
if (icons.length() > 4) {
|
||||||
String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY);
|
String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY);
|
||||||
awardingsBuilder.append("<img src=\"").append(iconUrl).append("\"> ").append("x").append(count).append(" ");
|
awardingsBuilder.append("<img src=\"").append(Html.escapeHtml(iconUrl)).append("\"> ").append("x").append(count).append(" ");
|
||||||
} else if (icons.length() > 0) {
|
} else if (icons.length() > 0) {
|
||||||
String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY);
|
String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY);
|
||||||
awardingsBuilder.append("<img src=\"").append(iconUrl).append("\"> ").append("x").append(count).append(" ");
|
awardingsBuilder.append("<img src=\"").append(Html.escapeHtml(iconUrl)).append("\"> ").append("x").append(count).append(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int score = singleCommentData.getInt(JSONUtils.SCORE_KEY);
|
int score = singleCommentData.getInt(JSONUtils.SCORE_KEY);
|
||||||
|
@ -46,7 +46,7 @@ public class ParsePost {
|
|||||||
if (e.equals("text")) {
|
if (e.equals("text")) {
|
||||||
authorFlairHTMLBuilder.append(flairObject.getString(JSONUtils.T_KEY));
|
authorFlairHTMLBuilder.append(flairObject.getString(JSONUtils.T_KEY));
|
||||||
} else if (e.equals("emoji")) {
|
} else if (e.equals("emoji")) {
|
||||||
authorFlairHTMLBuilder.append("<img src=\"").append(flairObject.getString(JSONUtils.U_KEY)).append("\">");
|
authorFlairHTMLBuilder.append("<img src=\"").append(Html.escapeHtml(flairObject.getString(JSONUtils.U_KEY))).append("\">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,9 +70,9 @@ public class ParsePost {
|
|||||||
JSONObject flairObject = flairArray.getJSONObject(i);
|
JSONObject flairObject = flairArray.getJSONObject(i);
|
||||||
String e = flairObject.getString(JSONUtils.E_KEY);
|
String e = flairObject.getString(JSONUtils.E_KEY);
|
||||||
if (e.equals("text")) {
|
if (e.equals("text")) {
|
||||||
postFlairHTMLBuilder.append(flairObject.getString(JSONUtils.T_KEY));
|
postFlairHTMLBuilder.append(Html.escapeHtml(flairObject.getString(JSONUtils.T_KEY)));
|
||||||
} else if (e.equals("emoji")) {
|
} else if (e.equals("emoji")) {
|
||||||
postFlairHTMLBuilder.append("<img src=\"").append(flairObject.getString(JSONUtils.U_KEY)).append("\">");
|
postFlairHTMLBuilder.append("<img src=\"").append(Html.escapeHtml(flairObject.getString(JSONUtils.U_KEY))).append("\">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,10 +85,10 @@ public class ParsePost {
|
|||||||
JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY);
|
JSONArray icons = award.getJSONArray(JSONUtils.RESIZED_ICONS_KEY);
|
||||||
if (icons.length() > 4) {
|
if (icons.length() > 4) {
|
||||||
String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY);
|
String iconUrl = icons.getJSONObject(3).getString(JSONUtils.URL_KEY);
|
||||||
awardingsBuilder.append("<img src=\"").append(iconUrl).append("\"> ").append("x").append(count).append(" ");
|
awardingsBuilder.append("<img src=\"").append(Html.escapeHtml(iconUrl)).append("\"> ").append("x").append(count).append(" ");
|
||||||
} else if (icons.length() > 0) {
|
} else if (icons.length() > 0) {
|
||||||
String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY);
|
String iconUrl = icons.getJSONObject(icons.length() - 1).getString(JSONUtils.URL_KEY);
|
||||||
awardingsBuilder.append("<img src=\"").append(iconUrl).append("\"> ").append("x").append(count).append(" ");
|
awardingsBuilder.append("<img src=\"").append(Html.escapeHtml(iconUrl)).append("\"> ").append("x").append(count).append(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Utils;
|
package ml.docilealligator.infinityforreddit.Utils;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.text.Html;
|
||||||
|
import android.text.Spannable;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -73,4 +76,15 @@ public class Utils {
|
|||||||
return String.format(Locale.US, "%.1f", (float) votes / 1000) + "K";
|
return String.format(Locale.US, "%.1f", (float) votes / 1000) + "K";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setHTMLWithImageToTextView(TextView textView, String content) {
|
||||||
|
Spannable html;
|
||||||
|
GlideImageGetter glideImageGetter = new GlideImageGetter(textView);
|
||||||
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
|
||||||
|
html = (Spannable) Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY, glideImageGetter, null);
|
||||||
|
} else {
|
||||||
|
html = (Spannable) Html.fromHtml(content, glideImageGetter, null);
|
||||||
|
}
|
||||||
|
textView.setText(html);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginEnd="8dp"
|
android:layout_marginEnd="8dp"
|
||||||
android:textColor="?attr/username"
|
android:textColor="?attr/username"
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_12"
|
||||||
android:maxLines="2"
|
android:maxLines="2"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user