From 1d2b32ac8c833c6471c1f0c737cff33daf8c34df Mon Sep 17 00:00:00 2001 From: h4h13 Date: Sun, 22 Dec 2019 22:06:11 +0530 Subject: [PATCH] Fix lyrics loading crashing --- .../monkey/retromusic/activities/ArtistDetailActivity.kt | 3 ++- .../monkey/retromusic/activities/GenreDetailsActivity.kt | 9 ++++++++- .../name/monkey/retromusic/activities/LyricsActivity.kt | 5 +++-- app/src/main/res/layout/activity_playlist_detail.xml | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt index 980e9865..4a4a5184 100755 --- a/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/ArtistDetailActivity.kt @@ -184,7 +184,8 @@ class ArtistDetailActivity : AbsSlidingMusicPanelActivity(), ArtistDetailsView, } private fun loadBiography( - name: String, lang: String? = Locale.getDefault().language + name: String, + lang: String? = Locale.getDefault().language ) { biography = null this.lang = lang diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt index 6d3ca809..17612ecd 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/GenreDetailsActivity.kt @@ -19,6 +19,7 @@ import code.name.monkey.retromusic.model.Genre import code.name.monkey.retromusic.model.Song import code.name.monkey.retromusic.mvp.presenter.GenreDetailsPresenter import code.name.monkey.retromusic.mvp.presenter.GenreDetailsView +import code.name.monkey.retromusic.util.DensityUtil import code.name.monkey.retromusic.util.RetroColorUtil import code.name.monkey.retromusic.util.ViewUtil import com.afollestad.materialcab.MaterialCab @@ -44,10 +45,16 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet } private fun checkIsEmpty() { + checkForPadding() emptyEmoji.text = getEmojiByUnicode(0x1F631) empty?.visibility = if (songAdapter.itemCount == 0) View.VISIBLE else View.GONE } + private fun checkForPadding() { + val height = DensityUtil.dip2px(this, 52f) + recyclerView.setPadding(0, 0, 0, (height)) + } + override fun onCreate(savedInstanceState: Bundle?) { setDrawUnderStatusBar() super.onCreate(savedInstanceState) @@ -127,7 +134,7 @@ class GenreDetailsActivity : AbsSlidingMusicPanelActivity(), CabHolder, GenreDet } override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab { - if (cab != null && cab!!.isActive) cab!!.finish() + if (cab != null && cab!!.isActive) cab?.finish() cab = MaterialCab(this, R.id.cab_stub).setMenu(menuRes).setCloseDrawableRes(R.drawable.ic_close_white_24dp).setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(ATHUtil.resolveColor(this, R.attr.colorSurface))).start(callback) return cab!! } diff --git a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt index c2b0f614..abd5e7b8 100644 --- a/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt +++ b/app/src/main/java/code/name/monkey/retromusic/activities/LyricsActivity.kt @@ -106,7 +106,7 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage toolbar.setBackgroundColor(toolbarColor) tabs.setBackgroundColor(toolbarColor) ToolbarContentTintHelper.colorBackButton(toolbar) - + setSupportActionBar(toolbar) tabs.setupWithViewPager(viewPager) tabs.setSelectedTabIndicator(TintHelper.createTintedDrawable(ContextCompat.getDrawable(this, R.drawable.tab_indicator), ThemeStore.accentColor(this))) tabs.setTabTextColors(ATHUtil.resolveColor(this, android.R.attr.textColorSecondary), ThemeStore.accentColor(this)) @@ -137,7 +137,8 @@ class LyricsActivity : AbsMusicServiceActivity(), View.OnClickListener, ViewPage override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == android.R.id.home) { - onBackPressed() + finish() + return true } return super.onOptionsItemSelected(item) } diff --git a/app/src/main/res/layout/activity_playlist_detail.xml b/app/src/main/res/layout/activity_playlist_detail.xml index 2ea2b31f..76009a89 100644 --- a/app/src/main/res/layout/activity_playlist_detail.xml +++ b/app/src/main/res/layout/activity_playlist_detail.xml @@ -17,6 +17,7 @@