diff --git a/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java b/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java index ec11bbfcf1..b006813b10 100644 --- a/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java +++ b/app/src/main/java/app/revanced/integrations/youtube/patches/general/GeneralPatch.java @@ -46,12 +46,8 @@ import app.revanced.integrations.shared.utils.ResourceUtils; import app.revanced.integrations.shared.utils.Utils; import app.revanced.integrations.youtube.settings.Settings; -import app.revanced.integrations.youtube.shared.PlayerType; import app.revanced.integrations.youtube.utils.ThemeUtils; -/** - * @noinspection ALL - */ @SuppressWarnings("unused") public class GeneralPatch { @@ -95,7 +91,7 @@ public static void changeStartPage(@NonNull Intent intent) { private static ArrayList formatStreamModelArray; /** - * Find the stream format containing the parameter {@link DEFAULT_AUDIO_TRACKS_IDENTIFIER}, and save to the array. + * Find the stream format containing the parameter {@link GeneralPatch#DEFAULT_AUDIO_TRACKS_IDENTIFIER}, and save to the array. * * @param formatStreamModel stream format model including audio tracks. */ @@ -151,8 +147,7 @@ public static ArrayList getFormatStreamModelArray(final ArrayList * The {@link AlertDialog#getButton(int)} method must be used after {@link AlertDialog#show()} is called. * Otherwise {@link AlertDialog#getButton(int)} method will always return null. - * https://stackoverflow.com/a/4604145 + * *

* That's why {@link AlertDialog#show()} is absolutely necessary. * Instead, use two tricks to hide Alertdialog. @@ -581,17 +576,19 @@ public static void replaceCreateButton(String enumString, View toolbarView) { if (!isCreateButton(enumString)) return; ImageView imageView = getChildView((ViewGroup) toolbarView, view -> view instanceof ImageView); + if (imageView == null) + return; // Overriding is possible only after OnClickListener is assigned to the create button. Utils.runOnMainThreadDelayed(() -> { if (Settings.REPLACE_TOOLBAR_CREATE_BUTTON_TYPE.get()) { - imageView.setOnClickListener(button -> openRVXSettings(button)); + imageView.setOnClickListener(GeneralPatch::openRVXSettings); imageView.setOnLongClickListener(button -> { openYouTubeSettings(button); return true; }); } else { - imageView.setOnClickListener(button -> openYouTubeSettings(button)); + imageView.setOnClickListener(GeneralPatch::openYouTubeSettings); imageView.setOnLongClickListener(button -> { openRVXSettings(button); return true; @@ -631,7 +628,7 @@ public static void setShellActivityTheme(Activity base) { return; base.setTheme(ThemeUtils.getThemeId()); - Utils.runOnMainThreadDelayed(() -> base.finish(), 0); + Utils.runOnMainThreadDelayed(base::finish, 0); }