Reverse the change of unescaping HTML because it also remove all the HTML tags. Fixed subreddit name and post time overlapping. Fixed menu item text not shown in MainActivity.

This commit is contained in:
Alex Ning 2019-05-07 19:45:08 +08:00
parent 1d294609f5
commit 297db53aa3
5 changed files with 23 additions and 15 deletions

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit; package ml.docilealligator.infinityforreddit;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.text.Html;
import android.util.Log; import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
@ -117,7 +116,7 @@ class ParseComment {
boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY); boolean isSubmitter = data.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
String commentContent = ""; String commentContent = "";
if(!data.isNull(JSONUtils.BODY_HTML_KEY)) { if(!data.isNull(JSONUtils.BODY_HTML_KEY)) {
commentContent = Html.fromHtml(data.getString(JSONUtils.BODY_HTML_KEY).trim()).toString(); commentContent = data.getString(JSONUtils.BODY_HTML_KEY).trim();
} }
String permalink = data.getString(JSONUtils.PERMALINK_KEY); String permalink = data.getString(JSONUtils.PERMALINK_KEY);
int score = data.getInt(JSONUtils.SCORE_KEY); int score = data.getInt(JSONUtils.SCORE_KEY);

View File

@ -1,7 +1,6 @@
package ml.docilealligator.infinityforreddit; package ml.docilealligator.infinityforreddit;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.text.Html;
import android.util.Log; import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
@ -63,6 +62,7 @@ class ParsePost {
for(int i = 0; i < allData.length(); i++) { for(int i = 0; i < allData.length(); i++) {
String kind = allData.getJSONObject(i).getString(JSONUtils.KIND_KEY); String kind = allData.getJSONObject(i).getString(JSONUtils.KIND_KEY);
if(!kind.equals("t3")) { if(!kind.equals("t3")) {
//It's a comment
continue; continue;
} }
JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY); JSONObject data = allData.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
@ -149,7 +149,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
post.setSelfText(""); post.setSelfText("");
} else { } else {
post.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); post.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
} }
bestPostData.add(post); bestPostData.add(post);
} else { } else {
@ -162,7 +162,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
linkPost.setSelfText(""); linkPost.setSelfText("");
} else { } else {
linkPost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); linkPost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
} }
bestPostData.add(linkPost); bestPostData.add(linkPost);
} }
@ -253,7 +253,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
textWithImagePost.setSelfText(""); textWithImagePost.setSelfText("");
} else { } else {
textWithImagePost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); textWithImagePost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
} }
bestPostData.add(textWithImagePost); bestPostData.add(textWithImagePost);
} else { } else {
@ -266,7 +266,7 @@ class ParsePost {
if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) { if(data.isNull(JSONUtils.SELFTEXT_HTML_KEY)) {
linkPost.setSelfText(""); linkPost.setSelfText("");
} else { } else {
linkPost.setSelfText(Html.fromHtml(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim()).toString()); linkPost.setSelfText(data.getString(JSONUtils.SELFTEXT_HTML_KEY).trim());
} }
linkPost.setPreviewWidth(previewWidth); linkPost.setPreviewWidth(previewWidth);

View File

@ -34,11 +34,13 @@
<LinearLayout <LinearLayout
android:id="@+id/subreddit_icon_name_linear_layout_view_post_detail" android:id="@+id/subreddit_icon_name_linear_layout_view_post_detail"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="16dp" android:padding="16dp"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/post_time_text_view_view_post_detail"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<CustomView.AspectRatioGifImageView <CustomView.AspectRatioGifImageView
@ -64,6 +66,7 @@
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_view_post_detail"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent"/>

View File

@ -26,7 +26,10 @@
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"/> android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay" />
<com.ferfalk.simplesearchview.SimpleSearchView <com.ferfalk.simplesearchview.SimpleSearchView
android:id="@+id/search_view_main_activity" android:id="@+id/search_view_main_activity"

View File

@ -19,11 +19,13 @@
<LinearLayout <LinearLayout
android:id="@+id/subreddit_icon_name_linear_layout_view_item_best_post" android:id="@+id/subreddit_icon_name_linear_layout_view_item_best_post"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
android:padding="16dp" android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_best_post_item"
app:layout_constraintTop_toTopOf="parent"> app:layout_constraintTop_toTopOf="parent">
<CustomView.AspectRatioGifImageView <CustomView.AspectRatioGifImageView
@ -38,7 +40,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_gravity="center" android:layout_gravity="center"
android:textColor="#E91E63" /> android:textColor="#E91E63"/>
</LinearLayout> </LinearLayout>
@ -46,11 +48,11 @@
android:id="@+id/stickied_post_image_view_best_post_item" android:id="@+id/stickied_post_image_view_best_post_item"
android:layout_width="24dp" android:layout_width="24dp"
android:layout_height="24dp" android:layout_height="24dp"
android:layout_gravity="center"
android:layout_marginStart="8dp" android:layout_marginStart="8dp"
android:layout_marginEnd="8dp" android:layout_marginEnd="8dp"
android:tint="@color/colorPrimary" android:tint="@color/colorPrimary"
android:visibility="gone" android:visibility="gone"
app:layout_constraintStart_toEndOf="@id/subreddit_icon_name_linear_layout_view_item_best_post"
app:layout_constraintEnd_toStartOf="@+id/post_time_text_view_best_post_item" app:layout_constraintEnd_toStartOf="@+id/post_time_text_view_best_post_item"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent"/>
@ -58,12 +60,13 @@
<TextView <TextView
android:id="@+id/post_time_text_view_best_post_item" android:id="@+id/post_time_text_view_best_post_item"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/stickied_post_image_view_best_post_item"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="1"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>