Skip to content

Commit a8c76bf

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Convert newpipe/local/subscription/ImportConfirmationDialog to kotlin
`onSaveInstanceState` is useless after #12995
1 parent 46db9ac commit a8c76bf

2 files changed

Lines changed: 49 additions & 56 deletions

File tree

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

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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.DialogInterface
10+
import android.content.Intent
11+
import android.os.Bundle
12+
import androidx.appcompat.app.AlertDialog
13+
import androidx.fragment.app.DialogFragment
14+
import androidx.fragment.app.Fragment
15+
import com.livefront.bridge.Bridge
16+
import org.schabi.newpipe.R
17+
18+
class ImportConfirmationDialog : DialogFragment() {
19+
lateinit var resultServiceIntent: Intent
20+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
21+
return AlertDialog.Builder(requireContext())
22+
.setMessage(R.string.import_network_expensive_warning)
23+
.setCancelable(true)
24+
.setNegativeButton(R.string.cancel, null)
25+
.setPositiveButton(R.string.ok) { _, _ ->
26+
requireContext().startService(resultServiceIntent)
27+
dismiss()
28+
}
29+
.create()
30+
}
31+
32+
override fun onCreate(savedInstanceState: Bundle?) {
33+
super.onCreate(savedInstanceState)
34+
resultServiceIntent = requireArguments().getParcelable(EXTRA_RESULT_SERVICE_INTENT)!!
35+
}
36+
37+
companion object {
38+
private const val EXTRA_RESULT_SERVICE_INTENT = "extra_result_service_intent"
39+
40+
@JvmStatic
41+
fun show(fragment: Fragment, resultServiceIntent: Intent) {
42+
val dialog = ImportConfirmationDialog()
43+
val args = Bundle()
44+
args.putParcelable(EXTRA_RESULT_SERVICE_INTENT, resultServiceIntent)
45+
dialog.setArguments(args)
46+
dialog.show(fragment.getParentFragmentManager(), null)
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)