Fix crashing, loading albums
This commit is contained in:
parent
397f42a54a
commit
d7ab358e60
59 changed files with 370 additions and 405 deletions
|
@ -33,7 +33,6 @@ import code.name.monkey.retromusic.glide.RetroMusicColoredTarget
|
|||
import code.name.monkey.retromusic.glide.SongGlideRequest
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSongSortOrder
|
||||
import code.name.monkey.retromusic.loaders.ArtistLoader
|
||||
import code.name.monkey.retromusic.misc.AppBarStateChangeListener
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
|
@ -78,6 +77,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
setDrawUnderStatusBar()
|
||||
setupWindowTransition()
|
||||
super.onCreate(savedInstanceState)
|
||||
App.musicComponent.inject(this)
|
||||
toggleBottomNavigationView(true)
|
||||
setLightNavigationBar(true)
|
||||
setNavigationbarColorAuto()
|
||||
|
@ -102,7 +102,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
setOnClickListener { MusicPlayerRemote.openAndShuffleQueue(album.songs!!, true) }
|
||||
}
|
||||
|
||||
App.musicComponent?.inject(this)
|
||||
|
||||
albumDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ALBUM_ID)) {
|
||||
|
@ -186,38 +186,11 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
|
||||
loadAlbumCover()
|
||||
simpleSongAdapter.swapDataSet(album.songs)
|
||||
|
||||
albumDetailsPresenter.loadMore(album.artistId)
|
||||
}
|
||||
|
||||
private lateinit var artistImage: ImageView
|
||||
|
||||
private fun loadMoreFrom(album: Album) {
|
||||
disposable.add(ArtistLoader.getArtistFlowable(this, album.artistId)
|
||||
.map {
|
||||
|
||||
return@map it.albums!!
|
||||
}
|
||||
.map { it.filter { albumSearch -> albumSearch.id != album.id } }
|
||||
.subscribe {
|
||||
for (albumFinal in it) {
|
||||
if (albumFinal.id == album.id)
|
||||
println("$albumFinal -> $album")
|
||||
}
|
||||
if (it.isEmpty()) {
|
||||
return@subscribe
|
||||
}
|
||||
moreTitle.visibility = View.VISIBLE
|
||||
moreRecyclerView.visibility = View.VISIBLE
|
||||
moreTitle.text = String.format("More from %s", album.artistName)
|
||||
|
||||
val albumAdapter = HorizontalAlbumAdapter(this, it as ArrayList<Album>, false, null)
|
||||
moreRecyclerView.layoutManager = GridLayoutManager(this, 1, GridLayoutManager.HORIZONTAL, false)
|
||||
moreRecyclerView.adapter = albumAdapter
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
override fun moreAlbums(albums: ArrayList<Album>) {
|
||||
moreTitle.show()
|
||||
moreRecyclerView.show()
|
||||
|
@ -237,6 +210,7 @@ class AlbumDetailsActivity : AbsSlidingMusicPanelActivity(), AlbumDetailsView {
|
|||
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private fun loadAlbumCover() {
|
||||
|
|
|
@ -79,16 +79,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
|
||||
ActivityCompat.postponeEnterTransition(this)
|
||||
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
artistDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
|
||||
artistDetailsPresenter.loadArtist(intent.extras!!.getInt(EXTRA_ARTIST_ID))
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
|
||||
lastFMRestClient = LastFMRestClient(this)
|
||||
|
||||
setUpViews()
|
||||
|
@ -107,6 +97,15 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
biographyText.maxLines = 4
|
||||
}
|
||||
}
|
||||
|
||||
App.musicComponent.inject(this)
|
||||
artistDetailsPresenter.attachView(this)
|
||||
|
||||
if (intent.extras!!.containsKey(EXTRA_ARTIST_ID)) {
|
||||
artistDetailsPresenter.loadArtist(intent.extras!!.getInt(EXTRA_ARTIST_ID))
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
@ -203,14 +202,6 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
}
|
||||
|
||||
override fun artist(artist: Artist) {
|
||||
setArtist(artist)
|
||||
}
|
||||
|
||||
private fun getArtist(): Artist {
|
||||
return this.artist
|
||||
}
|
||||
|
||||
private fun setArtist(artist: Artist) {
|
||||
if (artist.songCount <= 0) {
|
||||
finish()
|
||||
}
|
||||
|
@ -224,10 +215,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
text.text = String.format("%s • %s", MusicUtil.getArtistInfoString(this, artist), MusicUtil
|
||||
.getReadableDurationString(MusicUtil.getTotalDuration(this, artist.songs)))
|
||||
|
||||
//val songs = artist.songs.sortedWith(compareBy { it.title }) as ArrayList<Song>
|
||||
songAdapter.swapDataSet(artist.songs)
|
||||
|
||||
//val albums = artist.albums?.sortedWith(compareBy { it.artistName }) as ArrayList<Album>
|
||||
albumAdapter.swapDataSet(artist.albums!!)
|
||||
}
|
||||
|
||||
|
@ -255,7 +243,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
|
||||
// If the "lang" parameter is set and no biography is given, retry with default language
|
||||
if (biography == null && lang != null) {
|
||||
loadBiography(getArtist().name, null)
|
||||
loadBiography(artist.name, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,7 +281,7 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView {
|
|||
}
|
||||
|
||||
private fun handleSortOrderMenuItem(item: MenuItem): Boolean {
|
||||
val songs = getArtist().songs
|
||||
val songs = artist.songs
|
||||
when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
super.onBackPressed()
|
||||
|
|
|
@ -50,10 +50,10 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage
|
|||
override fun onPageScrollStateChanged(state: Int) {
|
||||
when (state) {
|
||||
ViewPager.SCROLL_STATE_IDLE ->
|
||||
fab.show(true)
|
||||
fab.show( )
|
||||
ViewPager.SCROLL_STATE_DRAGGING,
|
||||
ViewPager.SCROLL_STATE_SETTLING ->
|
||||
fab.hide(true)
|
||||
fab.hide( )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -92,9 +92,9 @@ class PlayingQueueActivity : AbsMusicServiceActivity() {
|
|||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
clearQueue.shrink(true)
|
||||
clearQueue.shrink( )
|
||||
} else if (dy < 0) {
|
||||
clearQueue.extend(true)
|
||||
clearQueue.extend( )
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -95,9 +95,9 @@ class SearchActivity : AbsMusicServiceActivity(), OnQueryTextListener, TextWatch
|
|||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
super.onScrolled(recyclerView, dx, dy)
|
||||
if (dy > 0) {
|
||||
keyboardPopup.shrink(true)
|
||||
keyboardPopup.shrink()
|
||||
} else if (dy < 0) {
|
||||
keyboardPopup.extend(true)
|
||||
keyboardPopup.extend()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package code.name.monkey.retromusic.activities
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.view.MenuItem
|
||||
import androidx.annotation.StringRes
|
||||
|
@ -11,11 +10,10 @@ import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.activities.base.AbsBaseActivity
|
||||
import code.name.monkey.retromusic.fragments.settings.MainSettingsFragment
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import kotlinx.android.synthetic.main.activity_settings.*
|
||||
|
||||
|
||||
class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
class SettingsActivity : AbsBaseActivity() {
|
||||
|
||||
private val fragmentManager = supportFragmentManager
|
||||
|
||||
|
@ -25,7 +23,6 @@ class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreference
|
|||
|
||||
setStatusbarColorAuto()
|
||||
setNavigationbarColorAuto()
|
||||
|
||||
setLightNavigationBar(true)
|
||||
|
||||
setupToolbar()
|
||||
|
@ -84,23 +81,6 @@ class SettingsActivity : AbsBaseActivity(), SharedPreferences.OnSharedPreference
|
|||
return super.onOptionsItemSelected(item)
|
||||
}
|
||||
|
||||
public override fun onPause() {
|
||||
super.onPause()
|
||||
PreferenceUtil.getInstance(this).unregisterOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
public override fun onResume() {
|
||||
super.onResume()
|
||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this)
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences, key: String) {
|
||||
if (key == PreferenceUtil.PROFILE_IMAGE_PATH) {
|
||||
recreate()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
const val TAG: String = "SettingsActivity"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue