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);