Fix observer not added in a specific case

This commit is contained in:
wch423
2026-02-06 22:30:35 +01:00
parent d1f002a132
commit bbaba3cd33
@@ -89,6 +89,13 @@ public class AudioView extends FrameLayout {
}
private void setupControls() {
// Set up observer in a very specific case when the view is detached and then re-attached,
// but binding from adapter has not happened yet
if (viewModel != null) {
viewModel.getPlaybackState().removeObserver(stateObserver);
viewModel.getPlaybackState().observeForever(stateObserver);
}
playPauseButton.setOnClickListener(v -> {
Log.w(TAG, "playPauseButton onClick");