Remove deprecated function and prevent errors in case of a null fragment name
This commit is contained in:
parent
bd6b96d09d
commit
990a354229
@ -74,15 +74,17 @@ class SettingsActivity : AppCompatActivity(),
|
||||
caller: PreferenceFragmentCompat,
|
||||
pref: Preference
|
||||
): Boolean {
|
||||
val fragmentClassName = pref.fragment ?: return false
|
||||
|
||||
// Instantiate the new Fragment
|
||||
val args = pref.extras
|
||||
val fragment = supportFragmentManager.fragmentFactory.instantiate(
|
||||
classLoader,
|
||||
pref.fragment
|
||||
fragmentClassName
|
||||
).apply {
|
||||
arguments = args
|
||||
setTargetFragment(caller, 0)
|
||||
}
|
||||
|
||||
// Replace the existing Fragment with the new Fragment
|
||||
supportFragmentManager.beginTransaction()
|
||||
.replace(R.id.settings, fragment)
|
||||
|
Loading…
Reference in New Issue
Block a user