Skip to content

Commit 3ec78a0

Browse files
committed
fx
1 parent 6006bfc commit 3ec78a0

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

app/src/main/java/com/deniscerri/ytdl/database/dao/HistoryDao.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ interface HistoryDao {
7878
fun getAllHistoryList() : List<HistoryItem>
7979

8080
@Query("SELECT * FROM history WHERE id=:id LIMIT 1")
81-
fun getHistoryItem(id: Long) : HistoryItem
81+
fun getHistoryItem(id: Long) : HistoryItem?
8282

8383
@Query("SELECT * FROM history WHERE url=:url")
8484
fun getAllHistoryByURL(url: String) : List<HistoryItem>

app/src/main/java/com/deniscerri/ytdl/database/repository/HistoryRepository.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HistoryRepository(private val historyDao: HistoryDao) {
2020
DATE, TITLE, AUTHOR, FILESIZE
2121
}
2222

23-
fun getItem(id: Long) : HistoryItem {
23+
fun getItem(id: Long) : HistoryItem? {
2424
return historyDao.getHistoryItem(id)
2525
}
2626

app/src/main/java/com/deniscerri/ytdl/ui/downloadcard/DownloadsAlreadyExistDialog.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,16 @@ class DownloadsAlreadyExistDialog : BottomSheetDialogFragment(), AlreadyExistsAd
167167
val historyItem = withContext(Dispatchers.IO){
168168
downloadViewModel.getHistoryItemById(historyItemID)
169169
}
170-
UiUtil.showHistoryItemDetailsCard(historyItem, requireActivity(), isPresent = true, preferences,
171-
removeItem = { item, deleteFile ->
172-
historyViewModel.delete(item, deleteFile)
173-
},
174-
redownloadItem = { },
175-
redownloadShowDownloadCard = {}
176-
)
170+
171+
historyItem?.apply {
172+
UiUtil.showHistoryItemDetailsCard(historyItem, requireActivity(), isPresent = true, preferences,
173+
removeItem = { item, deleteFile ->
174+
historyViewModel.delete(item, deleteFile)
175+
},
176+
redownloadItem = { },
177+
redownloadShowDownloadCard = {}
178+
)
179+
}
177180
}
178181
}
179182
}

0 commit comments

Comments
 (0)