Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
deniscerri committed Dec 5, 2024
1 parent dc5b66c commit 3c3ef92
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
override fun onActionButtonClick(itemID: Long) {
lifecycleScope.launch {
runCatching {
actionMode?.finish()
val item = withContext(Dispatchers.IO){
downloadViewModel.getItemByID(itemID)
}
Expand Down Expand Up @@ -247,6 +248,7 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
mode!!.menuInflater.inflate(R.menu.cancelled_downloads_menu_context, menu)
mode.title = "${adapter.getSelectedObjectsCount(totalSize)} ${getString(R.string.selected)}"
headerMenuBtn.isEnabled = false
return true
}

Expand Down Expand Up @@ -342,6 +344,7 @@ class CancelledDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClic
override fun onDestroyActionMode(mode: ActionMode?) {
actionMode = null
adapter.clearCheckedItems()
headerMenuBtn.isEnabled = true
}

suspend fun getSelectedIDs() : List<Long>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL

override fun onActionButtonClick(itemID: Long) {
lifecycleScope.launch {
actionMode?.finish()
val item = withContext(Dispatchers.IO){
downloadViewModel.getItemByID(itemID)
}
Expand Down Expand Up @@ -237,6 +238,7 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
mode!!.menuInflater.inflate(R.menu.cancelled_downloads_menu_context, menu)
mode.title = "${adapter.getSelectedObjectsCount(totalSize)} ${getString(R.string.selected)}"
headerMenuBtn.isEnabled = false
return true
}

Expand Down Expand Up @@ -334,6 +336,7 @@ class ErroredDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickL
override fun onDestroyActionMode(mode: ActionMode?) {
actionMode = null
adapter.clearCheckedItems()
headerMenuBtn.isEnabled = true
}

suspend fun getSelectedIDs() : List<Long>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class SavedDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickLis

override fun onActionButtonClick(itemID: Long) {
lifecycleScope.launch {
actionMode?.finish()

val item = withContext(Dispatchers.IO){
downloadViewModel.getItemByID(itemID)
}
Expand Down Expand Up @@ -240,6 +242,7 @@ class SavedDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickLis
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
mode!!.menuInflater.inflate(R.menu.saved_downloads_menu_context, menu)
mode.title = "${adapter.getSelectedObjectsCount(totalSize)} ${getString(R.string.selected)}"
headerMenuBtn.isEnabled = false
return true
}

Expand Down Expand Up @@ -339,6 +342,7 @@ class SavedDownloadsFragment : Fragment(), GenericDownloadAdapter.OnItemClickLis
override fun onDestroyActionMode(mode: ActionMode?) {
actionMode = null
adapter.clearCheckedItems()
headerMenuBtn.isEnabled = true
}

suspend fun getSelectedIDs() : List<Long>{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ class ScheduledDownloadsFragment : Fragment(), ScheduledDownloadAdapter.OnItemCl

override fun onActionButtonClick(itemID: Long) {
lifecycleScope.launch {
actionMode?.finish()
runCatching {
withContext(Dispatchers.IO){
downloadViewModel.resetScheduleTimeForItemsAndStartDownload(listOf(itemID))
Expand Down Expand Up @@ -265,6 +266,7 @@ class ScheduledDownloadsFragment : Fragment(), ScheduledDownloadAdapter.OnItemCl
override fun onCreateActionMode(mode: ActionMode?, menu: Menu?): Boolean {
mode!!.menuInflater.inflate(R.menu.scheduled_downloads_menu_context, menu)
mode.title = "${adapter.getSelectedObjectsCount(totalSize)} ${getString(R.string.selected)}"
headerMenuBtn.isEnabled = false
return true
}

Expand Down Expand Up @@ -351,6 +353,7 @@ class ScheduledDownloadsFragment : Fragment(), ScheduledDownloadAdapter.OnItemCl
override fun onDestroyActionMode(mode: ActionMode?) {
actionMode = null
adapter.clearCheckedItems()
headerMenuBtn.isEnabled = true
}

suspend fun getSelectedIDs() : List<Long>{
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/deniscerri/ytdl/util/UiUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ object UiUtil {
longClickDownloadButton(item)
bottomSheet.cancel()
}
download.setOnLongClickListener {
longClickDownloadButton(item)
bottomSheet.cancel()
true
}
}
DownloadRepository.Status.Scheduled -> {
download!!.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_downloads, 0, 0, 0);
Expand All @@ -642,6 +647,11 @@ object UiUtil {
longClickDownloadButton(item)
bottomSheet.cancel()
}
download?.setOnLongClickListener {
longClickDownloadButton(item)
bottomSheet.cancel()
true
}
}
else -> {
download?.setOnLongClickListener {
Expand Down

0 comments on commit 3c3ef92

Please sign in to comment.