adding a crashfix when playing an empty playlist
This commit is contained in:
parent
886a60db24
commit
f2f2283525
|
@ -92,7 +92,11 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
||||||
}
|
}
|
||||||
|
|
||||||
next_btn.setOnClickListener {
|
next_btn.setOnClickListener {
|
||||||
val adapter = getRecordingsAdapter() ?: return@setOnClickListener
|
val adapter = getRecordingsAdapter()
|
||||||
|
if (adapter == null || adapter.recordings.isEmpty()) {
|
||||||
|
return@setOnClickListener
|
||||||
|
}
|
||||||
|
|
||||||
val oldRecordingIndex = adapter.recordings.indexOfFirst { it.id == adapter.currRecordingId }
|
val oldRecordingIndex = adapter.recordings.indexOfFirst { it.id == adapter.currRecordingId }
|
||||||
val newRecordingIndex = (oldRecordingIndex + 1) % adapter.recordings.size
|
val newRecordingIndex = (oldRecordingIndex + 1) % adapter.recordings.size
|
||||||
val newRecording = adapter.recordings.getOrNull(newRecordingIndex) ?: return@setOnClickListener
|
val newRecording = adapter.recordings.getOrNull(newRecordingIndex) ?: return@setOnClickListener
|
||||||
|
|
Loading…
Reference in New Issue