Kotlin code refactor
This commit is contained in:
parent
a5cc0572a8
commit
229393e766
14 changed files with 71 additions and 163 deletions
|
@ -54,6 +54,8 @@ object Constants {
|
|||
|
||||
}
|
||||
|
||||
const val EXTRA_SONG = "extra_songs"
|
||||
const val EXTRA_PLAYLIST = "extra_list"
|
||||
const val LIBRARY_CATEGORIES = "library_categories"
|
||||
const val EXTRA_SONG_INFO = "extra_song_info"
|
||||
const val DESATURATED_COLOR = "desaturated_color"
|
||||
|
|
|
@ -17,8 +17,6 @@ import code.name.monkey.appthemehelper.util.TintHelper
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.base.AbsMultiSelectAdapter
|
||||
import code.name.monkey.retromusic.adapter.base.MediaEntryViewHolder
|
||||
import code.name.monkey.retromusic.dialogs.ClearSmartPlaylistDialog
|
||||
import code.name.monkey.retromusic.dialogs.DeletePlaylistDialog
|
||||
import code.name.monkey.retromusic.extensions.hide
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
|
@ -29,7 +27,6 @@ import code.name.monkey.retromusic.model.AbsCustomPlaylist
|
|||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import code.name.monkey.retromusic.model.smartplaylist.LastAddedPlaylist
|
||||
import code.name.monkey.retromusic.util.AutoGeneratedPlaylistBitmap
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.NavigationUtil
|
||||
|
@ -125,24 +122,6 @@ class PlaylistAdapter(
|
|||
|
||||
override fun onMultipleItemAction(menuItem: MenuItem, selection: ArrayList<Playlist>) {
|
||||
when (menuItem.itemId) {
|
||||
R.id.action_delete_playlist -> {
|
||||
var i = 0
|
||||
while (i < selection.size) {
|
||||
val playlist = selection[i]
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
ClearSmartPlaylistDialog.create(playlist).show(
|
||||
activity.supportFragmentManager, "CLEAR_PLAYLIST_" + playlist.name
|
||||
)
|
||||
selection.remove(playlist)
|
||||
i--
|
||||
}
|
||||
i++
|
||||
}
|
||||
if (selection.size > 0) {
|
||||
DeletePlaylistDialog.create(selection)
|
||||
.show(activity.supportFragmentManager, "DELETE_PLAYLIST")
|
||||
}
|
||||
}
|
||||
else -> SongsMenuHelper.handleMenuClick(
|
||||
activity,
|
||||
getSongList(selection),
|
||||
|
@ -183,25 +162,9 @@ class PlaylistAdapter(
|
|||
}
|
||||
|
||||
menu?.setOnClickListener { view ->
|
||||
val playlist = dataSet[layoutPosition]
|
||||
val popupMenu = PopupMenu(activity, view)
|
||||
popupMenu.inflate(
|
||||
if (itemViewType == SMART_PLAYLIST) R.menu.menu_item_smart_playlist
|
||||
else R.menu.menu_item_playlist
|
||||
)
|
||||
if (playlist is LastAddedPlaylist) {
|
||||
popupMenu.menu.findItem(R.id.action_clear_playlist).isVisible = false
|
||||
}
|
||||
popupMenu.inflate(R.menu.menu_item_playlist)
|
||||
popupMenu.setOnMenuItemClickListener { item ->
|
||||
if (item.itemId == R.id.action_clear_playlist) {
|
||||
if (playlist is AbsSmartPlaylist) {
|
||||
ClearSmartPlaylistDialog.create(playlist).show(
|
||||
activity.supportFragmentManager,
|
||||
"CLEAR_SMART_PLAYLIST_" + playlist.name
|
||||
)
|
||||
return@setOnMenuItemClickListener true
|
||||
}
|
||||
}
|
||||
PlaylistMenuHelper.handleMenuClick(
|
||||
activity, dataSet[layoutPosition], item
|
||||
)
|
||||
|
|
|
@ -17,6 +17,7 @@ package code.name.monkey.retromusic.dialogs
|
|||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
import code.name.monkey.retromusic.loaders.PlaylistLoader
|
||||
|
@ -41,21 +42,20 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.add_playlist_title)
|
||||
.setItems(playlistNames.toTypedArray()) { dialog, which ->
|
||||
val songs = extraNotNull<ArrayList<Song>>("songs")
|
||||
.setItems(playlistNames.toTypedArray()) { _, which ->
|
||||
val songs = extraNotNull<ArrayList<Song>>(EXTRA_SONG).value
|
||||
if (which == 0) {
|
||||
CreatePlaylistDialog.create(songs.value)
|
||||
.show(childFragmentManager, "ADD_TO_PLAYLIST")
|
||||
dismiss()
|
||||
CreatePlaylistDialog.create(songs)
|
||||
.show(requireActivity().supportFragmentManager, "ADD_TO_PLAYLIST")
|
||||
} else {
|
||||
PlaylistsUtil.addToPlaylist(
|
||||
requireContext(),
|
||||
songs.value,
|
||||
songs,
|
||||
playlists[which - 1].id,
|
||||
true
|
||||
)
|
||||
dismiss()
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
.create()
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ class AddToPlaylistDialog : DialogFragment() {
|
|||
fun create(songs: List<Song>): AddToPlaylistDialog {
|
||||
val dialog = AddToPlaylistDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList("songs", ArrayList(songs))
|
||||
args.putParcelableArrayList(EXTRA_SONG, ArrayList(songs))
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Hemanth Savarala.
|
||||
*
|
||||
* Licensed under the GNU General Public License v3
|
||||
*
|
||||
* This is free software: you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
package code.name.monkey.retromusic.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import android.os.Bundle
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
||||
|
||||
class ClearSmartPlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
|
||||
val playlist = requireArguments().getParcelable<AbsSmartPlaylist>("playlist")
|
||||
val title = R.string.clear_playlist_title
|
||||
|
||||
val message = HtmlCompat.fromHtml(
|
||||
getString(R.string.clear_playlist_x, playlist!!.name),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.clear_action) { _, _ ->
|
||||
playlist.clear(requireActivity())
|
||||
}
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.create()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
fun create(playlist: AbsSmartPlaylist): ClearSmartPlaylistDialog {
|
||||
val dialog = ClearSmartPlaylistDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelable("playlist", playlist)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,10 +19,9 @@ import android.app.Dialog
|
|||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.appthemehelper.util.MaterialUtil
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
|
@ -30,6 +29,7 @@ import code.name.monkey.retromusic.util.PlaylistsUtil
|
|||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import kotlinx.android.synthetic.main.dialog_playlist.view.*
|
||||
|
||||
class CreatePlaylistDialog : DialogFragment() {
|
||||
|
||||
|
@ -38,19 +38,21 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
savedInstanceState: Bundle?
|
||||
): Dialog {
|
||||
val view = LayoutInflater.from(requireActivity()).inflate(R.layout.dialog_playlist, null)
|
||||
val playlistView: TextInputEditText = view.findViewById(R.id.actionNewPlaylist)
|
||||
val playlistContainer: TextInputLayout = view.findViewById(R.id.actionNewPlaylistContainer)
|
||||
val playlistView: TextInputEditText = view.actionNewPlaylist
|
||||
val playlistContainer: TextInputLayout = view.actionNewPlaylistContainer
|
||||
MaterialUtil.setTint(playlistContainer, false)
|
||||
|
||||
return MaterialAlertDialogBuilder(requireActivity(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireActivity(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.new_playlist_title)
|
||||
.setView(view)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
.setPositiveButton(
|
||||
R.string.create_action
|
||||
) { _, _ ->
|
||||
val extra = extraNotNull<ArrayList<Song>>("songs")
|
||||
val extra = extraNotNull<ArrayList<Song>>(EXTRA_SONG)
|
||||
val playlistName = playlistView.text.toString()
|
||||
if (!TextUtils.isEmpty(playlistName)) {
|
||||
val playlistId = PlaylistsUtil.createPlaylist(
|
||||
|
@ -65,11 +67,6 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
.create()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
(dialog as AlertDialog)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
|
@ -85,7 +82,7 @@ class CreatePlaylistDialog : DialogFragment() {
|
|||
fun create(songs: ArrayList<Song>): CreatePlaylistDialog {
|
||||
val dialog = CreatePlaylistDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList("songs", songs)
|
||||
args.putParcelableArrayList(EXTRA_SONG, songs)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -18,29 +18,30 @@ import android.app.Dialog
|
|||
import android.os.Bundle
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_PLAYLIST
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
import code.name.monkey.retromusic.model.Playlist
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import java.util.*
|
||||
|
||||
class DeletePlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val playlists = requireArguments().getParcelableArrayList<Playlist>("playlist")
|
||||
val playlists = extraNotNull<List<Playlist>>(EXTRA_PLAYLIST).value
|
||||
val title: Int
|
||||
val message: CharSequence
|
||||
//noinspection ConstantConditions
|
||||
if (playlists!!.size > 1) {
|
||||
if (playlists.size > 1) {
|
||||
title = R.string.delete_playlists_title
|
||||
message = HtmlCompat.fromHtml(
|
||||
getString(R.string.delete_x_playlists, playlists.size),
|
||||
String.format(getString(R.string.delete_x_playlists), playlists.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = R.string.delete_playlist_title
|
||||
message = HtmlCompat.fromHtml(
|
||||
getString(R.string.delete_playlist_x, playlists[0].name),
|
||||
String.format(getString(R.string.delete_playlist_x), playlists[0].name),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
|
@ -69,7 +70,7 @@ class DeletePlaylistDialog : DialogFragment() {
|
|||
fun create(playlist: ArrayList<Playlist>): DeletePlaylistDialog {
|
||||
val dialog = DeletePlaylistDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList("playlist", playlist)
|
||||
args.putParcelableArrayList(EXTRA_PLAYLIST, playlist)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.net.Uri
|
|||
import android.os.Bundle
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.saf.SAFGuideActivity
|
||||
import code.name.monkey.retromusic.extensions.extraNotNull
|
||||
|
@ -39,25 +40,27 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
private var deleteSongsAsyncTask: DeleteSongsAsyncTask? = null
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val songs = extraNotNull<List<Song>>("songs¬").value
|
||||
val songs = extraNotNull<List<Song>>(EXTRA_SONG).value
|
||||
var title = 0
|
||||
var message: CharSequence = ""
|
||||
if (songs.size > 1) {
|
||||
title = R.string.delete_songs_title
|
||||
message = HtmlCompat.fromHtml(
|
||||
getString(R.string.delete_x_songs, songs.size),
|
||||
String.format(getString(R.string.delete_x_songs), songs.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = R.string.delete_song_title
|
||||
message = HtmlCompat.fromHtml(
|
||||
getString(R.string.delete_song_x, songs[0].title),
|
||||
String.format(getString(R.string.delete_song_x), songs[0].title),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setCancelable(false)
|
||||
|
@ -111,7 +114,7 @@ class DeleteSongsDialog : DialogFragment() {
|
|||
fun create(songs: List<Song>): DeleteSongsDialog {
|
||||
val dialog = DeleteSongsDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList("songs", ArrayList(songs))
|
||||
args.putParcelableArrayList(EXTRA_SONG, ArrayList(songs))
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.app.Dialog
|
|||
import android.os.Bundle
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.R.string
|
||||
import code.name.monkey.retromusic.model.PlaylistSong
|
||||
|
@ -27,7 +28,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||
class RemoveFromPlaylistDialog : DialogFragment() {
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val songs = requireArguments().getParcelableArrayList<PlaylistSong>("songs")
|
||||
val songs = requireArguments().getParcelableArrayList<PlaylistSong>(EXTRA_SONG)
|
||||
|
||||
var title = 0
|
||||
var message: CharSequence = ""
|
||||
|
@ -35,14 +36,14 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
if (songs.size > 1) {
|
||||
title = R.string.remove_songs_from_playlist_title
|
||||
message = HtmlCompat.fromHtml(
|
||||
getString(string.remove_x_songs_from_playlist, songs.size),
|
||||
String.format(getString(string.remove_x_songs_from_playlist), songs.size),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
)
|
||||
} else {
|
||||
title = R.string.remove_song_from_playlist_title
|
||||
message = HtmlCompat.fromHtml(
|
||||
getString(
|
||||
code.name.monkey.retromusic.R.string.remove_song_x_from_playlist,
|
||||
String.format(
|
||||
getString(string.remove_song_x_from_playlist),
|
||||
songs[0].title
|
||||
),
|
||||
HtmlCompat.FROM_HTML_MODE_LEGACY
|
||||
|
@ -50,8 +51,10 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.remove_action) { _, _ ->
|
||||
|
@ -75,7 +78,7 @@ class RemoveFromPlaylistDialog : DialogFragment() {
|
|||
fun create(songs: ArrayList<PlaylistSong>): RemoveFromPlaylistDialog {
|
||||
val dialog = RemoveFromPlaylistDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelableArrayList("songs", songs)
|
||||
args.putParcelableArrayList(EXTRA_SONG, songs)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -42,8 +42,10 @@ class RenamePlaylistDialog : DialogFragment() {
|
|||
layout.findViewById(R.id.actionNewPlaylistContainer)
|
||||
MaterialUtil.setTint(nameContainer, false)
|
||||
|
||||
return MaterialAlertDialogBuilder(requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert)
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
)
|
||||
.setTitle(R.string.rename_playlist_title)
|
||||
.setView(layout)
|
||||
.setNegativeButton(android.R.string.cancel, null)
|
||||
|
|
|
@ -35,9 +35,7 @@ import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.service.MusicService.ACTION_PENDING_QUIT
|
||||
import code.name.monkey.retromusic.service.MusicService.ACTION_QUIT
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtilKT
|
||||
import code.name.monkey.retromusic.util.ViewUtil
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.WhichButton
|
||||
import com.afollestad.materialdialogs.actions.getActionButton
|
||||
|
@ -169,19 +167,12 @@ class SleepTimerDialog : DialogFragment() {
|
|||
) {
|
||||
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
materialDialog.getActionButton(WhichButton.NEGATIVE).text = String.format(
|
||||
"%s %s",
|
||||
materialDialog.context.getString(R.string.cancel_current_timer),
|
||||
" (" + MusicUtil.getReadableDurationString(millisUntilFinished) + ")"
|
||||
)
|
||||
println("onTick: $millisUntilFinished")
|
||||
seekBar.progress = millisUntilFinished.toInt()
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
updateCancelButton()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setProgressBarColor(dark: Int) {
|
||||
ViewUtil.setProgressDrawable(progressSlider = seekBar, newColor = dark)
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ import android.widget.TextView
|
|||
import androidx.annotation.NonNull
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
|
@ -52,7 +53,7 @@ class SongDetailDialog : DialogFragment() {
|
|||
val context: Context = requireContext()
|
||||
val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_file_details, null)
|
||||
|
||||
val song = requireArguments().getParcelable<Song>("song")
|
||||
val song = requireArguments().getParcelable<Song>(EXTRA_SONG)
|
||||
val fileName: TextView = dialogView.findViewById(R.id.fileName)
|
||||
val filePath: TextView = dialogView.findViewById(R.id.filePath)
|
||||
val fileSize: TextView = dialogView.findViewById(R.id.fileSize)
|
||||
|
@ -165,7 +166,7 @@ class SongDetailDialog : DialogFragment() {
|
|||
fun create(song: Song): SongDetailDialog {
|
||||
val dialog = SongDetailDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelable("song", song)
|
||||
args.putParcelable(EXTRA_SONG, song)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.app.Dialog
|
|||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import code.name.monkey.retromusic.EXTRA_SONG
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.ShareInstagramStory
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
|
@ -26,10 +27,13 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||
|
||||
class SongShareDialog : DialogFragment() {
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val song: Song? = requireArguments().getParcelable("song")
|
||||
val song: Song? = requireArguments().getParcelable(EXTRA_SONG)
|
||||
val listening: String =
|
||||
getString(R.string.currently_listening_to_x_by_x, song?.title, song?.artistName)
|
||||
|
||||
String.format(
|
||||
getString(R.string.currently_listening_to_x_by_x),
|
||||
song?.title,
|
||||
song?.artistName
|
||||
)
|
||||
return MaterialAlertDialogBuilder(
|
||||
requireContext(),
|
||||
R.style.ThemeOverlay_MaterialComponents_Dialog_Alert
|
||||
|
@ -92,7 +96,7 @@ class SongShareDialog : DialogFragment() {
|
|||
fun create(song: Song): SongShareDialog {
|
||||
val dialog = SongShareDialog()
|
||||
val args = Bundle()
|
||||
args.putParcelable("song", song)
|
||||
args.putParcelable(EXTRA_SONG, song)
|
||||
dialog.arguments = args
|
||||
return dialog
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class PlaylistsUtil {
|
|||
return id;
|
||||
}
|
||||
|
||||
public static void deletePlaylists(@NonNull final Context context, @NonNull final ArrayList<Playlist> playlists) {
|
||||
public static void deletePlaylists(@NonNull final Context context, @NonNull final List<Playlist> playlists) {
|
||||
final StringBuilder selection = new StringBuilder();
|
||||
selection.append(MediaStore.Audio.Playlists._ID + " IN (");
|
||||
for (int i = 0; i < playlists.size(); i++) {
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
android:id="@+id/timerDisplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="8dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="16dp"
|
||||
android:textAppearance="@style/TextViewHeadline6" />
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatSeekBar
|
||||
android:id="@+id/seekBar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:maxHeight="3dp"
|
||||
android:paddingTop="12dp"
|
||||
android:splitTrack="false"
|
||||
tools:progress="20" />
|
||||
|
||||
|
@ -26,7 +26,9 @@
|
|||
android:id="@+id/shouldFinishLastSong"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/finish_last_song"
|
||||
android:textAppearance="@style/TextViewSubtitle1" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue