mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 02:53:09 +01:00
Merge pull request #9696 from Stypox/fix-pref-npe
Fix NPEs after OnSharedPreferenceChangeListener changes
This commit is contained in:
commit
d758e50634
@ -172,13 +172,13 @@ public final class VideoDetailFragment
|
||||
|
||||
private final SharedPreferences.OnSharedPreferenceChangeListener preferenceChangeListener =
|
||||
(sharedPreferences, key) -> {
|
||||
if (key.equals(getString(R.string.show_comments_key))) {
|
||||
if (getString(R.string.show_comments_key).equals(key)) {
|
||||
showComments = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
} else if (key.equals(getString(R.string.show_next_video_key))) {
|
||||
} else if (getString(R.string.show_next_video_key).equals(key)) {
|
||||
showRelatedItems = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
} else if (key.equals(getString(R.string.show_description_key))) {
|
||||
} else if (getString(R.string.show_description_key).equals(key)) {
|
||||
showDescription = sharedPreferences.getBoolean(key, true);
|
||||
tabSettingsChanged = true;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ public abstract class BaseListFragment<I, N> extends BaseStateFragment<I>
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
|
||||
final String key) {
|
||||
if (key.equals(getString(R.string.list_view_mode_key))) {
|
||||
if (getString(R.string.list_view_mode_key).equals(key)) {
|
||||
updateFlags |= LIST_MODE_UPDATE_FLAG;
|
||||
}
|
||||
}
|
||||
|
@ -159,11 +159,9 @@ public class RelatedItemsFragment extends BaseListInfoFragment<InfoItem, Related
|
||||
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
|
||||
final String s) {
|
||||
if (headerBinding != null) {
|
||||
headerBinding.autoplaySwitch.setChecked(
|
||||
sharedPreferences.getBoolean(
|
||||
getString(R.string.auto_queue_key), false));
|
||||
final String key) {
|
||||
if (headerBinding != null && getString(R.string.auto_queue_key).equals(key)) {
|
||||
headerBinding.autoplaySwitch.setChecked(sharedPreferences.getBoolean(key, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
|
||||
@Override
|
||||
public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences,
|
||||
final String key) {
|
||||
if (key.equals(getString(R.string.list_view_mode_key))) {
|
||||
if (getString(R.string.list_view_mode_key).equals(key)) {
|
||||
updateFlags |= LIST_MODE_UPDATE_FLAG;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import androidx.annotation.Nullable
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.content.edit
|
||||
@ -122,7 +121,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||
groupName = arguments?.getString(KEY_GROUP_NAME) ?: ""
|
||||
|
||||
onSettingsChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
if (key.equals(getString(R.string.list_view_mode_key))) {
|
||||
if (getString(R.string.list_view_mode_key).equals(key)) {
|
||||
updateListViewModeOnResume = true
|
||||
}
|
||||
}
|
||||
@ -500,7 +499,7 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||
|
||||
private fun handleFeedNotAvailable(
|
||||
subscriptionEntity: SubscriptionEntity,
|
||||
@Nullable cause: Throwable?,
|
||||
cause: Throwable?,
|
||||
nextItemsErrors: List<Throwable>
|
||||
) {
|
||||
val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
|
@ -27,14 +27,14 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
||||
|
||||
updateSeekOptions();
|
||||
|
||||
listener = (sharedPreferences, s) -> {
|
||||
listener = (sharedPreferences, key) -> {
|
||||
|
||||
// on M and above, if user chooses to minimise to popup player on exit
|
||||
// and the app doesn't have display over other apps permission,
|
||||
// show a snackbar to let the user give permission
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
&& s.equals(getString(R.string.minimize_on_exit_key))) {
|
||||
final String newSetting = sharedPreferences.getString(s, null);
|
||||
&& getString(R.string.minimize_on_exit_key).equals(key)) {
|
||||
final String newSetting = sharedPreferences.getString(key, null);
|
||||
if (newSetting != null
|
||||
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))
|
||||
&& !Settings.canDrawOverlays(getContext())) {
|
||||
@ -46,7 +46,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
||||
.show();
|
||||
|
||||
}
|
||||
} else if (s.equals(getString(R.string.use_inexact_seek_key))) {
|
||||
} else if (getString(R.string.use_inexact_seek_key).equals(key)) {
|
||||
updateSeekOptions();
|
||||
}
|
||||
};
|
||||
|
@ -73,7 +73,7 @@ public final class TabsManager {
|
||||
|
||||
private SharedPreferences.OnSharedPreferenceChangeListener getPreferenceChangeListener() {
|
||||
return (sp, key) -> {
|
||||
if (key.equals(savedTabsKey)) {
|
||||
if (savedTabsKey.equals(key)) {
|
||||
if (savedTabsChangeListener != null) {
|
||||
savedTabsChangeListener.onTabsChanged();
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ public class DownloadManagerService extends Service {
|
||||
}
|
||||
|
||||
private void handlePreferenceChange(SharedPreferences prefs, @NonNull String key) {
|
||||
if (key.equals(getString(R.string.downloads_maximum_retry))) {
|
||||
if (getString(R.string.downloads_maximum_retry).equals(key)) {
|
||||
try {
|
||||
String value = prefs.getString(key, getString(R.string.downloads_maximum_retry_default));
|
||||
mManager.mPrefMaxRetry = value == null ? 0 : Integer.parseInt(value);
|
||||
@ -318,13 +318,13 @@ public class DownloadManagerService extends Service {
|
||||
mManager.mPrefMaxRetry = 0;
|
||||
}
|
||||
mManager.updateMaximumAttempts();
|
||||
} else if (key.equals(getString(R.string.downloads_cross_network))) {
|
||||
} else if (getString(R.string.downloads_cross_network).equals(key)) {
|
||||
mManager.mPrefMeteredDownloads = prefs.getBoolean(key, false);
|
||||
} else if (key.equals(getString(R.string.downloads_queue_limit))) {
|
||||
} else if (getString(R.string.downloads_queue_limit).equals(key)) {
|
||||
mManager.mPrefQueueLimit = prefs.getBoolean(key, true);
|
||||
} else if (key.equals(getString(R.string.download_path_video_key))) {
|
||||
} else if (getString(R.string.download_path_video_key).equals(key)) {
|
||||
mManager.mMainStorageVideo = loadMainVideoStorage();
|
||||
} else if (key.equals(getString(R.string.download_path_audio_key))) {
|
||||
} else if (getString(R.string.download_path_audio_key).equals(key)) {
|
||||
mManager.mMainStorageAudio = loadMainAudioStorage();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user