Skip to content

Commit cafb139

Browse files
authored
Merge pull request #12995 from siddhesh-06/siddhesh-06/fix/crash-on-soundcloud-import
Fix crash on screen rotation while entering SoundCloud import URL
2 parents 6941248 + 418e341 commit cafb139

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

app/src/main/java/org/schabi/newpipe/local/subscription/ImportConfirmationDialog.java

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,23 @@
1010
import androidx.fragment.app.DialogFragment;
1111
import androidx.fragment.app.Fragment;
1212

13-
import com.evernote.android.state.State;
1413
import com.livefront.bridge.Bridge;
1514

1615
import org.schabi.newpipe.R;
1716

1817
public 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

Comments
 (0)