Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Funkwhale Android
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
Funkwhale Android
Commits
5ace27ca
Commit
5ace27ca
authored
2 years ago
by
Ryan Harg
Browse files
Options
Downloads
Plain Diff
Merge branch 'bugfix/117-delete-downloads' into 'develop'
#117
: Use the same contentId when adding and removing downloads Closes
#117
See merge request
!174
parents
b9401d75
c43baae8
No related branches found
No related tags found
1 merge request
!174
#117: Use the same contentId when adding and removing downloads
Pipeline
#21183
passed
2 years ago
Stage: test
Stage: visualize
Stage: build
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/src/main/java/audio/funkwhale/ffa/playback/PinService.kt
+8
-12
8 additions, 12 deletions
app/src/main/java/audio/funkwhale/ffa/playback/PinService.kt
changes/changelog.d/117.bugfix
+1
-0
1 addition, 0 deletions
changes/changelog.d/117.bugfix
with
9 additions
and
12 deletions
app/src/main/java/audio/funkwhale/ffa/playback/PinService.kt
+
8
−
12
View file @
5ace27ca
...
@@ -7,13 +7,7 @@ import androidx.core.net.toUri
...
@@ -7,13 +7,7 @@ import androidx.core.net.toUri
import
audio.funkwhale.ffa.R
import
audio.funkwhale.ffa.R
import
audio.funkwhale.ffa.model.DownloadInfo
import
audio.funkwhale.ffa.model.DownloadInfo
import
audio.funkwhale.ffa.model.Track
import
audio.funkwhale.ffa.model.Track
import
audio.funkwhale.ffa.utils.AppContext
import
audio.funkwhale.ffa.utils.*
import
audio.funkwhale.ffa.utils.Event
import
audio.funkwhale.ffa.utils.EventBus
import
audio.funkwhale.ffa.utils.Request
import
audio.funkwhale.ffa.utils.RequestBus
import
audio.funkwhale.ffa.utils.Response
import
audio.funkwhale.ffa.utils.mustNormalizeUrl
import
com.google.android.exoplayer2.offline.Download
import
com.google.android.exoplayer2.offline.Download
import
com.google.android.exoplayer2.offline.DownloadManager
import
com.google.android.exoplayer2.offline.DownloadManager
import
com.google.android.exoplayer2.offline.DownloadRequest
import
com.google.android.exoplayer2.offline.DownloadRequest
...
@@ -24,10 +18,9 @@ import com.google.gson.Gson
...
@@ -24,10 +18,9 @@ import com.google.gson.Gson
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers.Main
import
kotlinx.coroutines.Dispatchers.Main
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.flow.collect
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.launch
import
org.koin.java.KoinJavaComponent
import
org.koin.java.KoinJavaComponent
import
java.util.
Collections
import
java.util.
*
class
PinService
:
DownloadService
(
AppContext
.
NOTIFICATION_DOWNLOADS
)
{
class
PinService
:
DownloadService
(
AppContext
.
NOTIFICATION_DOWNLOADS
)
{
...
@@ -35,6 +28,7 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
...
@@ -35,6 +28,7 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
private
val
exoDownloadManager
:
DownloadManager
by
KoinJavaComponent
.
inject
(
DownloadManager
::
class
.
java
)
private
val
exoDownloadManager
:
DownloadManager
by
KoinJavaComponent
.
inject
(
DownloadManager
::
class
.
java
)
companion
object
{
companion
object
{
fun
download
(
context
:
Context
,
track
:
Track
)
{
fun
download
(
context
:
Context
,
track
:
Track
)
{
track
.
bestUpload
()
?.
let
{
upload
->
track
.
bestUpload
()
?.
let
{
upload
->
val
url
=
mustNormalizeUrl
(
upload
.
listen_url
)
val
url
=
mustNormalizeUrl
(
upload
.
listen_url
)
...
@@ -48,7 +42,7 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
...
@@ -48,7 +42,7 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
)
)
).
toByteArray
()
).
toByteArray
()
val
request
=
DownloadRequest
.
Builder
(
track
.
id
.
toString
(),
url
.
toUri
())
val
request
=
DownloadRequest
.
Builder
(
url
.
toUri
()
.
toString
(),
url
.
toUri
())
.
setData
(
data
)
.
setData
(
data
)
.
setStreamKeys
(
Collections
.
emptyList
())
.
setStreamKeys
(
Collections
.
emptyList
())
.
build
()
.
build
()
...
@@ -72,8 +66,10 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
...
@@ -72,8 +66,10 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
return
super
.
onStartCommand
(
intent
,
flags
,
startId
)
return
super
.
onStartCommand
(
intent
,
flags
,
startId
)
}
}
override
fun
getDownloadManager
()
=
exoDownloadManager
.
apply
{
override
fun
getDownloadManager
():
DownloadManager
{
addListener
(
DownloadListener
())
return
exoDownloadManager
.
apply
{
addListener
(
DownloadListener
())
}
}
}
override
fun
getScheduler
():
Scheduler
?
=
null
override
fun
getScheduler
():
Scheduler
?
=
null
...
...
This diff is collapsed.
Click to expand it.
changes/changelog.d/117.bugfix
0 → 100644
+
1
−
0
View file @
5ace27ca
Fix the removal of existing downloads
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment