Skip to content

Commit

Permalink
Fixed removing a bookmark is sometimes not possible #451
Browse files Browse the repository at this point in the history
  • Loading branch information
cemrich committed Sep 11, 2024
1 parent 4835c57 commit 65c0f79
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResultListener
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.coroutineScope
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import com.google.android.material.snackbar.Snackbar
Expand All @@ -33,6 +34,7 @@ import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.transform
import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject
import timber.log.Timber
import kotlin.time.Duration.Companion.milliseconds
Expand Down Expand Up @@ -243,7 +245,7 @@ class MediathekDetailFragment : Fragment() {
}

private fun updateVideoThumbnail() {
viewLifecycleOwner.launchOnCreated {
lifecycle.coroutineScope.launch {

// reload show for up to date file path and then update thumbnail
mediathekRepository
Expand All @@ -268,7 +270,7 @@ class MediathekDetailFragment : Fragment() {
private fun download(downloadQuality: Quality) {
startDownloadJob?.cancel()

startDownloadJob = viewLifecycleOwner.launchOnCreated {
startDownloadJob = lifecycle.coroutineScope.launch {

try {
downloadController.startDownload(persistedMediathekShow!!.id, downloadQuality)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package de.christinecoenen.code.zapp.app.mediathek.ui.helper

import android.view.*
import android.view.Gravity
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.widget.PopupMenu
import android.widget.PopupMenu.OnMenuItemClickListener
import androidx.fragment.app.Fragment
import androidx.fragment.app.setFragmentResultListener
import androidx.lifecycle.coroutineScope
import de.christinecoenen.code.zapp.R
import de.christinecoenen.code.zapp.app.mediathek.ui.dialogs.ConfirmDeleteDownloadDialog
import de.christinecoenen.code.zapp.app.mediathek.ui.dialogs.SelectQualityDialog
import de.christinecoenen.code.zapp.models.shows.MediathekShow
import de.christinecoenen.code.zapp.utils.system.LifecycleOwnerHelper.launchOnCreated
import de.christinecoenen.code.zapp.utils.system.LifecycleOwnerHelper.launchOnResumed
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
import org.koin.androidx.viewmodel.ext.android.viewModel

/**
Expand Down Expand Up @@ -59,38 +64,45 @@ class ShowMenuHelper(
show.shareExternally(fragment.requireContext())
true
}

R.id.menu_add_bookmark -> {
fragment.launchOnResumed {
fragment.lifecycle.coroutineScope.launch {
viewModel.bookmark(show)
}
return true
}

R.id.menu_remove_bookmark -> {
fragment.launchOnResumed {
fragment.lifecycle.coroutineScope.launch {
viewModel.removeBookmark(show)
}
return true
}

R.id.menu_start_download -> {
showSelectQualityDialog()
return true
}

R.id.menu_remove_download -> {
showConfirmDeleteDownloadDialog()
return true
}

R.id.menu_cancel_download -> {
fragment.launchOnResumed {
fragment.lifecycle.coroutineScope.launch {
viewModel.cancelDownload(show)
}
return true
}

R.id.menu_mark_unwatched -> {
fragment.launchOnResumed {
fragment.lifecycle.coroutineScope.launch {
viewModel.markUnwatched(show)
}
return true
}

else -> false
}
}
Expand All @@ -101,7 +113,7 @@ class ShowMenuHelper(
private fun startUpdateMenuJob(menu: Menu) {
updateMenuItemsJob?.cancel()

updateMenuItemsJob = fragment.launchOnResumed {
updateMenuItemsJob = fragment.lifecycle.coroutineScope.launch {
viewModel
.getMenuItemsVisibility(show)
.collectLatest { applyVisibiltyToMenu(menu, it) }
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/raw-en/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# v-next
* Fixed html entities visible in program information titles
* Fixed removing a bookmark is sometimes not possible

# 8.5.2
* Removed duplicate entries when scrolling the mediathek list
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/raw/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# v-next
* Sichtbare HTML-Entities in Programm-Information repariert
* Repariert, dass Lesezeichen manchmal nicht entfernt werden können

# 8.5.2
* Duplikate beim Scrollen in der Mediathek-Liste entfernt
Expand Down

0 comments on commit 65c0f79

Please sign in to comment.