mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-15 23:35:06 +00:00
more tests
This commit is contained in:
parent
b569ec6bd5
commit
464596e22e
4 changed files with 4 additions and 9 deletions
|
@ -9,8 +9,7 @@ import com.downloader.PRDownloader
|
||||||
class DownloadBroadcastReceiver: BroadcastReceiver() {
|
class DownloadBroadcastReceiver: BroadcastReceiver() {
|
||||||
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
val tag: Int? = intent?.getIntExtra("tag", 0)
|
PRDownloader.cancelAll()
|
||||||
PRDownloader.cancel(tag)
|
Log.d("VMNotification", "Canceled downloads")
|
||||||
Log.d("VMNotification", "Canceled $tag download")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -37,7 +37,6 @@ class MicrogDownloadService: Service() {
|
||||||
val dwnldUrl = apkUrl.get("url").asString
|
val dwnldUrl = apkUrl.get("url").asString
|
||||||
val channel = 420
|
val channel = 420
|
||||||
PRDownloader.download(dwnldUrl, filesDir.path, "microg.apk")
|
PRDownloader.download(dwnldUrl, filesDir.path, "microg.apk")
|
||||||
.setTag(55)
|
|
||||||
.build()
|
.build()
|
||||||
.setOnStartOrResumeListener { OnStartOrResumeListener { prefs?.edit()?.putBoolean("isMicrogDownloading", true)?.apply() } }
|
.setOnStartOrResumeListener { OnStartOrResumeListener { prefs?.edit()?.putBoolean("isMicrogDownloading", true)?.apply() } }
|
||||||
.setOnProgressListener { progress ->
|
.setOnProgressListener { progress ->
|
||||||
|
@ -46,7 +45,6 @@ class MicrogDownloadService: Service() {
|
||||||
channel,
|
channel,
|
||||||
mProgress.toInt(),
|
mProgress.toInt(),
|
||||||
getFileNameFromUrl(dwnldUrl),
|
getFileNameFromUrl(dwnldUrl),
|
||||||
55,
|
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,12 +64,11 @@ class VancedDownloadService: Service() {
|
||||||
val channel = 69
|
val channel = 69
|
||||||
PRDownloader
|
PRDownloader
|
||||||
.download(url, cacheDir.path, getFileNameFromUrl(url))
|
.download(url, cacheDir.path, getFileNameFromUrl(url))
|
||||||
.setTag(66)
|
|
||||||
.build()
|
.build()
|
||||||
.setOnStartOrResumeListener { OnStartOrResumeListener { prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply() } }
|
.setOnStartOrResumeListener { OnStartOrResumeListener { prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply() } }
|
||||||
.setOnProgressListener { progress ->
|
.setOnProgressListener { progress ->
|
||||||
val mProgress = progress.currentBytes * 100 / progress.totalBytes
|
val mProgress = progress.currentBytes * 100 / progress.totalBytes
|
||||||
displayDownloadNotif(channel, mProgress.toInt(), getFileNameFromUrl(url), 66, this)
|
displayDownloadNotif(channel, mProgress.toInt(), getFileNameFromUrl(url), this)
|
||||||
}
|
}
|
||||||
.setOnCancelListener { OnCancelListener {
|
.setOnCancelListener { OnCancelListener {
|
||||||
cancelNotif(channel, this)
|
cancelNotif(channel, this)
|
||||||
|
|
|
@ -24,7 +24,7 @@ object NotificationHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun displayDownloadNotif(channel: Int, progress:Int, filename: String, tag: Int, context: Context) {
|
fun displayDownloadNotif(channel: Int, progress:Int, filename: String, context: Context) {
|
||||||
val notifBuilder =
|
val notifBuilder =
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
|
||||||
Notification.Builder(context, channel.toString()).setChannelId("69420")
|
Notification.Builder(context, channel.toString()).setChannelId("69420")
|
||||||
|
@ -32,7 +32,6 @@ object NotificationHelper {
|
||||||
Notification.Builder(context).setPriority(Notification.PRIORITY_HIGH)
|
Notification.Builder(context).setPriority(Notification.PRIORITY_HIGH)
|
||||||
|
|
||||||
val cancelDownload = Intent(context, DownloadBroadcastReceiver::class.java)
|
val cancelDownload = Intent(context, DownloadBroadcastReceiver::class.java)
|
||||||
cancelDownload.putExtra("tag", tag)
|
|
||||||
|
|
||||||
val cancelPendingIntent = PendingIntent.getBroadcast(context, 0, cancelDownload, PendingIntent.FLAG_UPDATE_CURRENT)
|
val cancelPendingIntent = PendingIntent.getBroadcast(context, 0, cancelDownload, PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue