From 68790d5012b64be6c486c35a9b4b061e02819421 Mon Sep 17 00:00:00 2001 From: X1nto Date: Wed, 1 Jul 2020 20:12:32 +0400 Subject: [PATCH] exception handling test 4 --- .../manager/core/downloader/MicrogDownloadService.kt | 6 ++++++ .../manager/core/downloader/VancedDownloadService.kt | 7 ++++++- .../main/java/com/vanced/manager/utils/InternetTools.kt | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/vanced/manager/core/downloader/MicrogDownloadService.kt b/app/src/main/java/com/vanced/manager/core/downloader/MicrogDownloadService.kt index 3cab738a..b79c14d5 100644 --- a/app/src/main/java/com/vanced/manager/core/downloader/MicrogDownloadService.kt +++ b/app/src/main/java/com/vanced/manager/core/downloader/MicrogDownloadService.kt @@ -17,6 +17,8 @@ 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 java.lang.IllegalStateException +import java.lang.RuntimeException import java.util.concurrent.ExecutionException class MicrogDownloadService: Service() { @@ -37,6 +39,10 @@ class MicrogDownloadService: Service() { "" } catch (e: InterruptedException) { "" + } catch (e: IllegalStateException) { + "" + } catch (e: RuntimeException) { + "" } diff --git a/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloadService.kt b/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloadService.kt index c0c83569..753bdc22 100644 --- a/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloadService.kt +++ b/app/src/main/java/com/vanced/manager/core/downloader/VancedDownloadService.kt @@ -5,7 +5,6 @@ import android.content.Context import android.content.Intent import android.os.Build import android.os.IBinder -import android.widget.Toast import androidx.localbroadcastmanager.content.LocalBroadcastManager import androidx.preference.PreferenceManager import com.dezlum.codelabs.getjson.GetJson @@ -22,6 +21,8 @@ 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.IllegalStateException +import java.lang.RuntimeException import java.util.concurrent.ExecutionException class VancedDownloadService: Service() { @@ -44,6 +45,10 @@ class VancedDownloadService: Service() { "" } catch (e: InterruptedException) { "" + } catch (e: IllegalStateException) { + "" + } catch (e: RuntimeException) { + "" } val prefs = getSharedPreferences("installPrefs", Context.MODE_PRIVATE) diff --git a/app/src/main/java/com/vanced/manager/utils/InternetTools.kt b/app/src/main/java/com/vanced/manager/utils/InternetTools.kt index 0c2728cf..124bc443 100644 --- a/app/src/main/java/com/vanced/manager/utils/InternetTools.kt +++ b/app/src/main/java/com/vanced/manager/utils/InternetTools.kt @@ -10,6 +10,7 @@ import com.vanced.manager.BuildConfig import com.vanced.manager.R import java.lang.Exception import java.lang.IllegalStateException +import java.lang.RuntimeException import java.util.concurrent.ExecutionException object InternetTools { @@ -31,6 +32,10 @@ object InternetTools { context.getString(R.string.unavailable) } catch (e: InterruptedException) { context.getString(R.string.unavailable) + } catch (e: IllegalStateException) { + context.getString(R.string.unavailable) + } catch (e: RuntimeException) { + context.getString(R.string.unavailable) } } @@ -42,6 +47,10 @@ object InternetTools { 0 } catch (e: InterruptedException) { 0 + } catch (e: IllegalStateException) { + 0 + } catch (e: RuntimeException) { + 0 } }