Browse Source

Fixed crashes when deleting and cancelling download items, ready for next release

master 1.0.1
CookieGamesOfficial 3 weeks ago
parent
commit
88ee0c5630
  1. 4
      app/build.gradle
  2. 14
      app/src/main/java/com/cookiejarapps/smartcookieweb_ytdl/fragments/DownloadsFragment.kt

4
app/build.gradle

@ -11,8 +11,8 @@ android {
applicationId "com.cookiejarapps.smartcookieweb_ytdl"
minSdkVersion 21
targetSdkVersion 29
versionCode 6
versionName "1.0.0"
versionCode 7
versionName "1.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

14
app/src/main/java/com/cookiejarapps/smartcookieweb_ytdl/fragments/DownloadsFragment.kt

@ -115,15 +115,15 @@ class DownloadsFragment : Fragment() {
val repository =
DownloadsRepository(downloadsDao)
GlobalScope.launch {
repository.deleteDownloads((list.adapter as DownloadsAdapter).getDownloadList()[position])
}
DocumentFile.fromSingleUri(
requireContext(),
(list.adapter as DownloadsAdapter).getDownloadList()[position].downloadPath.toUri()
)?.delete()
GlobalScope.launch {
repository.deleteDownloads((list.adapter as DownloadsAdapter).getDownloadList()[position])
}
val updatedList =
(list.adapter as DownloadsAdapter).getDownloadList()
.drop(position)
@ -145,9 +145,6 @@ class DownloadsFragment : Fragment() {
builder.setItems(downloads) { _, which ->
when (which) {
0 -> {
val workManager = WorkManager.getInstance(activity?.applicationContext!!)
workManager.cancelAllWorkByTag((list.adapter as DownloadsAdapter).getDownloadList()[which].videoId)
val downloadsDao = DownloadDatabase.getDatabase(
context!!
).downloadsDao()
@ -158,6 +155,9 @@ class DownloadsFragment : Fragment() {
repository.deleteDownloads((list.adapter as DownloadsAdapter).getDownloadList()[position])
}
val workManager = WorkManager.getInstance(activity?.applicationContext!!)
workManager.cancelAllWorkByTag((list.adapter as DownloadsAdapter).getDownloadList()[which].videoId)
val updatedList =
(list.adapter as DownloadsAdapter).getDownloadList()
.drop(position)

Loading…
Cancel
Save