Skip to content

Commit

Permalink
Check ephemeral state in RingtonePickerDialog onCreateView
Browse files Browse the repository at this point in the history
  • Loading branch information
DeweyReed committed Jun 20, 2020
1 parent 4507772 commit a0bf6e7
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ class RingtonePickerDialog : DialogFragment(), UltimateRingtonePicker.RingtonePi

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {

if (directListener == null) {
val arguments = requireArguments()

if (arguments.getBoolean(EXTRA_EPHEMERAL) && directListener == null) {
dismiss()
}

if (savedInstanceState == null) {
val fragment =
requireArguments().getParcelable<UltimateRingtonePicker.Settings>(EXTRA_SETTINGS)!!
arguments.getParcelable<UltimateRingtonePicker.Settings>(EXTRA_SETTINGS)!!
.createFragment()
childFragmentManager.beginTransaction()
.add(R.id.urpFrameDialog, fragment, TAG_RINGTONE_PICKER)
Expand Down Expand Up @@ -78,6 +80,7 @@ class RingtonePickerDialog : DialogFragment(), UltimateRingtonePicker.RingtonePi

companion object {
private const val EXTRA_TITLE = "title"
private const val EXTRA_EPHEMERAL = "ephemeral"

@JvmStatic
fun createInstance(
Expand All @@ -102,6 +105,7 @@ class RingtonePickerDialog : DialogFragment(), UltimateRingtonePicker.RingtonePi
arguments = Bundle().apply {
putParcelable(EXTRA_SETTINGS, settings)
putCharSequence(EXTRA_TITLE, dialogTitle)
putBoolean(EXTRA_EPHEMERAL, true)
}
directListener = listener
}
Expand Down

0 comments on commit a0bf6e7

Please sign in to comment.