From 4b45a2acd63708c29f0cb8c77f21cb9806eaa769 Mon Sep 17 00:00:00 2001 From: X1nto Date: Wed, 12 Aug 2020 17:40:13 +0400 Subject: [PATCH] exception handling for crowdin --- .../main/java/com/vanced/manager/core/App.kt | 18 ++++++++++++------ .../manager/ui/viewmodels/HomeViewModel.kt | 11 ++++------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/vanced/manager/core/App.kt b/app/src/main/java/com/vanced/manager/core/App.kt index d69f5c14..5be5f2c1 100644 --- a/app/src/main/java/com/vanced/manager/core/App.kt +++ b/app/src/main/java/com/vanced/manager/core/App.kt @@ -1,6 +1,7 @@ package com.vanced.manager.core import android.app.Application +import android.util.Log import com.crowdin.platform.Crowdin import com.crowdin.platform.CrowdinConfig import com.crowdin.platform.data.remote.NetworkType @@ -12,11 +13,16 @@ class App: Application() { super.onCreate() PRDownloader.initialize(this) - Crowdin.init(this, - CrowdinConfig.Builder() - .withDistributionHash("36c51aed3180a4f43073d28j4s6") - .withNetworkType(NetworkType.WIFI) - .build()) + try { + Crowdin.init(this, + CrowdinConfig.Builder() + .withDistributionHash("36c51aed3180a4f43073d28j4s6") + .withNetworkType(NetworkType.WIFI) + .build() + ) + } catch (e: Exception) { + Log.d("VMLocalisation", "Failed to initialize Crowdin") + } } /* @@ -26,4 +32,4 @@ class App: Application() { } */ -} \ No newline at end of file +} diff --git a/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt b/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt index 40cb5c3b..64a81c7b 100644 --- a/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt +++ b/app/src/main/java/com/vanced/manager/ui/viewmodels/HomeViewModel.kt @@ -65,13 +65,10 @@ open class HomeViewModel(application: Application): AndroidViewModel(application fun fetchData() { CoroutineScope(Dispatchers.IO).launch { fetching.set(true) - //Crowdin has problems with R, skip fetching - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) - try { - Crowdin.forceUpdate(getApplication()) - } catch (e: Exception) { - Log.d("VMLocalisation", "Error: ", e) - } + try { + Crowdin.forceUpdate(getApplication()) + } catch (e: Exception) { + Log.d("VMLocalisation", "Error: ", e) vancedVersion.set(getJsonString("vanced.json", "version", getApplication())) microgVersion.set(getJsonString("microg.json", "version", getApplication())) microgInstalled.set(isPackageInstalled("com.mgoogle.android.gms", pm))