Skip to content

Commit 906592b

Browse files
committed
Convert newpipe/local/subscription/ImportConfirmationDialog to kotlin
`onSaveInstanceState` is useless after #12995
1 parent fbac8f2 commit 906592b

File tree

2 files changed

+47
-56
lines changed

2 files changed

+47
-56
lines changed

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

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2018-2026 NewPipe contributors <https://newpipe.net>
3+
* SPDX-License-Identifier: GPL-3.0-or-later
4+
*/
5+
6+
package org.schabi.newpipe.local.subscription
7+
8+
import android.app.Dialog
9+
import android.content.Intent
10+
import android.os.Bundle
11+
import androidx.appcompat.app.AlertDialog
12+
import androidx.fragment.app.DialogFragment
13+
import androidx.fragment.app.Fragment
14+
import org.schabi.newpipe.R
15+
16+
class ImportConfirmationDialog : DialogFragment() {
17+
lateinit var resultServiceIntent: Intent
18+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
19+
return AlertDialog.Builder(requireContext())
20+
.setMessage(R.string.import_network_expensive_warning)
21+
.setCancelable(true)
22+
.setNegativeButton(R.string.cancel, null)
23+
.setPositiveButton(R.string.ok) { _, _ ->
24+
requireContext().startService(resultServiceIntent)
25+
dismiss()
26+
}
27+
.create()
28+
}
29+
30+
override fun onCreate(savedInstanceState: Bundle?) {
31+
super.onCreate(savedInstanceState)
32+
resultServiceIntent = requireArguments().getParcelable(EXTRA_RESULT_SERVICE_INTENT)!!
33+
}
34+
35+
companion object {
36+
private const val EXTRA_RESULT_SERVICE_INTENT = "extra_result_service_intent"
37+
38+
@JvmStatic
39+
fun show(fragment: Fragment, resultServiceIntent: Intent) {
40+
val dialog = ImportConfirmationDialog()
41+
val args = Bundle()
42+
args.putParcelable(EXTRA_RESULT_SERVICE_INTENT, resultServiceIntent)
43+
dialog.setArguments(args)
44+
dialog.show(fragment.getParentFragmentManager(), null)
45+
}
46+
}
47+
}

0 commit comments

Comments
 (0)