Fix crash on empty status messages (#1402)

main
Ivan Kupalov 5 years ago committed by Konrad Pozniak
parent 4ec0c182f7
commit f5bc6c6fc8
  1. 3
      app/src/main/java/com/keylesspalace/tusky/util/SmartLengthInputFilter.kt

@ -38,7 +38,8 @@ private const val LENGTH_DEFAULT = 500
* @return Whether the message should be trimmed or not. * @return Whether the message should be trimmed or not.
*/ */
fun shouldTrimStatus(message: Spanned): Boolean { fun shouldTrimStatus(message: Spanned): Boolean {
return LENGTH_DEFAULT / message.length > 0.75 // Check for emptiness so that we don't divide by zero
return message.isNotEmpty() && LENGTH_DEFAULT.toFloat() / message.length > 0.75
} }
/** /**

Loading…
Cancel
Save