Fixed Playlist save
This commit is contained in:
parent
7b85fce485
commit
84295eda82
3 changed files with 15 additions and 14 deletions
|
@ -21,9 +21,10 @@ fun Fragment.createNewFile(
|
|||
registerForActivityResult(ActivityResultContracts.StartActivityForResult())
|
||||
{ result: ActivityResult ->
|
||||
if (result.resultCode == Activity.RESULT_OK) {
|
||||
context?.contentResolver?.openOutputStream(result.data?.data!!)?.use { os->
|
||||
write(os, result.data?.data)
|
||||
}
|
||||
write(
|
||||
context?.contentResolver?.openOutputStream(result.data?.data!!),
|
||||
result.data?.data
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ class PlaylistsFragment :
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryViewModel.getPlaylists().observe(viewLifecycleOwner, {
|
||||
libraryViewModel.getPlaylists().observe(viewLifecycleOwner) {
|
||||
if (it.isNotEmpty())
|
||||
adapter?.swapDataSet(it)
|
||||
else
|
||||
adapter?.swapDataSet(listOf())
|
||||
})
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner) {
|
||||
remove()
|
||||
requireActivity().onBackPressed()
|
||||
|
|
|
@ -72,17 +72,17 @@ object M3UWriter : M3UConstants {
|
|||
it.songPrimaryKey
|
||||
}.toSongs()
|
||||
if (songs.isNotEmpty()) {
|
||||
outputStream.bufferedWriter().use{ bw->
|
||||
bw.write(M3UConstants.HEADER)
|
||||
songs.forEach {
|
||||
bw.newLine()
|
||||
bw.write(M3UConstants.ENTRY + it.duration + M3UConstants.DURATION_SEPARATOR + it.artistName + " - " + it.title)
|
||||
bw.newLine()
|
||||
bw.write(it.data)
|
||||
outputStream.use { os ->
|
||||
os.bufferedWriter().use { bw->
|
||||
bw.write(M3UConstants.HEADER)
|
||||
songs.forEach {
|
||||
bw.newLine()
|
||||
bw.write(M3UConstants.ENTRY + it.duration + M3UConstants.DURATION_SEPARATOR + it.artistName + " - " + it.title)
|
||||
bw.newLine()
|
||||
bw.write(it.data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
outputStream.flush()
|
||||
outputStream.close()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue