diff options
Diffstat (limited to 'app/src/main/java/ml/docilealligator')
6 files changed, 24 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java index eef1a004..8af5a765 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentRecyclerViewAdapter.java @@ -14,6 +14,8 @@ import android.widget.Toast; import com.android.volley.RequestQueue; +import org.sufficientlysecure.htmltextview.HtmlTextView; + import java.util.ArrayList; class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { @@ -40,7 +42,7 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, final int position) { ((CommentViewHolder) holder).authorTextView.setText(mCommentData.get(position).getAuthor()); ((CommentViewHolder) holder).commentTimeTextView.setText(mCommentData.get(position).getCommentTime()); - ((CommentViewHolder) holder).commentTextView.setText(mCommentData.get(position).getCommentContent()); + ((CommentViewHolder) holder).commentHtmlTextView.setHtml(mCommentData.get(position).getCommentContent()); ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(mCommentData.get(position).getScore())); switch (mCommentData.get(position).getVoteType()) { @@ -180,7 +182,7 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH private class CommentViewHolder extends RecyclerView.ViewHolder { private TextView authorTextView; private TextView commentTimeTextView; - private TextView commentTextView; + private HtmlTextView commentHtmlTextView; private ImageView upvoteButton; private ImageView downvoteButton; private TextView scoreTextView; @@ -190,7 +192,7 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH super(itemView); authorTextView = itemView.findViewById(R.id.author_text_view_item_post_comment); commentTimeTextView = itemView.findViewById(R.id.comment_time_text_view_item_post_comment); - commentTextView = itemView.findViewById(R.id.comment_text_view_item_post_comment); + commentHtmlTextView = itemView.findViewById(R.id.comment_html_text_view_item_post_comment); upvoteButton = itemView.findViewById(R.id.plus_button_item_post_comment); downvoteButton = itemView.findViewById(R.id.minus_button_item_post_comment); scoreTextView = itemView.findViewById(R.id.score_text_view_item_post_comment); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java index 81d2a77f..d798f8dc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/JSONUtils.java @@ -13,7 +13,7 @@ class JSONUtils { static final String TITLE_KEY = "title"; static final String NAME_KEY = "name"; static final String SUBREDDIT_NAME_PREFIX_KEY = "subreddit_name_prefixed"; - static final String SELF_TEXT_KEY = "selftext"; + static final String SELFTEXT_HTML_KEY = "selftext_html"; static final String AUTHOR_KEY = "author"; static final String DOMAIN_KEY = "domain"; static final String LINK_FLAIR_TEXT_KEY = "link_flair_text"; @@ -44,7 +44,7 @@ class JSONUtils { static final String REDDIT_VIDEO_PREVIEW_KEY = "reddit_video_preview"; static final String IS_REDDIT_MEDIA_DOMAIN = "is_reddit_media_domain"; static final String STICKIED_KEY = "stickied"; - static final String BODY_KEY = "body"; + static final String BODY_HTML_KEY = "body_html"; static final String COLLAPSED_KEY = "collapsed"; static final String IS_SUBMITTER_KEY = "is_submitter"; static final String REPLIES_KEY = "replies"; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index 686a4874..4f3781b0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -72,7 +72,7 @@ class ParseComment { String fullName = data.getString(JSONUtils.LINK_ID); String author = data.getString(JSONUtils.AUTHOR_KEY); boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY); - String commentContent = data.getString(JSONUtils.BODY_KEY); + String commentContent = data.getString(JSONUtils.BODY_HTML_KEY); String permalink = data.getString(JSONUtils.PERMALINK_KEY); int score = data.getInt(JSONUtils.SCORE_KEY); long submitTime = data.getLong(JSONUtils.CREATED_UTC_KEY) * 1000; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java index aed3a1fc..b2fbb420 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java @@ -130,7 +130,12 @@ class ParsePost { Log.i("text", Integer.toString(i)); int postType = PostData.TEXT_TYPE; PostData postData = new PostData(id, fullName, subredditName, formattedPostTime, title, permalink, score, postType, voteType, nsfw); - postData.setSelfText(data.getString(JSONUtils.SELF_TEXT_KEY).trim()); + if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { + postData.setSelfText(""); + } else { + postData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()); + } + postData.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()); bestPostData.add(postData); } else { //No preview link post diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java index 3c31be30..47fa851e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseSubredditData.java @@ -46,6 +46,12 @@ class ParseSubredditData { String description = data.getString(JSONUtils.PUBLIC_DESCRIPTION).trim(); String bannerImageUrl = data.getString(JSONUtils.BANNER_IMG_KEY); String iconImageUrl = data.getString(JSONUtils.ICON_IMG_KEY); + if(iconImageUrl.equals("") || iconImageUrl.equals("null")) { + iconImageUrl = data.getString(JSONUtils.COMMUNITY_ICON_KEY); + if(iconImageUrl.equals("null")) { + iconImageUrl = ""; + } + } int nSubscribers = data.getInt(JSONUtils.SUBSCRIBERS_KEY); int nCurrentOnlineSubscribers = data.getInt(JSONUtils.ACTIVE_USER_COUNT); subredditData = new SubredditData(id, subredditFullName, iconImageUrl, bannerImageUrl, description, nSubscribers); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java index e5a66601..51912948 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewPostDetailActivity.java @@ -32,6 +32,8 @@ import com.bumptech.glide.load.engine.GlideException; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.target.Target; +import org.sufficientlysecure.htmltextview.HtmlTextView; + import java.util.ArrayList; import de.hdodenhof.circleimageview.CircleImageView; @@ -77,7 +79,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { CircleImageView subredditIconCircleImageView = findViewById(R.id.subreddit_icon_circle_image_view_view_post_detail); TextView postTimeTextView = findViewById(R.id.post_time_text_view_view_post_detail); TextView subredditTextView = findViewById(R.id.subreddit_text_view_view_post_detail); - TextView contentTextView = findViewById(R.id.content_text_view_view_post_detail); + HtmlTextView contentTextView = findViewById(R.id.content_html_text_view_view_post_detail); TextView typeTextView = findViewById(R.id.type_text_view_view_post_detail); TextView nsfwTextView = findViewById(R.id.nsfw_text_view_view_post_detail); RelativeLayout relativeLayout = findViewById(R.id.image_view_wrapper_view_post_detail); @@ -294,7 +296,7 @@ public class ViewPostDetailActivity extends AppCompatActivity { typeTextView.setText("TEXT"); if(!mPostData.getSelfText().equals("")) { contentTextView.setVisibility(View.VISIBLE); - contentTextView.setText(mPostData.getSelfText()); + contentTextView.setHtml(mPostData.getSelfText()); } } queryComment(); |