From 5bf1d342f6f30699f02a985cc8b16b6da90d4688 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 26 Dec 2019 23:57:02 +0800 Subject: Markdown table support. --- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 28 +++++++++++++++++++--- app/src/main/res/layout/adapter_default_entry.xml | 15 ++++++++++++ app/src/main/res/layout/adapter_table_block.xml | 19 +++++++++++++++ app/src/main/res/layout/item_post_detail.xml | 10 +++----- app/src/main/res/layout/view_table_entry_cell.xml | 9 +++++++ 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 app/src/main/res/layout/adapter_default_entry.xml create mode 100644 app/src/main/res/layout/adapter_table_block.xml create mode 100644 app/src/main/res/layout/view_table_entry_cell.xml (limited to 'app/src') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 694e0f62..74c04432 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -27,6 +27,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.RequestBuilder; @@ -39,6 +40,8 @@ import com.bumptech.glide.request.target.Target; import com.libRG.CustomTextView; import com.santalu.aspectratioimageview.AspectRatioImageView; +import org.commonmark.ext.gfm.tables.TableBlock; + import java.util.ArrayList; import java.util.Locale; @@ -49,6 +52,9 @@ import io.noties.markwon.Markwon; import io.noties.markwon.MarkwonConfiguration; import io.noties.markwon.ext.strikethrough.StrikethroughPlugin; import io.noties.markwon.linkify.LinkifyPlugin; +import io.noties.markwon.recycler.MarkwonAdapter; +import io.noties.markwon.recycler.table.TableEntry; +import io.noties.markwon.recycler.table.TableEntryPlugin; import io.noties.markwon.simple.ext.SimpleExtPlugin; import io.noties.markwon.urlprocessor.UrlProcessorRelativeToAbsolute; import jp.wasabeef.glide.transformations.BlurTransformation; @@ -97,6 +103,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter builder + .tableLayout(R.layout.adapter_table_block, R.id.table_layout) + .textLayoutIsRoot(R.layout.view_table_entry_cell))) .build(); + mMarkwonAdapter.setMarkdown(mMarkwon, ""); mAccessToken = accessToken; mAccountName = accountName; mPost = post; @@ -493,7 +507,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter + \ No newline at end of file diff --git a/app/src/main/res/layout/adapter_table_block.xml b/app/src/main/res/layout/adapter_table_block.xml new file mode 100644 index 00000000..b3b63a27 --- /dev/null +++ b/app/src/main/res/layout/adapter_table_block.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_post_detail.xml b/app/src/main/res/layout/item_post_detail.xml index 7a9dac19..41fa34da 100644 --- a/app/src/main/res/layout/item_post_detail.xml +++ b/app/src/main/res/layout/item_post_detail.xml @@ -81,15 +81,11 @@ android:textColor="@color/primaryTextColor" android:textSize="?attr/title_font_18" /> - + android:layout_height="match_parent" + android:visibility="gone" /> + \ No newline at end of file -- cgit v1.2.3