mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
fix deleting downloads
This commit is contained in:
parent
03701818da
commit
c3b2f5baee
@ -11,6 +11,7 @@ import com.github.libretube.databinding.DownloadedMediaRowBinding
|
|||||||
import com.github.libretube.obj.DownloadedFile
|
import com.github.libretube.obj.DownloadedFile
|
||||||
import com.github.libretube.ui.activities.OfflinePlayerActivity
|
import com.github.libretube.ui.activities.OfflinePlayerActivity
|
||||||
import com.github.libretube.ui.viewholders.DownloadsViewHolder
|
import com.github.libretube.ui.viewholders.DownloadsViewHolder
|
||||||
|
import com.github.libretube.util.DownloadHelper
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -49,15 +50,19 @@ class DownloadsAdapter(
|
|||||||
) { _, index ->
|
) { _, index ->
|
||||||
when (index) {
|
when (index) {
|
||||||
0 -> {
|
0 -> {
|
||||||
val downloadDir = File(
|
val audioDir = DownloadHelper.getAudioDir(root.context)
|
||||||
root.context.getExternalFilesDir(null),
|
val videoDir = DownloadHelper.getVideoDir(root.context)
|
||||||
"video"
|
|
||||||
)
|
|
||||||
|
|
||||||
File(
|
listOf(audioDir, videoDir).forEach {
|
||||||
downloadDir,
|
val f = File(it, file.name)
|
||||||
file.name
|
if (f.exists()) {
|
||||||
).delete()
|
try {
|
||||||
|
f.delete()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
files.removeAt(position)
|
files.removeAt(position)
|
||||||
notifyItemRemoved(position)
|
notifyItemRemoved(position)
|
||||||
|
@ -9,7 +9,6 @@ import com.github.libretube.R
|
|||||||
import com.github.libretube.constants.PreferenceKeys
|
import com.github.libretube.constants.PreferenceKeys
|
||||||
import com.github.libretube.ui.activities.SettingsActivity
|
import com.github.libretube.ui.activities.SettingsActivity
|
||||||
import com.github.libretube.ui.base.BasePreferenceFragment
|
import com.github.libretube.ui.base.BasePreferenceFragment
|
||||||
import com.github.libretube.ui.dialogs.NavBarOptionsDialog
|
|
||||||
import com.github.libretube.ui.dialogs.RequireRestartDialog
|
import com.github.libretube.ui.dialogs.RequireRestartDialog
|
||||||
import com.github.libretube.util.LocaleHelper
|
import com.github.libretube.util.LocaleHelper
|
||||||
import com.github.libretube.util.PreferenceHelper
|
import com.github.libretube.util.PreferenceHelper
|
||||||
|
Loading…
Reference in New Issue
Block a user