From 720c13fa2dc7d877cbf1bfb5a625a722a7e3daa9 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 27 Nov 2020 11:38:36 +0100 Subject: [PATCH] add decoration --- .../drawer/CommentListAdapter.java | 24 +++--- .../helper/CommentDecorationHelper.java | 38 +--------- app/src/main/res/layout/drawer_comment.xml | 75 ++----------------- 3 files changed, 19 insertions(+), 118 deletions(-) diff --git a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java index 9fa3fa1..98ebd83 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java +++ b/app/src/main/java/app/fedilab/fedilabtube/drawer/CommentListAdapter.java @@ -40,7 +40,6 @@ import android.widget.Toast; import androidx.annotation.NonNull; import androidx.appcompat.widget.PopupMenu; -import androidx.constraintlayout.widget.ConstraintLayout; import androidx.core.content.ContextCompat; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.ViewModelProvider; @@ -67,9 +66,6 @@ import es.dmoral.toasty.Toasty; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.MUTE; import static app.fedilab.fedilabtube.client.RetrofitPeertubeAPI.ActionType.REPLY; -import static app.fedilab.fedilabtube.helper.CommentDecorationHelper.allDecoration; -import static app.fedilab.fedilabtube.helper.CommentDecorationHelper.hideDecoration; -import static app.fedilab.fedilabtube.helper.CommentDecorationHelper.topDecorationOnly; public class CommentListAdapter extends RecyclerView.Adapter { @@ -127,21 +123,19 @@ public class CommentListAdapter extends RecyclerView.Adapter { PopupMenu popup = new PopupMenu(context, holder.binding.moreActions); popup.getMenuInflater() diff --git a/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java b/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java index 264506d..6a0e55a 100644 --- a/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java +++ b/app/src/main/java/app/fedilab/fedilabtube/helper/CommentDecorationHelper.java @@ -14,12 +14,9 @@ package app.fedilab.fedilabtube.helper; * You should have received a copy of the GNU General Public License along with TubeLab; if not, * see . */ -import android.view.View; import java.util.List; - import app.fedilab.fedilabtube.client.data.CommentData; -import app.fedilab.fedilabtube.databinding.DrawerCommentBinding; public class CommentDecorationHelper { @@ -27,6 +24,7 @@ public class CommentDecorationHelper { return numberOfIndentation(0, replyToCommentId, comments); } + private static int numberOfIndentation(int currentIdentation, String replyToCommentId, List comments) { String targetedComment = null; @@ -40,40 +38,8 @@ public class CommentDecorationHelper { currentIdentation++; return numberOfIndentation(currentIdentation, targetedComment, comments); } else { - return Math.min(currentIdentation, 5); + return Math.min(currentIdentation, 15); } } - public static void topDecorationOnly(DrawerCommentBinding binding) { - binding.decorationTop.setVisibility(View.VISIBLE); - binding.decorationCurvedTop.setVisibility(View.VISIBLE); - binding.decorationCurvedBottom.setVisibility(View.GONE); - binding.decorationCurvedLine.setVisibility(View.VISIBLE); - binding.decorationBottom.setVisibility(View.GONE); - } - - public static void allDecoration(DrawerCommentBinding binding) { - binding.decorationTop.setVisibility(View.VISIBLE); - binding.decorationCurvedTop.setVisibility(View.VISIBLE); - binding.decorationCurvedBottom.setVisibility(View.VISIBLE); - binding.decorationCurvedLine.setVisibility(View.VISIBLE); - binding.decorationBottom.setVisibility(View.VISIBLE); - } - - public static void hideDecoration(DrawerCommentBinding binding) { - binding.decorationTop.setVisibility(View.GONE); - binding.decorationCurvedTop.setVisibility(View.GONE); - binding.decorationCurvedBottom.setVisibility(View.GONE); - binding.decorationCurvedLine.setVisibility(View.GONE); - binding.decorationBottom.setVisibility(View.GONE); - } - - public static boolean hasReplies(String commentId, List comments) { - for (CommentData.Comment comment : comments) { - if (comment.getInReplyToCommentId() != null && commentId.compareTo(comment.getInReplyToCommentId()) == 0) { - return true; - } - } - return false; - } } diff --git a/app/src/main/res/layout/drawer_comment.xml b/app/src/main/res/layout/drawer_comment.xml index 21fbc2e..e14a89f 100644 --- a/app/src/main/res/layout/drawer_comment.xml +++ b/app/src/main/res/layout/drawer_comment.xml @@ -25,79 +25,20 @@ android:showDividers="end" android:focusable="true"> - - - - - - - - - - - - - - - - + app:layout_constraintTop_toTopOf="parent" /> + android:layout_marginStart="10dp">