2019-03-03 09:20:15 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2018-12-05 04:29:55 +00:00
|
|
|
package code.name.monkey.retromusic.dialogs
|
|
|
|
|
|
|
|
import android.app.Dialog
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.text.Html
|
|
|
|
import androidx.fragment.app.DialogFragment
|
|
|
|
import code.name.monkey.retromusic.R
|
|
|
|
import code.name.monkey.retromusic.model.smartplaylist.AbsSmartPlaylist
|
2019-09-17 19:36:13 +00:00
|
|
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
|
|
import com.afollestad.materialdialogs.LayoutMode
|
2018-12-05 04:29:55 +00:00
|
|
|
import com.afollestad.materialdialogs.MaterialDialog
|
2019-05-15 20:55:57 +00:00
|
|
|
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
|
2018-12-05 04:29:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ClearSmartPlaylistDialog : DialogFragment() {
|
|
|
|
|
|
|
|
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
|
|
|
|
|
|
|
val playlist = arguments!!.getParcelable<AbsSmartPlaylist>("playlist")
|
|
|
|
val title = R.string.clear_playlist_title
|
|
|
|
|
|
|
|
val content = Html.fromHtml(getString(R.string.clear_playlist_x, playlist!!.name))
|
|
|
|
|
2019-09-17 19:36:13 +00:00
|
|
|
return MaterialDialog(requireContext(), BottomSheet(LayoutMode.WRAP_CONTENT)).show {
|
2019-02-19 10:38:51 +00:00
|
|
|
title(title)
|
2019-09-17 19:36:13 +00:00
|
|
|
cornerRadius(PreferenceUtil.getInstance(requireContext()).dialogCorner)
|
2019-02-19 10:38:51 +00:00
|
|
|
message(text = content)
|
|
|
|
positiveButton(R.string.clear_action) {
|
|
|
|
if (activity == null) {
|
|
|
|
return@positiveButton
|
2018-12-05 04:29:55 +00:00
|
|
|
}
|
2019-03-04 03:55:09 +00:00
|
|
|
playlist.clear(activity!!)
|
2019-02-19 10:38:51 +00:00
|
|
|
}
|
|
|
|
negativeButton { (android.R.string.cancel) }
|
|
|
|
}
|
2018-12-05 04:29:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
|
|
|
fun create(playlist: AbsSmartPlaylist): ClearSmartPlaylistDialog {
|
|
|
|
val dialog = ClearSmartPlaylistDialog()
|
|
|
|
val args = Bundle()
|
|
|
|
args.putParcelable("playlist", playlist)
|
|
|
|
dialog.arguments = args
|
|
|
|
return dialog
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|