From d4d9df6ba5cc076732ca86b4641b6970a4cd7107 Mon Sep 17 00:00:00 2001 From: h4h13 Date: Mon, 17 Feb 2020 21:47:47 +0530 Subject: [PATCH] Fix tablet layout crashing --- .../retromusic/adapter/artist/ArtistAdapter.kt | 4 ++++ .../fragments/player/blur/BlurPlayerFragment.kt | 13 ++++++------- .../fragments/player/cardblur/CardBlurFragment.kt | 5 ++--- app/src/main/res/layout-land/fragment_blur.xml | 5 ++++- .../res/layout-land/fragment_card_blur_player.xml | 5 ++++- .../main/res/layout-xlarge-land/fragment_blur.xml | 12 ++++-------- app/src/main/res/layout-xlarge/fragment_blur.xml | 5 ++++- app/src/main/res/layout/fragment_blur.xml | 12 +++++------- .../main/res/layout/fragment_card_blur_player.xml | 5 ++++- .../fragment_card_blur_player_playback_controls.xml | 6 +----- app/src/main/res/values/dimens.xml | 2 +- 11 files changed, 39 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt b/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt index fb183ece..0b7188e0 100644 --- a/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt +++ b/app/src/main/java/code/name/monkey/retromusic/adapter/artist/ArtistAdapter.kt @@ -35,6 +35,10 @@ class ArtistAdapter( activity, cabHolder, R.menu.menu_media_selection ), PopupTextProvider { + init { + this.setHasStableIds(true) + } + fun swapDataSet(dataSet: List) { this.dataSet = dataSet notifyDataSetChanged() diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt index dd5c3cd3..570e6805 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/blur/BlurPlayerFragment.kt @@ -54,7 +54,7 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer } private fun setUpPlayerToolbar() { - playerToolbar!!.apply { + playerToolbar.apply { inflateMenu(R.menu.menu_player) setNavigationOnClickListener { activity!!.onBackPressed() } ToolbarContentTintHelper.colorizeToolbar(this, Color.WHITE, activity) @@ -68,8 +68,8 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer override fun onColorChanged(color: Int) { playbackControlsFragment.setDark(color) lastColor = color - callbacks!!.onPaletteColorChanged() - ToolbarContentTintHelper.colorizeToolbar(playerToolbar!!, Color.WHITE, activity) + callbacks?.onPaletteColorChanged() + ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity) } override fun toggleFavorite(song: Song) { @@ -99,17 +99,16 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer private fun updateBlur() { val blurAmount = PreferenceManager.getDefaultSharedPreferences(requireContext()) .getInt(PreferenceUtil.NEW_BLUR_AMOUNT, 25) - colorBackground!!.clearColorFilter() + colorBackground.clearColorFilter() SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) .checkIgnoreMediaStore(requireContext()) .generatePalette(requireContext()).build() + .dontAnimate() .transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build()) - //.centerCrop() - //.override(320, 480) .into(object : RetroMusicColoredTarget(colorBackground) { override fun onColorReady(color: Int) { if (color == defaultFooterColor) { - colorBackground!!.setColorFilter(color) + colorBackground.setColorFilter(color) } } }) diff --git a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt index 5ff6e16c..f1854004 100644 --- a/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt +++ b/app/src/main/java/code/name/monkey/retromusic/fragments/player/cardblur/CardBlurFragment.kt @@ -133,13 +133,12 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen SongGlideRequest.Builder.from(Glide.with(requireActivity()), MusicPlayerRemote.currentSong) .checkIgnoreMediaStore(requireContext()) .generatePalette(requireContext()).build() + .dontAnimate() .transform(BlurTransformation.Builder(requireContext()).blurRadius(blurAmount.toFloat()).build()) - //.centerCrop() - //.override(320, 480) .into(object : RetroMusicColoredTarget(colorBackground) { override fun onColorReady(color: Int) { if (color == defaultFooterColor) { - colorBackground!!.setColorFilter(color) + colorBackground.setColorFilter(color) } } }) diff --git a/app/src/main/res/layout-land/fragment_blur.xml b/app/src/main/res/layout-land/fragment_blur.xml index 53b138bc..d4040d47 100644 --- a/app/src/main/res/layout-land/fragment_blur.xml +++ b/app/src/main/res/layout-land/fragment_blur.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="?attr/colorSurface" android:clickable="true" android:focusable="true"> @@ -11,7 +12,9 @@ android:id="@+id/colorBackground" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" /> + android:background="?attr/colorSurface" + android:scaleType="centerCrop" + app:srcCompat="@color/black_color" /> @@ -11,7 +12,9 @@ android:id="@+id/colorBackground" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" /> + android:background="?attr/colorSurface" + android:scaleType="centerCrop" + app:srcCompat="@color/black_color" /> @@ -11,21 +12,16 @@ android:id="@+id/colorBackground" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" /> + android:background="?attr/colorSurface" + android:scaleType="centerCrop" + app:srcCompat="@color/black_color" /> - - @@ -11,7 +12,9 @@ android:id="@+id/colorBackground" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" /> + android:background="?attr/colorSurface" + android:scaleType="centerCrop" + app:srcCompat="@color/black_color" /> @@ -11,17 +12,15 @@ android:id="@+id/colorBackground" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" /> + android:background="?attr/colorSurface" + android:scaleType="centerCrop" + app:srcCompat="@color/black_color" /> - + android:layout_weight="1"> @@ -11,7 +12,9 @@ android:id="@+id/colorBackground" android:layout_width="match_parent" android:layout_height="match_parent" - android:scaleType="centerCrop" /> + android:background="?attr/colorSurface" + android:scaleType="centerCrop" + app:srcCompat="@color/black_color" /> - - @@ -81,8 +77,8 @@ android:maxLines="1" android:paddingStart="16dp" android:paddingTop="8dp" - android:paddingBottom="8dp" android:paddingEnd="16dp" + android:paddingBottom="8dp" android:textSize="12sp" tools:text="@tools:sample/lorem/random" /> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index c8084435..bb2608da 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -49,5 +49,5 @@ 56dp 32dp 56dp - 70dp + 72dp