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
efb2d925
Verified
Commit
efb2d925
authored
2 years ago
by
Ryan Harg
Browse files
Options
Downloads
Patches
Plain Diff
#117
: Use the same contentId when adding and removing downloads
parent
b9401d75
No related branches found
No related tags found
1 merge request
!174
#117: Use the same contentId when adding and removing downloads
Pipeline
#21181
canceled
2 years ago
Stage: test
Stage: visualize
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
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
with
8 additions
and
12 deletions
app/src/main/java/audio/funkwhale/ffa/playback/PinService.kt
+
8
−
12
View file @
efb2d925
...
...
@@ -7,13 +7,7 @@ import androidx.core.net.toUri
import
audio.funkwhale.ffa.R
import
audio.funkwhale.ffa.model.DownloadInfo
import
audio.funkwhale.ffa.model.Track
import
audio.funkwhale.ffa.utils.AppContext
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
audio.funkwhale.ffa.utils.*
import
com.google.android.exoplayer2.offline.Download
import
com.google.android.exoplayer2.offline.DownloadManager
import
com.google.android.exoplayer2.offline.DownloadRequest
...
...
@@ -24,10 +18,9 @@ import com.google.gson.Gson
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.Dispatchers.Main
import
kotlinx.coroutines.Job
import
kotlinx.coroutines.flow.collect
import
kotlinx.coroutines.launch
import
org.koin.java.KoinJavaComponent
import
java.util.
Collections
import
java.util.
*
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
)
companion
object
{
fun
download
(
context
:
Context
,
track
:
Track
)
{
track
.
bestUpload
()
?.
let
{
upload
->
val
url
=
mustNormalizeUrl
(
upload
.
listen_url
)
...
...
@@ -48,7 +42,7 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
)
).
toByteArray
()
val
request
=
DownloadRequest
.
Builder
(
track
.
id
.
toString
(),
url
.
toUri
())
val
request
=
DownloadRequest
.
Builder
(
url
.
toUri
()
.
toString
(),
url
.
toUri
())
.
setData
(
data
)
.
setStreamKeys
(
Collections
.
emptyList
())
.
build
()
...
...
@@ -72,8 +66,10 @@ class PinService : DownloadService(AppContext.NOTIFICATION_DOWNLOADS) {
return
super
.
onStartCommand
(
intent
,
flags
,
startId
)
}
override
fun
getDownloadManager
()
=
exoDownloadManager
.
apply
{
addListener
(
DownloadListener
())
override
fun
getDownloadManager
():
DownloadManager
{
return
exoDownloadManager
.
apply
{
addListener
(
DownloadListener
())
}
}
override
fun
getScheduler
():
Scheduler
?
=
null
...
...
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