From ecb379d379c932f7ebc6599f601ca2acd6cf730f Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Thu, 28 Mar 2019 23:57:04 +0100 Subject: [PATCH] SettingsActivity: findPreference - cast category result to PreferenceScreen --- .../activities/SettingsActivity.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java index 0ec0eb43..c4bdf0af 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/SettingsActivity.java @@ -161,7 +161,7 @@ public class SettingsActivity extends SyncthingActivity { private Dialog mCurrentPrefScreenDialog = null; /* Run conditions */ - private Preference mCategoryRunConditions; + private PreferenceScreen mCategoryRunConditions; private ListPreference mPowerSource; private CheckBoxPreference mRunOnMobileData; private CheckBoxPreference mRunOnWifi; @@ -177,7 +177,7 @@ public class SettingsActivity extends SyncthingActivity { private Languages mLanguages; /* Syncthing Options */ - private Preference mCategorySyncthingOptions; + private PreferenceScreen mCategorySyncthingOptions; private EditTextPreference mDeviceName; private EditTextPreference mListenAddresses; private EditTextPreference mMaxRecvKbps; @@ -297,7 +297,7 @@ public class SettingsActivity extends SyncthingActivity { getString(R.string.run_on_whitelisted_wifi_networks, wifiSsidSummary) ); - mCategoryRunConditions = findPreference("category_run_conditions"); + mCategoryRunConditions = (PreferenceScreen) findPreference("category_run_conditions"); setPreferenceCategoryChangeListener(mCategoryRunConditions, this::onRunConditionPreferenceChange); /* Behaviour */ @@ -333,7 +333,7 @@ public class SettingsActivity extends SyncthingActivity { mDownloadSupportBundle = findPreference(KEY_DOWNLOAD_SUPPORT_BUNDLE); Preference undoIgnoredDevicesFolders = findPreference(KEY_UNDO_IGNORED_DEVICES_FOLDERS); - mCategorySyncthingOptions = findPreference("category_syncthing_options"); + mCategorySyncthingOptions = (PreferenceScreen) findPreference("category_syncthing_options"); setPreferenceCategoryChangeListener(mCategorySyncthingOptions, this::onSyncthingPreferenceChange); mSyncthingApiKey.setOnPreferenceClickListener(this); mDownloadSupportBundle.setOnPreferenceClickListener(this); @@ -549,10 +549,9 @@ public class SettingsActivity extends SyncthingActivity { } private void setPreferenceCategoryChangeListener( - Preference category, Preference.OnPreferenceChangeListener listener) { - PreferenceScreen ps = (PreferenceScreen) category; - for (int i = 0; i < ps.getPreferenceCount(); i++) { - Preference p = ps.getPreference(i); + PreferenceScreen category, Preference.OnPreferenceChangeListener listener) { + for (int i = 0; i < category.getPreferenceCount(); i++) { + Preference p = category.getPreference(i); p.setOnPreferenceChangeListener(listener); } }