1111import org .schabi .newpipe .error .UserAction ;
1212import org .schabi .newpipe .util .PicassoHelper ;
1313
14+ import java .lang .reflect .InvocationTargetException ;
1415import java .util .Optional ;
1516
1617public class DebugSettingsFragment extends BasePreferenceFragment {
18+ private static final String DUMMY = "Dummy" ;
19+
1720 @ Override
1821 public void onCreatePreferences (final Bundle savedInstanceState , final String rootKey ) {
1922 addPreferencesFromResourceRegistry ();
@@ -61,18 +64,18 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
6164 });
6265
6366 crashTheAppPreference .setOnPreferenceClickListener (preference -> {
64- throw new RuntimeException ();
67+ throw new RuntimeException (DUMMY );
6568 });
6669
6770 showErrorSnackbarPreference .setOnPreferenceClickListener (preference -> {
6871 ErrorUtil .showUiErrorSnackbar (DebugSettingsFragment .this ,
69- "Dummy" , new RuntimeException ("Dummy" ));
72+ DUMMY , new RuntimeException (DUMMY ));
7073 return true ;
7174 });
7275
7376 createErrorNotificationPreference .setOnPreferenceClickListener (preference -> {
7477 ErrorUtil .createNotification (requireContext (),
75- new ErrorInfo (new RuntimeException ("Dummy" ), UserAction .UI_ERROR , "Dummy" ));
78+ new ErrorInfo (new RuntimeException (DUMMY ), UserAction .UI_ERROR , DUMMY ));
7679 return true ;
7780 });
7881 }
@@ -81,9 +84,10 @@ private Optional<DebugSettingsBVLeakCanaryAPI> getBVLeakCanary() {
8184 try {
8285 // Try to find the implementation of the LeakCanary API
8386 return Optional .of ((DebugSettingsBVLeakCanaryAPI )
84- Class .forName (DebugSettingsBVLeakCanaryAPI .IMPL_CLASS ).newInstance ());
85- } catch (final ClassNotFoundException
86- | IllegalAccessException | java .lang .InstantiationException e ) {
87+ Class .forName (DebugSettingsBVLeakCanaryAPI .IMPL_CLASS )
88+ .getDeclaredConstructor ()
89+ .newInstance ());
90+ } catch (final Exception e ) {
8791 return Optional .empty ();
8892 }
8993 }
0 commit comments