diff --git a/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt index 1634561ac..1bafddb5b 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt @@ -11,6 +11,7 @@ import com.github.libretube.databinding.DownloadedMediaRowBinding import com.github.libretube.obj.DownloadedFile import com.github.libretube.ui.activities.OfflinePlayerActivity import com.github.libretube.ui.viewholders.DownloadsViewHolder +import com.github.libretube.util.DownloadHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.File @@ -49,15 +50,19 @@ class DownloadsAdapter( ) { _, index -> when (index) { 0 -> { - val downloadDir = File( - root.context.getExternalFilesDir(null), - "video" - ) + val audioDir = DownloadHelper.getAudioDir(root.context) + val videoDir = DownloadHelper.getVideoDir(root.context) - File( - downloadDir, - file.name - ).delete() + listOf(audioDir, videoDir).forEach { + val f = File(it, file.name) + if (f.exists()) { + try { + f.delete() + } catch (e: Exception) { + e.printStackTrace() + } + } + } files.removeAt(position) notifyItemRemoved(position) diff --git a/app/src/main/java/com/github/libretube/ui/preferences/GeneralSettings.kt b/app/src/main/java/com/github/libretube/ui/preferences/GeneralSettings.kt index 1a2445f61..5f0d07849 100644 --- a/app/src/main/java/com/github/libretube/ui/preferences/GeneralSettings.kt +++ b/app/src/main/java/com/github/libretube/ui/preferences/GeneralSettings.kt @@ -9,7 +9,6 @@ import com.github.libretube.R import com.github.libretube.constants.PreferenceKeys import com.github.libretube.ui.activities.SettingsActivity 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.util.LocaleHelper import com.github.libretube.util.PreferenceHelper