Refine animation of hiding and showing comment toolbar.

This commit is contained in:
Alex Ning 2020-04-01 19:42:37 +08:00
parent 093fccc790
commit 9bfae61ce7
3 changed files with 14 additions and 6 deletions

View File

@ -25,6 +25,8 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller; import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.transition.AutoTransition;
import androidx.transition.TransitionManager;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager; 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 @Subscribe
public void onPostUpdateEvent(PostUpdateEventToDetailActivity event) { public void onPostUpdateEvent(PostUpdateEventToDetailActivity event) {
if (mPost.getId().equals(event.post.getId())) { if (mPost.getId().equals(event.post.getId())) {

View File

@ -853,10 +853,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
} }
if (mCommentToolbarHidden) { if (mCommentToolbarHidden) {
((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.GONE); ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
} else { } else {
((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE); ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
} }
@ -905,11 +905,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (mCommentToolbarHideOnClick) { if (mCommentToolbarHideOnClick) {
View.OnClickListener hideToolbarOnClickListener = view -> { View.OnClickListener hideToolbarOnClickListener = view -> {
if (((CommentViewHolder) holder).bottomConstraintLayout.getVisibility() == View.GONE){ if (((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height == 0) {
((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = LinearLayout.LayoutParams.WRAP_CONTENT;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE); ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.GONE);
((ViewPostDetailActivity) mActivity).delayTransition();
} else { } else {
((CommentViewHolder) holder).bottomConstraintLayout.setVisibility(View.GONE); ((ViewPostDetailActivity) mActivity).delayTransition();
((CommentViewHolder) holder).bottomConstraintLayout.getLayoutParams().height = 0;
((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE); ((CommentViewHolder) holder).topScoreTextView.setVisibility(View.VISIBLE);
} }
}; };

View File

@ -20,7 +20,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:layout_marginBottom="12dp"
android:orientation="vertical" android:orientation="vertical"
android:animateLayoutChanges="true"> android:animateLayoutChanges="true">
@ -115,6 +114,7 @@
android:id="@+id/bottom_constraint_layout_item_post_comment" android:id="@+id/bottom_constraint_layout_item_post_comment"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingBottom="12dp"
android:paddingStart="4dp" android:paddingStart="4dp"
android:paddingEnd="4dp"> android:paddingEnd="4dp">