2019-04-20 05:29:45 +00:00
|
|
|
package code.name.monkey.retromusic.activities
|
2018-11-30 01:06:16 +00:00
|
|
|
|
2019-09-18 15:44:14 +00:00
|
|
|
import android.app.ActivityOptions
|
2018-11-30 01:06:16 +00:00
|
|
|
import android.content.Intent
|
|
|
|
import android.os.Bundle
|
2020-01-02 03:53:43 +00:00
|
|
|
import android.transition.Slide
|
2019-11-26 15:27:28 +00:00
|
|
|
import android.view.Menu
|
|
|
|
import android.view.MenuItem
|
|
|
|
import android.view.SubMenu
|
|
|
|
import android.view.View
|
2018-12-25 14:58:47 +00:00
|
|
|
import android.widget.ImageView
|
2019-11-13 13:07:44 +00:00
|
|
|
import androidx.core.app.ActivityCompat
|
2019-11-26 15:27:28 +00:00
|
|
|
import androidx.recyclerview.widget.DefaultItemAnimator
|
|
|
|
import androidx.recyclerview.widget.GridLayoutManager
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager
|
|
|
|
import code.name.monkey.appthemehelper.util.ATHUtil
|
2019-12-01 15:27:01 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.MaterialUtil
|
2020-01-06 03:12:32 +00:00
|
|
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
2019-11-26 15:27:28 +00:00
|
|
|
import code.name.monkey.retromusic.App
|
|
|
|
import code.name.monkey.retromusic.R
|
2019-06-04 18:18:27 +00:00
|
|
|
import code.name.monkey.retromusic.activities.base.AbsSlidingMusicPanelActivity
|
2019-11-26 15:27:28 +00:00
|
|
|
import code.name.monkey.retromusic.activities.tageditor.AbsTagEditorActivity
|
|
|
|
import code.name.monkey.retromusic.activities.tageditor.AlbumTagEditorActivity
|
2019-06-04 18:18:27 +00:00
|
|
|
import code.name.monkey.retromusic.adapter.album.HorizontalAlbumAdapter
|
|
|
|
import code.name.monkey.retromusic.adapter.song.SimpleSongAdapter
|
2019-11-26 15:27:28 +00:00
|
|
|
import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
|
|
|
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
2019-12-06 17:13:09 +00:00
|
|
|
import code.name.monkey.retromusic.extensions.ripAlpha
|
2019-09-04 19:30:24 +00:00
|
|
|
import code.name.monkey.retromusic.extensions.show
|
2019-11-26 15:27:28 +00:00
|
|
|
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
|
|
|
import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
|
|
|
import code.name.monkey.retromusic.glide.SongGlideRequest
|
2018-11-30 01:06:16 +00:00
|
|
|
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
|
|
|
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder
|
2019-11-26 15:27:28 +00:00
|
|
|
import code.name.monkey.retromusic.interfaces.CabHolder
|
|
|
|
import code.name.monkey.retromusic.model.Album
|
|
|
|
import code.name.monkey.retromusic.model.Artist
|
|
|
|
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsPresenter
|
|
|
|
import code.name.monkey.retromusic.mvp.presenter.AlbumDetailsView
|
2020-01-28 17:00:28 +00:00
|
|
|
import code.name.monkey.retromusic.rest.model.LastFmAlbum
|
2019-11-26 15:27:28 +00:00
|
|
|
import code.name.monkey.retromusic.util.MusicUtil
|
|
|
|
import code.name.monkey.retromusic.util.NavigationUtil
|
|
|
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
|
|
|
import code.name.monkey.retromusic.util.RetroColorUtil
|
2020-01-28 17:00:28 +00:00
|
|
|
import code.name.monkey.retromusic.util.RetroUtil
|
2019-11-26 15:27:28 +00:00
|
|
|
import com.afollestad.materialcab.MaterialCab
|
2019-09-16 18:02:40 +00:00
|
|
|
import com.bumptech.glide.Glide
|
2020-01-02 03:53:43 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_album.albumCoverContainer
|
2019-12-30 11:01:50 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_album.albumText
|
|
|
|
import kotlinx.android.synthetic.main.activity_album.albumTitle
|
|
|
|
import kotlinx.android.synthetic.main.activity_album.image
|
|
|
|
import kotlinx.android.synthetic.main.activity_album.toolbar
|
2020-01-28 17:00:28 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.aboutAlbumText
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.aboutAlbumTitle
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.listeners
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.listenersLabel
|
2019-12-30 11:01:50 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.moreRecyclerView
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.moreTitle
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.playAction
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.recyclerView
|
2020-01-28 17:00:28 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.scrobbles
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.scrobblesLabel
|
2019-12-30 11:01:50 +00:00
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.shuffleAction
|
|
|
|
import kotlinx.android.synthetic.main.activity_album_content.songTitle
|
|
|
|
import java.util.ArrayList
|
2019-09-04 19:30:24 +00:00
|
|
|
import javax.inject.Inject
|
2019-09-18 15:44:14 +00:00
|
|
|
import android.util.Pair as UtilPair
|
2018-11-30 01:06:16 +00:00
|
|
|
|
2019-11-26 15:27:28 +00:00
|
|
|
class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView, CabHolder {
|
|
|
|
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
|
|
|
cab?.let {
|
|
|
|
if (it.isActive) it.finish()
|
|
|
|
}
|
|
|
|
cab = MaterialCab(this, R.id.cab_stub)
|
2019-12-30 11:01:50 +00:00
|
|
|
.setMenu(menuRes)
|
|
|
|
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
|
|
|
.setBackgroundColor(
|
|
|
|
RetroColorUtil.shiftBackgroundColorForLightText(
|
|
|
|
ATHUtil.resolveColor(
|
|
|
|
this,
|
|
|
|
R.attr.colorSurface
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.start(callback)
|
2019-11-26 15:27:28 +00:00
|
|
|
return cab as MaterialCab
|
|
|
|
}
|
|
|
|
|
|
|
|
private lateinit var simpleSongAdapter: SimpleSongAdapter
|
|
|
|
private lateinit var album: Album
|
|
|
|
private lateinit var artistImage: ImageView
|
|
|
|
private var cab: MaterialCab? = null
|
|
|
|
private val savedSortOrder: String
|
|
|
|
get() = PreferenceUtil.getInstance(this).albumDetailSongSortOrder
|
|
|
|
|
|
|
|
override fun createContentView(): View {
|
|
|
|
return wrapSlidingMusicPanel(R.layout.activity_album)
|
|
|
|
}
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
lateinit var albumDetailsPresenter: AlbumDetailsPresenter
|
|
|
|
|
2020-01-02 03:53:43 +00:00
|
|
|
private fun windowEnterTransition() {
|
|
|
|
val slide = Slide()
|
|
|
|
slide.excludeTarget(R.id.appBarLayout, true)
|
|
|
|
slide.excludeTarget(R.id.status_bar, true)
|
|
|
|
slide.excludeTarget(android.R.id.statusBarBackground, true)
|
|
|
|
slide.excludeTarget(android.R.id.navigationBarBackground, true)
|
|
|
|
|
|
|
|
window.enterTransition = slide
|
|
|
|
}
|
|
|
|
|
2019-11-26 15:27:28 +00:00
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
|
setDrawUnderStatusBar()
|
|
|
|
super.onCreate(savedInstanceState)
|
|
|
|
toggleBottomNavigationView(true)
|
2019-12-01 15:27:01 +00:00
|
|
|
setStatusbarColorAuto()
|
2019-11-26 15:27:28 +00:00
|
|
|
setNavigationbarColorAuto()
|
|
|
|
setTaskDescriptionColorAuto()
|
|
|
|
setLightNavigationBar(true)
|
2020-01-02 03:53:43 +00:00
|
|
|
window.sharedElementsUseOverlay = true
|
|
|
|
|
|
|
|
App.musicComponent.inject(this)
|
|
|
|
albumDetailsPresenter.attachView(this)
|
2019-11-26 15:27:28 +00:00
|
|
|
|
2020-01-02 03:53:43 +00:00
|
|
|
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
|
|
|
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let {
|
|
|
|
albumDetailsPresenter.loadAlbum(it)
|
|
|
|
albumCoverContainer?.transitionName = "${getString(R.string.transition_album_art)}_$it"
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
|
|
|
|
windowEnterTransition()
|
2019-11-26 15:27:28 +00:00
|
|
|
ActivityCompat.postponeEnterTransition(this)
|
|
|
|
|
2020-01-02 03:53:43 +00:00
|
|
|
|
2019-11-26 15:27:28 +00:00
|
|
|
artistImage = findViewById(R.id.artistImage)
|
|
|
|
|
|
|
|
setupRecyclerView()
|
|
|
|
|
|
|
|
artistImage.setOnClickListener {
|
2019-12-30 11:01:50 +00:00
|
|
|
val artistPairs = ActivityOptions.makeSceneTransitionAnimation(
|
|
|
|
this,
|
2020-01-02 03:53:43 +00:00
|
|
|
UtilPair.create(
|
|
|
|
artistImage,
|
|
|
|
"${getString(R.string.transition_artist_image)}_${album.artistId}"
|
|
|
|
)
|
2019-12-30 11:01:50 +00:00
|
|
|
)
|
2019-11-26 15:27:28 +00:00
|
|
|
NavigationUtil.goToArtistOptions(this, album.artistId, artistPairs)
|
|
|
|
}
|
|
|
|
playAction.apply {
|
|
|
|
setOnClickListener { MusicPlayerRemote.openQueue(album.songs!!, 0, true) }
|
|
|
|
}
|
|
|
|
shuffleAction.apply {
|
|
|
|
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) }
|
|
|
|
}
|
2020-01-28 17:00:28 +00:00
|
|
|
|
|
|
|
aboutAlbumText.setOnClickListener {
|
|
|
|
if (aboutAlbumText.maxLines == 4) {
|
|
|
|
aboutAlbumText.maxLines = Integer.MAX_VALUE
|
|
|
|
} else {
|
|
|
|
aboutAlbumText.maxLines = 4
|
|
|
|
}
|
|
|
|
}
|
2019-11-26 15:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun setupRecyclerView() {
|
|
|
|
simpleSongAdapter = SimpleSongAdapter(this, ArrayList(), R.layout.item_song, this)
|
|
|
|
recyclerView.apply {
|
|
|
|
layoutManager = LinearLayoutManager(this@AlbumDetailsActivity)
|
|
|
|
itemAnimator = DefaultItemAnimator()
|
|
|
|
isNestedScrollingEnabled = false
|
|
|
|
adapter = simpleSongAdapter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
|
super.onDestroy()
|
|
|
|
albumDetailsPresenter.detachView()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun complete() {
|
|
|
|
ActivityCompat.startPostponedEnterTransition(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun album(album: Album) {
|
2020-01-02 03:53:43 +00:00
|
|
|
complete()
|
2019-11-26 15:27:28 +00:00
|
|
|
if (album.songs!!.isEmpty()) {
|
|
|
|
finish()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
this.album = album
|
|
|
|
|
|
|
|
albumTitle.text = album.title
|
|
|
|
if (MusicUtil.getYearString(album.year) == "-") {
|
2019-12-30 11:01:50 +00:00
|
|
|
albumText.text = String.format(
|
|
|
|
"%s • %s",
|
|
|
|
album.artistName,
|
2020-01-17 17:19:06 +00:00
|
|
|
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
|
2019-12-30 11:01:50 +00:00
|
|
|
)
|
2019-11-26 15:27:28 +00:00
|
|
|
} else {
|
2019-12-30 11:01:50 +00:00
|
|
|
albumText.text = String.format(
|
|
|
|
"%s • %s • %s",
|
|
|
|
album.artistName,
|
|
|
|
MusicUtil.getYearString(album.year),
|
2020-01-17 17:19:06 +00:00
|
|
|
MusicUtil.getReadableDurationString(MusicUtil.getTotalDuration(album.songs))
|
2019-12-30 11:01:50 +00:00
|
|
|
)
|
2019-11-26 15:27:28 +00:00
|
|
|
}
|
|
|
|
loadAlbumCover()
|
|
|
|
simpleSongAdapter.swapDataSet(album.songs)
|
|
|
|
albumDetailsPresenter.loadMore(album.artistId)
|
2020-01-28 17:00:28 +00:00
|
|
|
albumDetailsPresenter.aboutAlbum(album.artistName!!, album.title!!)
|
2019-11-26 15:27:28 +00:00
|
|
|
}
|
|
|
|
|
2020-02-17 11:20:08 +00:00
|
|
|
override fun moreAlbums(albums: List<Album>) {
|
2019-11-26 15:27:28 +00:00
|
|
|
moreTitle.show()
|
|
|
|
moreRecyclerView.show()
|
|
|
|
moreTitle.text = String.format(getString(R.string.label_more_from), album.artistName)
|
|
|
|
|
2020-02-17 11:20:08 +00:00
|
|
|
val albumAdapter = HorizontalAlbumAdapter(this, albums, null)
|
2019-11-26 15:27:28 +00:00
|
|
|
moreRecyclerView.layoutManager = GridLayoutManager(
|
2019-12-30 11:01:50 +00:00
|
|
|
this,
|
|
|
|
1,
|
|
|
|
GridLayoutManager.HORIZONTAL,
|
|
|
|
false
|
2019-11-26 15:27:28 +00:00
|
|
|
)
|
|
|
|
moreRecyclerView.adapter = albumAdapter
|
|
|
|
}
|
|
|
|
|
2020-01-28 17:00:28 +00:00
|
|
|
override fun aboutAlbum(lastFmAlbum: LastFmAlbum) {
|
2020-02-01 17:53:26 +00:00
|
|
|
if (lastFmAlbum.album != null) {
|
|
|
|
if (lastFmAlbum.album.wiki != null) {
|
|
|
|
aboutAlbumText.show()
|
|
|
|
aboutAlbumTitle.show()
|
|
|
|
aboutAlbumTitle.text = String.format("About %s", lastFmAlbum.album.name)
|
|
|
|
aboutAlbumText.text = lastFmAlbum.album.wiki.content
|
|
|
|
}
|
|
|
|
if (lastFmAlbum.album.listeners.isNotEmpty()) {
|
|
|
|
listeners.show()
|
|
|
|
listenersLabel.show()
|
|
|
|
scrobbles.show()
|
|
|
|
scrobblesLabel.show()
|
2020-01-28 17:00:28 +00:00
|
|
|
|
2020-02-01 17:53:26 +00:00
|
|
|
listeners.text = RetroUtil.formatValue(lastFmAlbum.album.listeners.toFloat())
|
|
|
|
scrobbles.text = RetroUtil.formatValue(lastFmAlbum.album.playcount.toFloat())
|
|
|
|
}
|
2020-01-28 17:00:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-26 15:27:28 +00:00
|
|
|
override fun loadArtistImage(artist: Artist) {
|
|
|
|
ArtistGlideRequest.Builder.from(Glide.with(this), artist).generatePalette(this).build()
|
2019-12-30 11:01:50 +00:00
|
|
|
.dontAnimate().dontTransform().into(object : RetroMusicColoredTarget(artistImage) {
|
|
|
|
override fun onColorReady(color: Int) {
|
|
|
|
}
|
|
|
|
})
|
2019-11-26 15:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun loadAlbumCover() {
|
|
|
|
SongGlideRequest.Builder.from(Glide.with(this), album.safeGetFirstSong())
|
2019-12-30 11:01:50 +00:00
|
|
|
.checkIgnoreMediaStore(this)
|
|
|
|
.ignoreMediaStore(PreferenceUtil.getInstance(this).ignoreMediaStoreArtwork())
|
|
|
|
.generatePalette(this)
|
|
|
|
.build().dontAnimate().dontTransform()
|
|
|
|
.into(object : RetroMusicColoredTarget(image) {
|
|
|
|
override fun onColorReady(color: Int) {
|
|
|
|
setColors(color)
|
|
|
|
}
|
|
|
|
})
|
2019-11-26 15:27:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private fun setColors(color: Int) {
|
2020-01-28 17:00:28 +00:00
|
|
|
val textColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
|
|
|
color.ripAlpha()
|
|
|
|
else
|
|
|
|
ATHUtil.resolveColor(this, android.R.attr.textColorPrimary)
|
2019-11-26 15:27:28 +00:00
|
|
|
|
2020-01-28 17:00:28 +00:00
|
|
|
songTitle.setTextColor(textColor)
|
|
|
|
moreTitle.setTextColor(textColor)
|
|
|
|
aboutAlbumTitle.setTextColor(textColor)
|
2019-11-26 15:27:28 +00:00
|
|
|
|
2019-12-01 11:28:57 +00:00
|
|
|
val buttonColor = if (PreferenceUtil.getInstance(this).adaptiveColor)
|
2019-12-06 17:13:09 +00:00
|
|
|
color.ripAlpha()
|
2019-12-01 11:28:57 +00:00
|
|
|
else
|
2019-12-06 17:13:09 +00:00
|
|
|
ATHUtil.resolveColor(this, R.attr.colorSurface)
|
2019-11-26 15:27:28 +00:00
|
|
|
|
2019-12-01 15:27:01 +00:00
|
|
|
MaterialUtil.setTint(button = shuffleAction, color = buttonColor)
|
|
|
|
MaterialUtil.setTint(button = playAction, color = buttonColor)
|
2019-11-26 15:27:28 +00:00
|
|
|
|
2019-12-01 15:27:01 +00:00
|
|
|
val toolbarColor = ATHUtil.resolveColor(this, R.attr.colorSurface)
|
|
|
|
toolbar.setBackgroundColor(toolbarColor)
|
2019-11-26 15:27:28 +00:00
|
|
|
setSupportActionBar(toolbar)
|
|
|
|
supportActionBar?.title = null
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
|
|
|
menuInflater.inflate(R.menu.menu_album_detail, menu)
|
|
|
|
val sortOrder = menu.findItem(R.id.action_sort_order)
|
|
|
|
setUpSortOrderMenu(sortOrder.subMenu)
|
2020-01-06 03:12:32 +00:00
|
|
|
ToolbarContentTintHelper.handleOnCreateOptionsMenu(
|
|
|
|
this,
|
|
|
|
toolbar,
|
|
|
|
menu,
|
|
|
|
getToolbarBackgroundColor(toolbar)
|
|
|
|
)
|
2019-11-26 15:27:28 +00:00
|
|
|
return super.onCreateOptionsMenu(menu)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
|
|
return handleSortOrderMenuItem(item)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun handleSortOrderMenuItem(item: MenuItem): Boolean {
|
|
|
|
var sortOrder: String? = null
|
|
|
|
val songs = simpleSongAdapter.dataSet
|
|
|
|
when (item.itemId) {
|
|
|
|
R.id.action_play_next -> {
|
|
|
|
MusicPlayerRemote.playNext(songs)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
R.id.action_add_to_current_playing -> {
|
|
|
|
MusicPlayerRemote.enqueue(songs)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
R.id.action_add_to_playlist -> {
|
|
|
|
AddToPlaylistDialog.create(songs).show(supportFragmentManager, "ADD_PLAYLIST")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
R.id.action_delete_from_device -> {
|
|
|
|
DeleteSongsDialog.create(songs).show(supportFragmentManager, "DELETE_SONGS")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
android.R.id.home -> {
|
|
|
|
super.onBackPressed()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
R.id.action_tag_editor -> {
|
|
|
|
val intent = Intent(this, AlbumTagEditorActivity::class.java)
|
|
|
|
intent.putExtra(AbsTagEditorActivity.EXTRA_ID, album.id)
|
2019-12-30 11:01:50 +00:00
|
|
|
val options = ActivityOptions.makeSceneTransitionAnimation(
|
|
|
|
this,
|
2020-01-05 20:25:55 +00:00
|
|
|
albumCoverContainer,
|
|
|
|
"${getString(R.string.transition_album_art)}_${album.id}"
|
2019-12-30 11:01:50 +00:00
|
|
|
)
|
2019-12-01 15:45:12 +00:00
|
|
|
startActivityForResult(intent, TAG_EDITOR_REQUEST, options.toBundle())
|
2019-11-26 15:27:28 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
/*Sort*/
|
|
|
|
R.id.action_sort_order_title -> sortOrder = AlbumSongSortOrder.SONG_A_Z
|
|
|
|
R.id.action_sort_order_title_desc -> sortOrder = AlbumSongSortOrder.SONG_Z_A
|
|
|
|
R.id.action_sort_order_track_list -> sortOrder = AlbumSongSortOrder.SONG_TRACK_LIST
|
|
|
|
R.id.action_sort_order_artist_song_duration -> sortOrder = AlbumSongSortOrder.SONG_DURATION
|
|
|
|
}
|
|
|
|
if (sortOrder != null) {
|
|
|
|
item.isChecked = true
|
|
|
|
setSaveSortOrder(sortOrder)
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun setUpSortOrderMenu(sortOrder: SubMenu) {
|
|
|
|
when (savedSortOrder) {
|
2019-12-10 17:36:20 +00:00
|
|
|
AlbumSongSortOrder.SONG_A_Z -> sortOrder.findItem(R.id.action_sort_order_title).isChecked = true
|
|
|
|
AlbumSongSortOrder.SONG_Z_A -> sortOrder.findItem(R.id.action_sort_order_title_desc).isChecked = true
|
2019-12-30 11:01:50 +00:00
|
|
|
AlbumSongSortOrder.SONG_TRACK_LIST -> sortOrder.findItem(R.id.action_sort_order_track_list).isChecked =
|
|
|
|
true
|
|
|
|
AlbumSongSortOrder.SONG_DURATION -> sortOrder.findItem(R.id.action_sort_order_artist_song_duration)
|
|
|
|
.isChecked = true
|
2019-11-26 15:27:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun setSaveSortOrder(sortOrder: String?) {
|
|
|
|
PreferenceUtil.getInstance(this).albumDetailSongSortOrder = sortOrder
|
|
|
|
reload()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onMediaStoreChanged() {
|
|
|
|
super.onMediaStoreChanged()
|
|
|
|
reload()
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun reload() {
|
|
|
|
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
|
|
|
intent.extras?.getInt(EXTRA_ALBUM_ID)?.let { albumDetailsPresenter.loadAlbum(it) }
|
|
|
|
} else {
|
|
|
|
finish()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-28 14:22:02 +00:00
|
|
|
override fun onBackPressed() {
|
|
|
|
if (cab != null && cab!!.isActive) {
|
|
|
|
cab?.finish()
|
|
|
|
} else {
|
|
|
|
super.onBackPressed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-26 15:27:28 +00:00
|
|
|
companion object {
|
|
|
|
|
|
|
|
const val EXTRA_ALBUM_ID = "extra_album_id"
|
|
|
|
private const val TAG_EDITOR_REQUEST = 2001
|
|
|
|
}
|
2018-11-30 01:06:16 +00:00
|
|
|
}
|