1010import androidx .fragment .app .DialogFragment ;
1111import androidx .fragment .app .Fragment ;
1212
13- import com .evernote .android .state .State ;
1413import com .livefront .bridge .Bridge ;
1514
1615import org .schabi .newpipe .R ;
1716
1817public class ImportConfirmationDialog extends DialogFragment {
19- @ State
2018 protected Intent resultServiceIntent ;
19+ private static final String EXTRA_RESULT_SERVICE_INTENT = "extra_result_service_intent" ;
2120
2221 public static void show (@ NonNull final Fragment fragment ,
2322 @ NonNull final Intent resultServiceIntent ) {
2423 final ImportConfirmationDialog confirmationDialog = new ImportConfirmationDialog ();
25- confirmationDialog .setResultServiceIntent (resultServiceIntent );
24+ final Bundle args = new Bundle ();
25+ args .putParcelable (EXTRA_RESULT_SERVICE_INTENT , resultServiceIntent );
26+ confirmationDialog .setArguments (args );
2627 confirmationDialog .show (fragment .getParentFragmentManager (), null );
2728 }
2829
29- public void setResultServiceIntent (final Intent resultServiceIntent ) {
30- this .resultServiceIntent = resultServiceIntent ;
31- }
32-
3330 @ NonNull
3431 @ Override
3532 public Dialog onCreateDialog (@ Nullable final Bundle savedInstanceState ) {
@@ -38,9 +35,7 @@ public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
3835 .setCancelable (true )
3936 .setNegativeButton (R .string .cancel , null )
4037 .setPositiveButton (R .string .ok , (dialogInterface , i ) -> {
41- if (resultServiceIntent != null && getContext () != null ) {
42- getContext ().startService (resultServiceIntent );
43- }
38+ requireContext ().startService (resultServiceIntent );
4439 dismiss ();
4540 })
4641 .create ();
@@ -50,11 +45,7 @@ public Dialog onCreateDialog(@Nullable final Bundle savedInstanceState) {
5045 public void onCreate (@ Nullable final Bundle savedInstanceState ) {
5146 super .onCreate (savedInstanceState );
5247
53- if (resultServiceIntent == null ) {
54- throw new IllegalStateException ("Result intent is null" );
55- }
56-
57- Bridge .restoreInstanceState (this , savedInstanceState );
48+ resultServiceIntent = requireArguments ().getParcelable (EXTRA_RESULT_SERVICE_INTENT );
5849 }
5950
6051 @ Override
0 commit comments