diff --git a/live/src/main/java/com/yunbao/live/views/PDLiveConversationFragment.java b/live/src/main/java/com/yunbao/live/views/PDLiveConversationFragment.java index f83e318f4..3ad61d8b1 100644 --- a/live/src/main/java/com/yunbao/live/views/PDLiveConversationFragment.java +++ b/live/src/main/java/com/yunbao/live/views/PDLiveConversationFragment.java @@ -5,6 +5,7 @@ import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.text.Editable; +import android.text.InputFilter; import android.text.TextWatcher; import android.view.MotionEvent; import android.view.View; @@ -12,6 +13,7 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.lifecycle.Observer; +import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.event.PDChatInputModeEvent; import com.yunbao.common.http.base.HttpCallback; @@ -52,6 +54,18 @@ public class PDLiveConversationFragment extends ConversationFragment { @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + mList.addOnScrollListener(new RecyclerView.OnScrollListener() { + @Override + public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { + super.onScrollStateChanged(recyclerView, newState); + } + + @Override + public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { + super.onScrolled(recyclerView, dx, dy); + EventBus.getDefault().post(new PDChatInputModeEvent(InputMode.TextInput)); + } + }); super.onViewCreated(view, savedInstanceState); view.setBackgroundColor(Color.parseColor("#00000000")); //TODO 下面片段是尝试修复模拟器emoji无法唤起的bug。后续版本解决该问题: @@ -84,7 +98,6 @@ public class PDLiveConversationFragment extends ConversationFragment { } }); */ - mRongExtensionViewModel.getInputModeLiveData().observe(getViewLifecycleOwner(), new Observer() { @Override public void onChanged(InputMode inputMode) { @@ -118,6 +131,9 @@ public class PDLiveConversationFragment extends ConversationFragment { editString = editable.toString(); } }); + mRongExtension.getInputPanel().getEditText().setFilters(new InputFilter[]{ + new InputFilter.LengthFilter(300) + }); } @Override