aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-04-01 11:42:37 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-04-01 11:42:37 +0000
commit9bfae61ce79d72e2c9272d43b396eedab8bf9dc6 (patch)
treecbe398b542105e682954d7ff3d06f915e57314f4 /app/src/main
parent093fccc790437ec72bea2e1667f1ea06ada3bf10 (diff)
downloadinfinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.tar
infinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.tar.gz
infinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.tar.bz2
infinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.tar.lz
infinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.tar.xz
infinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.tar.zst
infinity-for-reddit-9bfae61ce79d72e2c9272d43b396eedab8bf9dc6.zip
Refine animation of hiding and showing comment toolbar.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java12
-rw-r--r--app/src/main/res/layout/item_comment.xml2
3 files changed, 14 insertions, 6 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index 75a53c5c..7700fcbb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -25,6 +25,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
+import androidx.transition.AutoTransition;
+import androidx.transition.TransitionManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
@@ -1178,6 +1180,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
}
}
+ public void delayTransition() {
+ TransitionManager.beginDelayedTransition(mRecyclerView, new AutoTransition());
+ }
+
@Subscribe
public void onPostUpdateEvent(PostUpdateEventToDetailActivity event) {
if (mPost.getId().equals(event.post.getId())) {
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 44609d19..4027b699 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -853,10 +853,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
if (mCommentToolbarHidden) {
- ((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.GONE);
+ ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
} else {
- ((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.VISIBLE);
+ ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
}
@@ -905,11 +905,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mCommentToolbarHideOnClick) {
View.OnClickListener hideToolbarOnClickListener = view -> {
- if (((CommentViewHolder) holder).bottomConstraintLayout.getVisibility() == View.GONE){
- ((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.VISIBLE);
+ if (((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height == 0) {
+ ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
+ ((ViewPostDetailActivity) mActivity).delayTransition();
} else {
- ((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.GONE);
+ ((ViewPostDetailActivity) mActivity).delayTransition();
+ ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
}
};
diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml
index 535e6fd6..25ef83df 100644
--- a/app/src/main/res/layout/item_comment.xml
+++ b/app/src/main/res/layout/item_comment.xml
@@ -20,7 +20,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
- android:layout_marginBottom="12dp"
android:orientation="vertical"
android:animateLayoutChanges="true">
@@ -115,6 +114,7 @@
android:id="@+id/bottom_constraint_layout_item_post_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:paddingBottom="12dp"
android:paddingStart="4dp"
android:paddingEnd="4dp">