mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 13:50:30 +05:30
fix: download activity not dismissed when dialog closed
This commit is contained in:
parent
45fbef920a
commit
f3049b5118
@ -2,18 +2,16 @@ package com.github.libretube.ui.activities
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.os.bundleOf
|
||||
import com.github.libretube.constants.IntentData
|
||||
import com.github.libretube.enums.PlaylistType
|
||||
import com.github.libretube.helpers.IntentHelper
|
||||
import com.github.libretube.helpers.ThemeHelper
|
||||
import com.github.libretube.ui.base.BaseActivity
|
||||
import com.github.libretube.ui.dialogs.DownloadDialog
|
||||
import com.github.libretube.ui.dialogs.DownloadPlaylistDialog
|
||||
|
||||
class DownloadActivity: BaseActivity() {
|
||||
class DownloadActivity : BaseActivity() {
|
||||
override val isDialogActivity: Boolean = true
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@ -26,6 +24,11 @@ class DownloadActivity: BaseActivity() {
|
||||
val videoId = intentData?.getStringExtra(IntentData.videoId)
|
||||
val playlistId = intentData?.getStringExtra(IntentData.playlistId)
|
||||
if (videoId != null) {
|
||||
supportFragmentManager.setFragmentResultListener(
|
||||
DownloadDialog.DOWNLOAD_DIALOG_DISMISSED_KEY,
|
||||
this
|
||||
) { _, _ -> finish() }
|
||||
|
||||
DownloadDialog().apply {
|
||||
arguments = bundleOf(IntentData.videoId to videoId)
|
||||
}.show(supportFragmentManager, null)
|
||||
|
@ -7,8 +7,10 @@ import android.text.InputFilter
|
||||
import android.text.format.Formatter
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.view.isGone
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.setFragmentResult
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.RetrofitInstance
|
||||
@ -253,6 +255,12 @@ class DownloadDialog : DialogFragment() {
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onDismiss(dialog: DialogInterface) {
|
||||
super.onDismiss(dialog)
|
||||
|
||||
setFragmentResult(DOWNLOAD_DIALOG_DISMISSED_KEY, bundleOf())
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Max file name length at Android systems
|
||||
@ -264,5 +272,7 @@ class DownloadDialog : DialogFragment() {
|
||||
private const val AUDIO_DOWNLOAD_QUALITY = "audio_download_quality"
|
||||
private const val AUDIO_DOWNLOAD_FORMAT = "audio_download_format"
|
||||
private const val SUBTITLE_LANGUAGE = "subtitle_download_language"
|
||||
|
||||
const val DOWNLOAD_DIALOG_DISMISSED_KEY = "download_dialog_dismissed_key"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user