0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-23 19:55:11 +00:00

more tests

This commit is contained in:
X1nto 2020-06-30 13:21:48 +04:00
parent b569ec6bd5
commit 464596e22e
4 changed files with 4 additions and 9 deletions

View file

@ -9,8 +9,7 @@ import com.downloader.PRDownloader
class DownloadBroadcastReceiver: BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
val tag: Int? = intent?.getIntExtra("tag", 0)
PRDownloader.cancel(tag)
Log.d("VMNotification", "Canceled $tag download")
PRDownloader.cancelAll()
Log.d("VMNotification", "Canceled downloads")
}
}

View file

@ -37,7 +37,6 @@ class MicrogDownloadService: Service() {
val dwnldUrl = apkUrl.get("url").asString
val channel = 420
PRDownloader.download(dwnldUrl, filesDir.path, "microg.apk")
.setTag(55)
.build()
.setOnStartOrResumeListener { OnStartOrResumeListener { prefs?.edit()?.putBoolean("isMicrogDownloading", true)?.apply() } }
.setOnProgressListener { progress ->
@ -46,7 +45,6 @@ class MicrogDownloadService: Service() {
channel,
mProgress.toInt(),
getFileNameFromUrl(dwnldUrl),
55,
this
)
}

View file

@ -64,12 +64,11 @@ class VancedDownloadService: Service() {
val channel = 69
PRDownloader
.download(url, cacheDir.path, getFileNameFromUrl(url))
.setTag(66)
.build()
.setOnStartOrResumeListener { OnStartOrResumeListener { prefs?.edit()?.putBoolean("isVancedDownloading", true)?.apply() } }
.setOnProgressListener { progress ->
val mProgress = progress.currentBytes * 100 / progress.totalBytes
displayDownloadNotif(channel, mProgress.toInt(), getFileNameFromUrl(url), 66, this)
displayDownloadNotif(channel, mProgress.toInt(), getFileNameFromUrl(url), this)
}
.setOnCancelListener { OnCancelListener {
cancelNotif(channel, this)

View file

@ -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 =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
Notification.Builder(context, channel.toString()).setChannelId("69420")
@ -32,7 +32,6 @@ object NotificationHelper {
Notification.Builder(context).setPriority(Notification.PRIORITY_HIGH)
val cancelDownload = Intent(context, DownloadBroadcastReceiver::class.java)
cancelDownload.putExtra("tag", tag)
val cancelPendingIntent = PendingIntent.getBroadcast(context, 0, cancelDownload, PendingIntent.FLAG_UPDATE_CURRENT)