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) { val colorFinal = if (PreferenceUtil.getInstance(requireContext()).adaptiveColor) {
color color
} else { } else {
ThemeStore.accentColor(context!!) ThemeStore.accentColor(requireContext())
}.ripAlpha() }.ripAlpha()
TintHelper.setTintAuto( TintHelper.setTintAuto(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -77,12 +77,12 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
progressViewUpdateHelper!!.start() progressViewUpdateHelper?.start()
} }
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
progressViewUpdateHelper!!.stop() progressViewUpdateHelper?.stop()
} }
override fun onServiceConnected() { 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.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
import code.name.monkey.retromusic.R 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.fragments.base.AbsPlayerControlsFragment
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper