Skip to content

Commit 5144159

Browse files
author
Yevhen Babiichuk (DustDFG)
committed
Convert newpipe/local/subscription/ImportConfirmationDialog to kotlin
Remove exception throwing as instance always has valid either via constructor or via @State restore
1 parent a40b42b commit 5144159

2 files changed

Lines changed: 51 additions & 63 deletions

File tree

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

Lines changed: 0 additions & 63 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 com.evernote.android.state.State
15+
import com.livefront.bridge.Bridge
16+
import org.schabi.newpipe.R
17+
18+
open class ImportConfirmationDialog private constructor(
19+
@State @JvmField protected var resultServiceIntent: Intent
20+
) : DialogFragment() {
21+
22+
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
23+
return AlertDialog.Builder(requireContext())
24+
.setMessage(R.string.import_network_expensive_warning)
25+
.setCancelable(true)
26+
.setNegativeButton(R.string.cancel, null)
27+
.setPositiveButton(R.string.ok) { _, _ ->
28+
requireContext().startService(resultServiceIntent)
29+
dismiss()
30+
}
31+
.create()
32+
}
33+
34+
override fun onCreate(savedInstanceState: Bundle?) {
35+
super.onCreate(savedInstanceState)
36+
Bridge.restoreInstanceState(this, savedInstanceState)
37+
}
38+
39+
override fun onSaveInstanceState(outState: Bundle) {
40+
super.onSaveInstanceState(outState)
41+
Bridge.saveInstanceState(this, outState)
42+
}
43+
44+
companion object {
45+
@JvmStatic
46+
fun show(fragment: Fragment, resultServiceIntent: Intent) {
47+
val confirmationDialog = ImportConfirmationDialog(resultServiceIntent)
48+
confirmationDialog.show(fragment.getParentFragmentManager(), null)
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)