Pārlūkot izejas kodu

Fixed some crashes of icon, resource not found etc

Khubaib 8 mēneši atpakaļ
vecāks
revīzija
9652e4bf3e

BIN
app/release/fastestvpn_v-3.0_beta.apk


+ 16 - 14
app/src/main/java/com/vpn/fastestvpnservice/customItems/CountryItem.kt

@@ -156,20 +156,22 @@ fun CountryItem(
                 val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
                 else Utils.getDrawableGray(context, server.iso)
 
-                Icon(
-                    painter = painterResource(id = icon),
-                    contentDescription = "Server Logo",
-                    tint = Color.Unspecified,
-                    modifier = Modifier
-                        .padding(bottom = 16.dp)
-                        .size(24.dp)
-                        .clip(CircleShape)
-                        .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
-                        .paint(
-                            painter = painterResource(id = icon),
-                            contentScale = ContentScale.FillBounds
-                        )
-                )
+                if (icon != 0) {
+                    Icon(
+                        painter = painterResource(id = icon),
+                        contentDescription = "Server Logo",
+                        tint = Color.Unspecified,
+                        modifier = Modifier
+                            .padding(bottom = 16.dp)
+                            .size(24.dp)
+                            .clip(CircleShape)
+                            .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
+                            .paint(
+                                painter = painterResource(id = icon),
+                                contentScale = ContentScale.FillBounds
+                            )
+                    )
+                }
                 Text(text = server.country!!,
                     style = MaterialTheme.typography.labelMedium,
                     color = MaterialTheme.colorScheme.primary,

+ 16 - 14
app/src/main/java/com/vpn/fastestvpnservice/customItems/ServerItem.kt

@@ -158,20 +158,22 @@ fun ServerItem(server: Server, navHostController: NavHostController, serverPing:
             val icon = if (server.enable == 1) Utils.getDrawable(context, server.iso)
             else Utils.getDrawableGray(context, server.iso)
 
-            Icon(
-                painter = painterResource(id = icon),
-                contentDescription = "Server Logo",
-                tint = Color.Unspecified,
-                modifier = Modifier
-                    .padding(bottom = 16.dp)
-                    .size(24.dp)
-                    .clip(CircleShape)
-                    .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
-                    .paint(
-                        painter = painterResource(id = icon),
-                        contentScale = ContentScale.FillBounds
-                    )
-            )
+            if (icon != 0) {
+                Icon(
+                    painter = painterResource(id = icon),
+                    contentDescription = "Server Logo",
+                    tint = Color.Unspecified,
+                    modifier = Modifier
+                        .padding(bottom = 16.dp)
+                        .size(24.dp)
+                        .clip(CircleShape)
+                        .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
+                        .paint(
+                            painter = painterResource(id = icon),
+                            contentScale = ContentScale.FillBounds
+                        )
+                )
+            }
             Text(text = "${server.server_name}",
                 style = MaterialTheme.typography.labelMedium,
                 color = MaterialTheme.colorScheme.primary,

+ 4 - 3
app/src/main/java/com/vpn/fastestvpnservice/screens/SplashScreen.kt

@@ -132,10 +132,11 @@ fun Splash(navHostController: NavHostController) {
     LaunchedEffect(key1 = true) {
 //        splashViewModel.serverDataApi()
         delay(delay)
-
         if (isLoggedIn) {
-            serverListViewModelSplash.setRecommendedSmartServers()
-            serverListViewModelSplash.setCountryData()
+            if (::serverListViewModelSplash.isInitialized) {
+                serverListViewModelSplash.setRecommendedSmartServers()
+                serverListViewModelSplash.setCountryData()
+            }
             splashViewModel.serverDataApi()
             navHostController.popBackStack()
             navHostController.navigate(Screen.BottomBarMainScreen.route)