Code cleanup
This commit is contained in:
parent
10490e3aa6
commit
1a4ec34bb2
|
@ -17,7 +17,6 @@ package im.vector.riotx.features.settings
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.FragmentManager
|
import androidx.fragment.app.FragmentManager
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
@ -75,32 +74,30 @@ class VectorSettingsActivity : VectorBaseActivity(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat?, pref: Preference?): Boolean {
|
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
|
||||||
var oFragment: Fragment? = null
|
val oFragment = when {
|
||||||
|
VectorPreferences.SETTINGS_NOTIFICATION_TROUBLESHOOT_PREFERENCE_KEY == pref.key ->
|
||||||
if (VectorPreferences.SETTINGS_NOTIFICATION_TROUBLESHOOT_PREFERENCE_KEY == pref?.key) {
|
VectorSettingsNotificationsTroubleshootFragment.newInstance(session.myUserId)
|
||||||
oFragment = VectorSettingsNotificationsTroubleshootFragment.newInstance(session.myUserId)
|
VectorPreferences.SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY == pref.key ->
|
||||||
} else if (VectorPreferences.SETTINGS_NOTIFICATION_ADVANCED_PREFERENCE_KEY == pref?.key) {
|
VectorSettingsAdvancedNotificationPreferenceFragment.newInstance(session.myUserId)
|
||||||
oFragment = VectorSettingsAdvancedNotificationPreferenceFragment.newInstance(session.myUserId)
|
else ->
|
||||||
} else {
|
|
||||||
try {
|
try {
|
||||||
pref?.fragment?.let {
|
pref.fragment?.let {
|
||||||
oFragment = supportFragmentManager.fragmentFactory
|
supportFragmentManager.fragmentFactory.instantiate(classLoader, it)
|
||||||
.instantiate(classLoader, it)
|
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
showSnackbar(getString(R.string.not_implemented))
|
showSnackbar(getString(R.string.not_implemented))
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oFragment != null) {
|
if (oFragment != null) {
|
||||||
oFragment!!.setTargetFragment(caller, 0)
|
oFragment.setTargetFragment(caller, 0)
|
||||||
// Replace the existing Fragment with the new Fragment
|
// Replace the existing Fragment with the new Fragment
|
||||||
supportFragmentManager.beginTransaction()
|
supportFragmentManager.beginTransaction()
|
||||||
.setCustomAnimations(R.anim.right_in, R.anim.fade_out,
|
.setCustomAnimations(R.anim.right_in, R.anim.fade_out, R.anim.fade_in, R.anim.right_out)
|
||||||
R.anim.fade_in, R.anim.right_out)
|
.replace(R.id.vector_settings_page, oFragment, pref.title.toString())
|
||||||
.replace(R.id.vector_settings_page, oFragment!!, pref?.title.toString())
|
|
||||||
.addToBackStack(null)
|
.addToBackStack(null)
|
||||||
.commit()
|
.commit()
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue