Skip to content

Commit 1d2856f

Browse files
committed
Check savestate of activity before trying to modify DialogFragment
1 parent d12444f commit 1d2856f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import com.duckduckgo.app.browser.autocomplete.BrowserAutoCompleteSuggestionsAda
6666
import com.duckduckgo.app.browser.downloader.DownloadFailReason
6767
import com.duckduckgo.app.browser.downloader.FileDownloadNotificationManager
6868
import com.duckduckgo.app.browser.downloader.FileDownloader
69-
import com.duckduckgo.app.browser.downloader.FileDownloader.FileDownloadListener
7069
import com.duckduckgo.app.browser.downloader.FileDownloader.PendingFileDownload
7170
import com.duckduckgo.app.browser.filechooser.FileChooserIntentBuilder
7271
import com.duckduckgo.app.browser.logindetection.DOMLoginDetector
@@ -1131,18 +1130,16 @@ class BrowserTabFragment : Fragment(), FindListener, CoroutineScope, DaxDialogLi
11311130
}
11321131

11331132
private fun requestDownloadConfirmation(pendingDownload: PendingFileDownload) {
1133+
if (isStateSaved) return
1134+
11341135
val downloadConfirmationFragment = DownloadConfirmationFragment.instance(pendingDownload)
11351136
childFragmentManager.findFragmentByTag(DOWNLOAD_CONFIRMATION_TAG)?.let {
11361137
Timber.i("Found existing dialog; removing it now")
1137-
childFragmentManager.commitNow { remove(it) }
1138+
childFragmentManager.commitNow(allowStateLoss = true) { remove(it) }
11381139
}
11391140
downloadConfirmationFragment.show(childFragmentManager, DOWNLOAD_CONFIRMATION_TAG)
11401141
}
11411142

1142-
private fun completeDownload(pendingDownload: PendingFileDownload, callback: FileDownloadListener) {
1143-
viewModel.download(pendingDownload)
1144-
}
1145-
11461143
private fun launchFilePicker(command: Command.ShowFileChooser) {
11471144
pendingUploadTask = command.filePathCallback
11481145
val canChooseMultipleFiles = command.fileChooserParams.mode == WebChromeClient.FileChooserParams.MODE_OPEN_MULTIPLE

0 commit comments

Comments
 (0)