mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-09-05 10:53:24 +00:00
Merge pull request #25 from MNCHL/MNCHL-patch-26
Delete src/android/app/src/main/java/org/yuzu/yuzu_emu/DownloadComple…
This commit is contained in:
commit
2db81e6a2b
|
@ -1,33 +0,0 @@
|
|||
package org.yuzu.yuzu_emu
|
||||
|
||||
import android.app.DownloadManager
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
import java.io.File
|
||||
|
||||
class DownloadCompleteReceiver(
|
||||
private val downloadId: Long,
|
||||
private val onDownloadComplete: (Uri?) -> Unit
|
||||
) : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
if (DownloadManager.ACTION_DOWNLOAD_COMPLETE == intent?.action) {
|
||||
val downloadManager =
|
||||
context?.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager
|
||||
val query = DownloadManager.Query().setFilterById(downloadId)
|
||||
val cursor: Cursor = downloadManager.query(query)
|
||||
|
||||
if (cursor.moveToFirst()) {
|
||||
val columnIndex = cursor.getColumnIndex(DownloadManager.COLUMN_STATUS)
|
||||
if (DownloadManager.STATUS_SUCCESSFUL == cursor.getInt(columnIndex)) {
|
||||
val uri = cursor.getString(cursor.getColumnIndex(DownloadManager.COLUMN_LOCAL_URI))
|
||||
val downloadedFile = File(Uri.parse(uri).path)
|
||||
onDownloadComplete(Uri.fromFile(downloadedFile))
|
||||
}
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue