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?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.advanced_settings, rootKey)
|
setPreferencesFromResource(R.xml.advanced_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.advanced))
|
settingsActivity?.changeTopBarText(getString(R.string.advanced))
|
||||||
|
|
||||||
val maxImageCache = findPreference<ListPreference>(PreferenceKeys.MAX_IMAGE_CACHE)
|
val maxImageCache = findPreference<ListPreference>(PreferenceKeys.MAX_IMAGE_CACHE)
|
||||||
maxImageCache?.setOnPreferenceChangeListener { _, _ ->
|
maxImageCache?.setOnPreferenceChangeListener { _, _ ->
|
||||||
|
@ -19,8 +19,8 @@ class AppearanceSettings : MaterialPreferenceFragment() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
|
setPreferencesFromResource(R.xml.appearance_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.appearance))
|
settingsActivity?.changeTopBarText(getString(R.string.appearance))
|
||||||
|
|
||||||
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
|
val themeToggle = findPreference<ListPreference>(PreferenceKeys.THEME_MODE)
|
||||||
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
themeToggle?.setOnPreferenceChangeListener { _, _ ->
|
||||||
|
@ -13,8 +13,8 @@ class GeneralSettings : MaterialPreferenceFragment() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.general_settings, rootKey)
|
setPreferencesFromResource(R.xml.general_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.general))
|
settingsActivity?.changeTopBarText(getString(R.string.general))
|
||||||
|
|
||||||
val language = findPreference<ListPreference>("language")
|
val language = findPreference<ListPreference>("language")
|
||||||
language?.setOnPreferenceChangeListener { _, _ ->
|
language?.setOnPreferenceChangeListener { _, _ ->
|
||||||
|
@ -13,8 +13,8 @@ class HistorySettings : MaterialPreferenceFragment() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.history_settings, rootKey)
|
setPreferencesFromResource(R.xml.history_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.history))
|
settingsActivity?.changeTopBarText(getString(R.string.history))
|
||||||
|
|
||||||
// clear search history
|
// clear search history
|
||||||
val clearHistory = findPreference<Preference>(PreferenceKeys.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?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.instance_settings, rootKey)
|
setPreferencesFromResource(R.xml.instance_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.instance))
|
settingsActivity?.changeTopBarText(getString(R.string.instance))
|
||||||
|
|
||||||
val instance = findPreference<ListPreference>(PreferenceKeys.FETCH_INSTANCE)
|
val instance = findPreference<ListPreference>(PreferenceKeys.FETCH_INSTANCE)
|
||||||
// fetchInstance()
|
// fetchInstance()
|
||||||
|
@ -87,14 +87,14 @@ class MainSettings : MaterialPreferenceFragment() {
|
|||||||
update?.setOnPreferenceClickListener {
|
update?.setOnPreferenceClickListener {
|
||||||
CoroutineScope(Dispatchers.IO).launch {
|
CoroutineScope(Dispatchers.IO).launch {
|
||||||
if (!NetworkHelper.isNetworkAvailable(requireContext())) {
|
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
|
return@launch
|
||||||
}
|
}
|
||||||
// check for update
|
// check for update
|
||||||
val updateInfo = UpdateChecker.getLatestReleaseInfo()
|
val updateInfo = UpdateChecker.getLatestReleaseInfo()
|
||||||
if (updateInfo?.name == null) {
|
if (updateInfo?.name == null) {
|
||||||
// request failed
|
// 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) {
|
} else if (BuildConfig.VERSION_NAME != updateInfo.name) {
|
||||||
// show the UpdateAvailableDialog if there's an update available
|
// show the UpdateAvailableDialog if there's an update available
|
||||||
val updateAvailableDialog = UpdateDialog(updateInfo)
|
val updateAvailableDialog = UpdateDialog(updateInfo)
|
||||||
@ -104,7 +104,7 @@ class MainSettings : MaterialPreferenceFragment() {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// otherwise show the no update available snackBar
|
// 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
|
true
|
||||||
|
@ -14,8 +14,8 @@ class NotificationSettings : MaterialPreferenceFragment() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.notification_settings, rootKey)
|
setPreferencesFromResource(R.xml.notification_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.notifications))
|
settingsActivity?.changeTopBarText(getString(R.string.notifications))
|
||||||
|
|
||||||
val notificationsEnabled =
|
val notificationsEnabled =
|
||||||
findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_ENABLED)
|
findPreference<SwitchPreferenceCompat>(PreferenceKeys.NOTIFICATION_ENABLED)
|
||||||
|
@ -14,8 +14,8 @@ class PlayerSettings : MaterialPreferenceFragment() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.player_settings, rootKey)
|
setPreferencesFromResource(R.xml.player_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.audio_video))
|
settingsActivity?.changeTopBarText(getString(R.string.audio_video))
|
||||||
|
|
||||||
val playerOrientation =
|
val playerOrientation =
|
||||||
findPreference<ListPreference>(PreferenceKeys.FULLSCREEN_ORIENTATION)
|
findPreference<ListPreference>(PreferenceKeys.FULLSCREEN_ORIENTATION)
|
||||||
|
@ -10,7 +10,7 @@ class SponsorBlockSettings : MaterialPreferenceFragment() {
|
|||||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
|
setPreferencesFromResource(R.xml.sponsorblock_settings, rootKey)
|
||||||
|
|
||||||
val settingsActivity = activity as SettingsActivity
|
val settingsActivity = activity as? SettingsActivity
|
||||||
settingsActivity.changeTopBarText(getString(R.string.sponsorblock))
|
settingsActivity?.changeTopBarText(getString(R.string.sponsorblock))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user