yuliskov/SmartTube · error · IllegalArgumentException
SelectionListener must not be null. Use `disableSelectionMod
Error message
SelectionListener must not be null. Use `disableSelectionMode()` if you want tp disable selection mode
What it means
enableSelectionMode stores a SelectionListener that receives selected-count callbacks during long-press multi-select. A null listener would make selection silently lose its callbacks, so the API rejects it up front with IllegalArgumentException and names disableSelectionMode() as the intentional way to switch selection off (the 'tp' typo is in the library source).
Source
Thrown at chatkit/src/main/java/com/stfalcon/chatkit/messages/MessagesListAdapter.java:416
if (layoutManager != null && !items.isEmpty()) {
layoutManager.scrollToPosition(items.size() - 1);
}
}
public void scrollToBottom() {
if (layoutManager != null) {
layoutManager.scrollToPosition(0);
}
}
/**
* Enables selection mode.
*
* @param selectionListener listener for selected items count. To get selected messages use {@link #getSelectedMessages()}.
*/
public void enableSelectionMode(SelectionListener selectionListener) {
if (selectionListener == null) {
throw new IllegalArgumentException("SelectionListener must not be null. Use `disableSelectionMode()` if you want tp disable selection mode");
} else {
this.selectionListener = selectionListener;
}
}
/**
* Disables selection mode and removes {@link SelectionListener}.
*/
public void disableSelectionMode() {
this.selectionListener = null;
unselectAllItems();
}
public void enableDateHeader(boolean enable) {
isDateHeaderEnabled = enable;
}
public void enableStackFromEnd(boolean enable) {View on GitHub (pinned to 3de8d90593)
Solutions
- To switch selection off, call disableSelectionMode() — it also unselects current items
- Otherwise construct and pass a non-null SelectionListener implementation
- In Kotlin, make the listener non-null or pass it only after initialization
Example fix
// before adapter.enableSelectionMode(null); // throws // after adapter.disableSelectionMode(); // or adapter.enableSelectionMode(count -> tv.setText(String.valueOf(count)));
Defensive patterns
Strategy: validation
Validate before calling
if (listener == null) {
adapter.disableSelectionMode();
} else {
adapter.enableSelectionMode(listener);
} Prevention
- Treat disableSelectionMode() as the only way to switch selection off
- Keep listener references non-null in Kotlin (no nullable var passed straight through)
When it happens
Trigger: Calling messagesListAdapter.enableSelectionMode(null) — usually a nullable listener variable in Kotlin, or an attempt to turn selection off by passing null.
Common situations: Trying to disable selection with enableSelectionMode(null) instead of disableSelectionMode(); conditionally wiring UI and passing a not-yet-constructed listener; refactoring listeners into optional fields.
Related errors
- ContentChecker cannot be null when using custom content type
- Dates must not be null
- You can't set adapter to DialogsList. Use #setAdapter(Dialog
- content type must be greater or less than '0'!
- Wrong message view type. Please, report this issue on GitHub
AI-assisted analysis of yuliskov/SmartTube@3de8d90593 (2026-08-22).
Data as JSON: /api/errors/3f124b0d32f6c185.
Report an issue: GitHub.