Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
os
App Lounge
Commits
a34f8210
Commit
a34f8210
authored
Feb 02, 2019
by
Nihar Thakkar
Browse files
Check download status when download is complete
parent
a04771b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/foundation/e/apps/application/model/Downloader.kt
View file @
a34f8210
...
...
@@ -121,7 +121,26 @@ class Downloader(private val applicationInfo: ApplicationInfo, private val fullD
private
var
onComplete
:
BroadcastReceiver
=
object
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
unregisterReceivers
(
context
)
downloaderInterface
.
onDownloadComplete
(
context
,
DownloadManager
.
STATUS_SUCCESSFUL
)
val
status
=
getDownloadStatus
()
if
(
status
!=
null
&&
status
==
DownloadManager
.
STATUS_SUCCESSFUL
)
{
downloaderInterface
.
onDownloadComplete
(
context
,
DownloadManager
.
STATUS_SUCCESSFUL
)
}
else
{
downloaderInterface
.
onDownloadComplete
(
context
,
DownloadManager
.
STATUS_FAILED
)
}
}
}
private
fun
getDownloadStatus
():
Int
?
{
val
query
=
DownloadManager
.
Query
().
apply
{
setFilterById
(
downloadId
)
}
val
cursor
=
downloadManager
.
query
(
query
)
if
(
cursor
.
moveToNext
())
{
val
columnIndex
=
cursor
.
getColumnIndex
(
DownloadManager
.
COLUMN_STATUS
)
val
status
=
cursor
.
getInt
(
columnIndex
)
cursor
.
close
()
return
status
}
return
null
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment