Added kotlin null safety

This commit is contained in:
h4h13 2020-03-01 18:56:12 +05:30
parent b41ef5bff5
commit 3e655ffc70
9 changed files with 17 additions and 13 deletions

View file

@ -128,7 +128,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color
} else {
ThemeStore.accentColor(context!!)
ThemeStore.accentColor(requireContext())
}.ripAlpha()
TintHelper.setTintAuto(

View file

@ -55,7 +55,7 @@ class BlurPlayerFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPrefer
private fun setUpPlayerToolbar() {
playerToolbar.apply {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { activity!!.onBackPressed() }
setNavigationOnClickListener { requireActivity().onBackPressed() }
ToolbarContentTintHelper.colorizeToolbar(this, Color.WHITE, activity)
}.setOnMenuItemClickListener(this)
}

View file

@ -87,7 +87,7 @@ class CardFragment : AbsPlayerFragment() {
private fun setUpPlayerToolbar() {
playerToolbar.inflateMenu(R.menu.menu_player)
playerToolbar.setNavigationOnClickListener { activity!!.onBackPressed() }
playerToolbar.setNavigationOnClickListener { requireActivity().onBackPressed() }
playerToolbar.setOnMenuItemClickListener(this)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)

View file

@ -136,7 +136,7 @@ class CardPlaybackControlsFragment : AbsPlayerControlsFragment() {
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color
} else {
ThemeStore.accentColor(context!!).ripAlpha()
ThemeStore.accentColor(requireContext()).ripAlpha()
}
image.setColorFilter(colorFinal, PorterDuff.Mode.SRC_IN)
TintHelper.setTintAuto(

View file

@ -98,7 +98,7 @@ class CardBlurFragment : AbsPlayerFragment(), SharedPreferences.OnSharedPreferen
private fun setUpPlayerToolbar() {
playerToolbar.apply {
inflateMenu(R.menu.menu_player)
setNavigationOnClickListener { activity!!.onBackPressed() }
setNavigationOnClickListener { requireActivity().onBackPressed() }
setTitleTextColor(Color.WHITE)
setSubtitleTextColor(Color.WHITE)
ToolbarContentTintHelper.colorizeToolbar(playerToolbar, Color.WHITE, activity)

View file

@ -94,7 +94,7 @@ class FlatPlaybackControlsFragment : AbsPlayerControlsFragment(), Callback {
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color
} else {
ThemeStore.accentColor(context!!).ripAlpha()
ThemeStore.accentColor(requireContext()).ripAlpha()
}
updateTextColors(colorFinal)

View file

@ -95,12 +95,13 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
override fun setDark(color: Int) {
lastPlaybackControlsColor = Color.WHITE
lastDisabledPlaybackControlsColor = ContextCompat.getColor(context!!, R.color.md_grey_500)
lastDisabledPlaybackControlsColor =
ContextCompat.getColor(requireContext(), R.color.md_grey_500)
val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color
} else {
ThemeStore.accentColor(context!!).ripAlpha()
ThemeStore.accentColor(requireContext()).ripAlpha()
}
volumeFragment?.setTintableColor(colorFinal)
text.setTextColor(colorFinal)
@ -180,7 +181,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
private fun setupMenu() {
playerMenu.setOnClickListener {
val popupMenu = PopupMenu(context!!, it)
val popupMenu = PopupMenu(requireContext(), it)
popupMenu.setOnMenuItemClickListener(this)
popupMenu.inflate(R.menu.menu_player)
popupMenu.show()
@ -277,7 +278,7 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
}
private fun toggleFavorite(song: Song) {
MusicUtil.toggleFavorite(activity!!, song)
MusicUtil.toggleFavorite(requireContext(), song)
if (song.id == MusicPlayerRemote.currentSong.id) {
updateIsFavorite()
}

View file

@ -77,12 +77,12 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
override fun onResume() {
super.onResume()
progressViewUpdateHelper!!.start()
progressViewUpdateHelper?.start()
}
override fun onPause() {
super.onPause()
progressViewUpdateHelper!!.stop()
progressViewUpdateHelper?.stop()
}
override fun onServiceConnected() {

View file

@ -9,7 +9,10 @@ import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.*
import code.name.monkey.retromusic.extensions.hide
import code.name.monkey.retromusic.extensions.ripAlpha
import code.name.monkey.retromusic.extensions.show
import code.name.monkey.retromusic.extensions.textColorSecondary
import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper