From 9bfae61ce79d72e2c9272d43b396eedab8bf9dc6 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Wed, 1 Apr 2020 19:42:37 +0800 Subject: Refine animation of hiding and showing comment toolbar. --- .../infinityforreddit/Activity/ViewPostDetailActivity.java | 6 ++++++ .../Adapter/CommentAndPostRecyclerViewAdapter.java | 12 +++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'app/src/main/java/ml') 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 { - 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); } }; -- cgit v1.2.3