From b279bb10830f5b32eed89703a573812ac18ca002 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 6 Oct 2022 17:58:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=B6=88=E6=81=AF=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/live/adapter/LiveChatAdapter.java | 2 +- .../java/com/yunbao/live/views/LiveRoomViewHolder.java | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index 94b82ad37..799363de0 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -389,7 +389,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { * @param recyclerView * @return */ - public static boolean isSlideToBottom(RecyclerView recyclerView) { + public boolean isSlideToBottom(RecyclerView recyclerView) { if (recyclerView == null) return false; if (recyclerView.computeVerticalScrollExtent() + recyclerView.computeVerticalScrollOffset() >= recyclerView.computeVerticalScrollRange()) diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index dadfb73c0..eff91cd4e 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -31,6 +31,7 @@ import android.widget.RelativeLayout; import android.widget.TextView; import android.widget.ViewFlipper; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.recyclerview.widget.LinearLayoutManager; @@ -826,6 +827,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); mChatRecyclerView.setAdapter(mLiveChatAdapter); + mChatRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + if (mLiveChatAdapter.isSlideToBottom(recyclerView)) { + newMessage.setVisibility(View.GONE); + } + } + }); mBtnFollow.setOnClickListener(this); mViewMedal.setOnClickListener(this); findViewById(R.id.btn_close).setOnClickListener(this);