浏览代码

Fixed crashes resources not found of icon

Khubaib 3 月之前
父节点
当前提交
b9848ec4ff

+ 11 - 0
.idea/other.xml

@@ -29,6 +29,17 @@
           <option name="screenY" value="2160" />
         </PersistentDeviceSelectionData>
         <PersistentDeviceSelectionData>
+          <option name="api" value="34" />
+          <option name="brand" value="Lenovo" />
+          <option name="codename" value="TB370FU" />
+          <option name="id" value="TB370FU" />
+          <option name="manufacturer" value="Lenovo" />
+          <option name="name" value="Tab P12" />
+          <option name="screenDensity" value="340" />
+          <option name="screenX" value="1840" />
+          <option name="screenY" value="2944" />
+        </PersistentDeviceSelectionData>
+        <PersistentDeviceSelectionData>
           <option name="api" value="31" />
           <option name="brand" value="samsung" />
           <option name="codename" value="a51" />

+ 44 - 36
app/src/main/java/com/vpn/fastestvpnservice/customItems/ServerItem.kt

@@ -516,21 +516,24 @@ fun ServerSearchItem(
             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 = 15.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
-                    )
-                    .align(Alignment.CenterStart)
-            )
+            if (icon != 0) {
+                Icon(
+                    painter = painterResource(id = icon),
+                    contentDescription = "Server Logo",
+                    tint = Color.Unspecified,
+                    modifier = Modifier
+                        .padding(bottom = 15.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
+                        )
+                        .align(Alignment.CenterStart)
+                )
+            }
+
             Surface(
                 modifier = Modifier
                     .padding(start = 40.dp, bottom = 15.dp, end = 110.dp)
@@ -648,27 +651,32 @@ fun ServerSpecificItem(
             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
-                    )
-            )
-            Text(text = server.server_name!!,
-                color = MaterialTheme.colorScheme.primary,
-                style = MaterialTheme.typography.labelMedium,
-                modifier = Modifier
-                    .padding(start = 16.dp, bottom = 18.dp)
-                    .align(Alignment.CenterVertically)
-            )
+            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
+                        )
+                )
+            }
+
+            server.server_name?.let {
+                Text(text = it,
+                    color = MaterialTheme.colorScheme.primary,
+                    style = MaterialTheme.typography.labelMedium,
+                    modifier = Modifier
+                        .padding(start = 16.dp, bottom = 18.dp)
+                        .align(Alignment.CenterVertically)
+                )
+            }
         }
 
         Surface(

+ 51 - 42
app/src/main/java/com/vpn/fastestvpnservice/customItems/ServerItemTV.kt

@@ -155,20 +155,23 @@ fun ServerItemTV(
                 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(top = 20.dp)
-                        .size(44.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(top = 20.dp)
+                            .size(44.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,
@@ -285,20 +288,24 @@ fun SearchServerItemTV(
         ) {
             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!!,
                 color = MaterialTheme.colorScheme.primary,
                 style = MaterialTheme.typography.labelMedium,
@@ -442,20 +449,22 @@ fun FavoriteServerItemTV(
             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!!,
                 color = MaterialTheme.colorScheme.primary,