Explorar o código

fix: EmojiRainView Crash

pengwuliang hai 10 meses
pai
achega
02dbecba76

+ 5 - 1
module/message/src/main/java/com/adealink/weparty/message/conversation/view/EmojiRainView.kt

@@ -133,7 +133,11 @@ class EmojiRainView @JvmOverloads constructor(
             val section = random.nextInt(sections)
             val minX = section * sectionWidth
             val maxX = (section + 1) * sectionWidth - emoji.width
-            x = (minX + random.nextInt(maxX - minX + 1)).toFloat()
+            x = if(maxX <= minX) {
+                minX.toFloat()
+            } else {
+                (minX + random.nextInt(maxX - minX + 1)).toFloat()
+            }
             y = -emoji.height.toFloat() - random.nextInt(100)
 
             attempts++