diff options
author | Alex Ning <chineseperson5@gmail.com> | 2019-01-09 02:05:20 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2019-01-09 02:05:20 +0000 |
commit | f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2 (patch) | |
tree | e75272ac86da929a6b2e6c0939dc040eaa242bed /app/src/main/java/ml | |
parent | 38be0ba01f6dd08c0be1a830e0d0389405949a56 (diff) | |
download | infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.gz infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.bz2 infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.lz infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.xz infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.tar.zst infinity-for-reddit-f0b149ce82cf11df1f5cf84c7d644e5e670ad0b2.zip |
Use MarkwonView (a markdown library) instead of HtmlTextView to display post content and comments.
Diffstat (limited to 'app/src/main/java/ml')
2 files changed, 16 insertions, 17 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java index bb95b2f6..3e3c655c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentMultiLevelRecyclerViewAdapter.java @@ -18,8 +18,6 @@ import com.multilevelview.MultiLevelAdapter; import com.multilevelview.MultiLevelRecyclerView; import com.multilevelview.models.RecyclerViewItem; -import org.sufficientlysecure.htmltextview.HtmlTextView; - import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -27,6 +25,7 @@ import java.util.Locale; import butterknife.BindView; import butterknife.ButterKnife; import retrofit2.Retrofit; +import ru.noties.markwon.view.MarkwonView; class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter { private Context mContext; @@ -67,7 +66,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter { ((CommentViewHolder) holder).authorTextView.setText(commentItem.getAuthor()); ((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime()); - ((CommentViewHolder) holder).commentHtmlTextView.setHtml(commentItem.getCommentContent()); + ((CommentViewHolder) holder).commentMarkdownView.setMarkdown(commentItem.getCommentContent()); ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore())); ((CommentViewHolder) holder).verticalBlock.getLayoutParams().width = commentItem.getDepth() * 16; @@ -260,7 +259,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter { class CommentViewHolder extends RecyclerView.ViewHolder { @BindView(R.id.author_text_view_item_post_comment) TextView authorTextView; @BindView(R.id.comment_time_text_view_item_post_comment) TextView commentTimeTextView; - @BindView(R.id.comment_html_text_view_item_post_comment) HtmlTextView commentHtmlTextView; + @BindView(R.id.comment_markdown_view_item_post_comment) MarkwonView commentMarkdownView; @BindView(R.id.plus_button_item_post_comment) ImageView upvoteButton; @BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView; @BindView(R.id.minus_button_item_post_comment) ImageView downvoteButton; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index de7b7992..1b3a9f90 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -3,6 +3,7 @@ package ml.docilealligator.infinityforreddit; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.ColorFilter; +import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.Bundle; @@ -36,8 +37,6 @@ import com.lsjwzh.widget.materialloadingprogressbar.CircleProgressBar; import com.multilevelview.MultiLevelRecyclerView; import com.santalu.aspectratioimageview.AspectRatioImageView; -import org.sufficientlysecure.htmltextview.HtmlTextView; - import java.util.ArrayList; import java.util.List; @@ -50,6 +49,7 @@ import butterknife.ButterKnife; import de.hdodenhof.circleimageview.CircleImageView; import jp.wasabeef.glide.transformations.BlurTransformation; import retrofit2.Retrofit; +import ru.noties.markwon.view.MarkwonView; public class ViewPostDetailActivity extends AppCompatActivity { @@ -66,7 +66,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { @BindView(R.id.subreddit_icon_circle_image_view_view_post_detail) CircleImageView mSubredditIconCircleImageView; @BindView(R.id.post_time_text_view_view_post_detail) TextView mPostTimeTextView; @BindView(R.id.subreddit_text_view_view_post_detail) TextView mSubredditTextView; - @BindView(R.id.content_html_text_view_view_post_detail) HtmlTextView mContentTextView; + @BindView(R.id.content_markdown_view_view_post_detail) MarkwonView mContentMarkdownView; @BindView(R.id.type_text_view_view_post_detail) Chip mTypeChip; @BindView(R.id.gilded_image_view_view_post_detail) ImageView mGildedImageView; @BindView(R.id.gilded_number_text_view_view_post_detail) TextView mGildedNumberTextView; @@ -151,11 +151,11 @@ public class ViewPostDetailActivity extends AppCompatActivity { switch (mPost.getVoteType()) { case 1: //Upvote - mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN); + mUpvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN); break; case -1: //Downvote - mDownvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN); + mDownvoteButton.setColorFilter(ContextCompat.getColor(this, R.color.minusButtonColor), PorterDuff.Mode.SRC_IN); break; } @@ -268,8 +268,8 @@ public class ViewPostDetailActivity extends AppCompatActivity { case Post.NO_PREVIEW_LINK_TYPE: mTypeChip.setText("LINK"); if(!mPost.getSelfText().equals("")) { - mContentTextView.setVisibility(View.VISIBLE); - mContentTextView.setHtml(mPost.getSelfText()); + mContentMarkdownView.setVisibility(View.VISIBLE); + mContentMarkdownView.setMarkdown(mPost.getSelfText()); } mNoPreviewLinkImageView.setVisibility(View.VISIBLE); mNoPreviewLinkImageView.setOnClickListener(view -> { @@ -284,8 +284,8 @@ public class ViewPostDetailActivity extends AppCompatActivity { case Post.TEXT_TYPE: mTypeChip.setVisibility(View.GONE); if(!mPost.getSelfText().equals("")) { - mContentTextView.setVisibility(View.VISIBLE); - mContentTextView.setHtml(mPost.getSelfText()); + mContentMarkdownView.setVisibility(View.VISIBLE); + mContentMarkdownView.setMarkdown(mPost.getSelfText()); } break; } @@ -298,7 +298,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { mDownvoteButton.clearColorFilter(); if (mUpvoteButton.getColorFilter() == null) { - mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN); + mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN); if(isDownvotedBefore) { mScoreTextView.setText(Integer.toString(mPost.getScore() + 2)); } else { @@ -340,7 +340,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { public void onVoteThingFail() { Toast.makeText(ViewPostDetailActivity.this, "Cannot unvote this post", Toast.LENGTH_SHORT).show(); mScoreTextView.setText(Integer.toString(mPost.getScore() + 1)); - mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN); + mUpvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN); mPost.setScore(mPost.getScore() + 1); } }, mPost.getFullName(), RedditUtils.DIR_UNVOTE); @@ -354,7 +354,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { mUpvoteButton.clearColorFilter(); if (mDownvoteButton.getColorFilter() == null) { - mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN); + mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), PorterDuff.Mode.SRC_IN); if (isUpvotedBefore) { mScoreTextView.setText(Integer.toString(mPost.getScore() - 2)); } else { @@ -395,7 +395,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { @Override public void onVoteThingFail() { Toast.makeText(ViewPostDetailActivity.this, "Cannot unvote this post", Toast.LENGTH_SHORT).show(); - mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN); + mDownvoteButton.setColorFilter(ContextCompat.getColor(ViewPostDetailActivity.this, R.color.minusButtonColor), PorterDuff.Mode.SRC_IN); mScoreTextView.setText(Integer.toString(mPost.getScore())); mPost.setScore(mPost.getScore()); } |