Skip to content

Commit

Permalink
Replace context-excl-excl with requireCOntext()
Browse files Browse the repository at this point in the history
  • Loading branch information
CNugteren committed Feb 6, 2025
1 parent 81758ad commit 36aff42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class BuienradarChartFragment : Fragment() {
activity.toggleNavigationButtons(true)

// Set the location (latitude and longitude)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val locationEnabled = sharedPreferences.getBoolean("location_enable", false)
if (locationEnabled) {
val gpsEnable = sharedPreferences.getBoolean("gps_enable", false)
Expand Down Expand Up @@ -95,7 +95,7 @@ class BuienradarChartFragment : Fragment() {
}

fun loadPage() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val darkMode = sharedPreferences.getString("dark_mode", "dark_mode_no")
var textColour = Color.BLACK
var background = Color.WHITE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class MapFragment : Fragment() {
})

// Set the location (latitude and longitude)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
gifView.drawCircles = sharedPreferences.getBoolean("location_enable", false)
if (gifView.drawCircles && !coordinates.contentEquals(arrayOf(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f))) {
val gpsEnable = sharedPreferences.getBoolean("gps_enable", false)
Expand Down Expand Up @@ -142,7 +142,7 @@ class MapFragment : Fragment() {
}

fun loadPage() {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val backgroundColour = " " + sharedPreferences.getString("background_colour", "black") + " "

val gifView = binding.gifView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SettingsFragment : PreferenceFragmentCompat(),

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.fragment_settings, rootKey)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
enableDisableLocationProviderButton()

// Don't display floating navigation buttons
Expand Down Expand Up @@ -69,13 +69,13 @@ class SettingsFragment : PreferenceFragmentCompat(),

override fun onResume() {
super.onResume()
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
sharedPreferences.registerOnSharedPreferenceChangeListener(this)
}

override fun onPause() {
super.onPause()
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
sharedPreferences.unregisterOnSharedPreferenceChangeListener(this)
}

Expand Down Expand Up @@ -110,7 +110,7 @@ class SettingsFragment : PreferenceFragmentCompat(),
}

private fun setListPreferenceData(defaultViewSelection: ListPreference) {
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context!!)
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
val sourceEnableKNMI = sharedPreferences.getBoolean("knmi_enable", true)
val sourceEnableBuienradar = sharedPreferences.getBoolean("buienradar_enable", false)

Expand Down

0 comments on commit 36aff42

Please sign in to comment.