|
| 1 | +package org.schabi.newpipe.local.subscription |
| 2 | + |
| 3 | +import android.app.Dialog |
| 4 | +import android.content.DialogInterface |
| 5 | +import android.content.Intent |
| 6 | +import android.os.Bundle |
| 7 | +import androidx.appcompat.app.AlertDialog |
| 8 | +import androidx.fragment.app.DialogFragment |
| 9 | +import androidx.fragment.app.Fragment |
| 10 | +import com.livefront.bridge.Bridge |
| 11 | +import org.schabi.newpipe.R |
| 12 | + |
| 13 | +class ImportConfirmationDialog : DialogFragment() { |
| 14 | + lateinit var resultServiceIntent: Intent |
| 15 | + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { |
| 16 | + return AlertDialog.Builder(requireContext()) |
| 17 | + .setMessage(R.string.import_network_expensive_warning) |
| 18 | + .setCancelable(true) |
| 19 | + .setNegativeButton(R.string.cancel, null) |
| 20 | + .setPositiveButton(R.string.ok) { _, _ -> |
| 21 | + requireContext().startService(resultServiceIntent) |
| 22 | + dismiss() |
| 23 | + } |
| 24 | + .create() |
| 25 | + } |
| 26 | + |
| 27 | + override fun onCreate(savedInstanceState: Bundle?) { |
| 28 | + super.onCreate(savedInstanceState) |
| 29 | + resultServiceIntent = requireArguments().getParcelable(EXTRA_RESULT_SERVICE_INTENT)!! |
| 30 | + } |
| 31 | + |
| 32 | + companion object { |
| 33 | + private const val EXTRA_RESULT_SERVICE_INTENT = "extra_result_service_intent" |
| 34 | + |
| 35 | + @JvmStatic |
| 36 | + fun show(fragment: Fragment, resultServiceIntent: Intent) { |
| 37 | + val dialog = ImportConfirmationDialog() |
| 38 | + val args = Bundle() |
| 39 | + args.putParcelable(EXTRA_RESULT_SERVICE_INTENT, resultServiceIntent) |
| 40 | + dialog.setArguments(args) |
| 41 | + dialog.show(fragment.getParentFragmentManager(), null) |
| 42 | + } |
| 43 | + } |
| 44 | +} |
0 commit comments