mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
fix crash
This commit is contained in:
parent
c9007e3456
commit
29afd06478
@ -39,8 +39,8 @@ class AdvancedSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.advanced_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.advanced))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.advanced))
|
||||
|
||||
val maxImageCache = findPreference<ListPreference>(PreferenceKeys.MAX_IMAGE_CACHE)
|
||||
maxImageCache?.setOnPreferenceChangeListener { _, _ ->
|
||||
|
@ -19,8 +19,8 @@ class AppearanceSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.appearance))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.appearance))
|
||||
|
||||
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
|
||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||
|
@ -13,8 +13,8 @@ class GeneralSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.general_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.general))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.general))
|
||||
|
||||
val language = findPreference<ListPreference>("language")
|
||||
language?.setOnPreferenceChangeListener { _, _ ->
|
||||
|
@ -13,8 +13,8 @@ class HistorySettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.history_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.history))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.history))
|
||||
|
||||
// clear search history
|
||||
val clearHistory = findPreference<Preference>(PreferenceKeys.CLEAR_SEARCH_HISTORY)
|
||||
|
@ -51,8 +51,8 @@ class InstanceSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.instance_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.instance))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.instance))
|
||||
|
||||
val instance = findPreference<ListPreference>(PreferenceKeys.FETCH_INSTANCE)
|
||||
// fetchInstance()
|
||||
|
@ -87,14 +87,14 @@ class MainSettings : MaterialPreferenceFragment() {
|
||||
update?.setOnPreferenceClickListener {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
if (!NetworkHelper.isNetworkAvailable(requireContext())) {
|
||||
(activity as SettingsActivity).binding.root.getStyledSnackBar(R.string.unknown_error).show()
|
||||
(activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.unknown_error)?.show()
|
||||
return@launch
|
||||
}
|
||||
// check for update
|
||||
val updateInfo = UpdateChecker.getLatestReleaseInfo()
|
||||
if (updateInfo?.name == null) {
|
||||
// request failed
|
||||
(activity as SettingsActivity).binding.root.getStyledSnackBar(R.string.unknown_error).show()
|
||||
(activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.unknown_error)?.show()
|
||||
} else if (BuildConfig.VERSION_NAME != updateInfo.name) {
|
||||
// show the UpdateAvailableDialog if there's an update available
|
||||
val updateAvailableDialog = UpdateDialog(updateInfo)
|
||||
@ -104,7 +104,7 @@ class MainSettings : MaterialPreferenceFragment() {
|
||||
)
|
||||
} else {
|
||||
// otherwise show the no update available snackBar
|
||||
(activity as SettingsActivity).binding.root.getStyledSnackBar(R.string.app_uptodate).show()
|
||||
(activity as? SettingsActivity)?.binding?.root?.getStyledSnackBar(R.string.app_uptodate)?.show()
|
||||
}
|
||||
}
|
||||
true
|
||||
|
@ -14,8 +14,8 @@ class NotificationSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.notification_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.notifications))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.notifications))
|
||||
|
||||
val notificationsEnabled =
|
||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_ENABLED)
|
||||
|
@ -14,8 +14,8 @@ class PlayerSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.player_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.audio_video))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.audio_video))
|
||||
|
||||
val playerOrientation =
|
||||
findPreference<ListPreference>(PreferenceKeys.FULLSCREEN_ORIENTATION)
|
||||
|
@ -10,7 +10,7 @@ class SponsorBlockSettings : MaterialPreferenceFragment() {
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
|
||||
|
||||
val settingsActivity = activity as SettingsActivity
|
||||
settingsActivity.changeTopBarText(getString(R.string.sponsorblock))
|
||||
val settingsActivity = activity as? SettingsActivity
|
||||
settingsActivity?.changeTopBarText(getString(R.string.sponsorblock))
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user