added OnCancelListener

This commit is contained in:
X1nto 2020-06-29 23:31:18 +04:00
parent d2ab184165
commit c5b38ef53b
2 changed files with 8 additions and 15 deletions

View File

@ -5,23 +5,14 @@ import android.content.Context
import android.content.Intent
import android.os.IBinder
import android.widget.Toast
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.dezlum.codelabs.getjson.GetJson
import com.downloader.Error
import com.downloader.OnDownloadListener
import com.downloader.OnStartOrResumeListener
import com.downloader.PRDownloader
import com.downloader.*
import com.vanced.manager.R
import com.vanced.manager.core.installer.AppInstaller
import com.vanced.manager.ui.fragments.HomeFragment
import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
import com.vanced.manager.utils.NotificationHelper
import com.vanced.manager.utils.NotificationHelper.cancelNotif
import com.vanced.manager.utils.NotificationHelper.createBasicNotif
import com.vanced.manager.utils.PackageHelper.installApp
import java.lang.Exception
import java.lang.IllegalStateException
import java.lang.RuntimeException
import java.util.concurrent.ExecutionException
class MicrogDownloadService: Service() {
@ -59,6 +50,9 @@ class MicrogDownloadService: Service() {
context = this
)
}
.setOnCancelListener { OnCancelListener {
cancelNotif(channel, this)
} }
.start(object : OnDownloadListener {
override fun onDownloadComplete() {
prefs?.edit()?.putBoolean("isMicrogDownloading", false)?.apply()

View File

@ -9,10 +9,7 @@ import android.widget.Toast
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
import com.dezlum.codelabs.getjson.GetJson
import com.downloader.Error
import com.downloader.OnDownloadListener
import com.downloader.OnStartOrResumeListener
import com.downloader.PRDownloader
import com.downloader.*
import com.vanced.manager.R
import com.vanced.manager.core.installer.RootSplitInstallerService
import com.vanced.manager.core.installer.SplitInstaller
@ -22,7 +19,6 @@ import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
import com.vanced.manager.utils.NotificationHelper.cancelNotif
import com.vanced.manager.utils.NotificationHelper.createBasicNotif
import com.vanced.manager.utils.NotificationHelper.displayDownloadNotif
import java.lang.Exception
import java.util.concurrent.ExecutionException
class VancedDownloadService: Service() {
@ -75,6 +71,9 @@ class VancedDownloadService: Service() {
val mProgress = progress.currentBytes * 100 / progress.totalBytes
displayDownloadNotif(channel, progress = mProgress.toInt(), filename = getFileNameFromUrl(url), downTag = "VancedDownload", context = this)
}
.setOnCancelListener { OnCancelListener {
cancelNotif(channel, this)
} }
.start(object : OnDownloadListener {
override fun onDownloadComplete() {
when (type) {