fix: 数据异常时闪退
This commit is contained in:
parent
26d85c7577
commit
dd151775d1
|
|
@ -44,7 +44,9 @@ abstract class BaseComposeActivityWithData<DATA> : BaseComposeActivity() {
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
final override fun Content() {
|
final override fun Content() {
|
||||||
Content(data!!)
|
data?.let { data ->
|
||||||
|
Content(data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
|
|
@ -540,14 +540,11 @@ private fun getDescText(
|
||||||
time: Long?,
|
time: Long?,
|
||||||
ipAddress: String?
|
ipAddress: String?
|
||||||
): String {
|
): String {
|
||||||
val texts = mutableListOf<String>()
|
val texts = listOfNotNull(
|
||||||
if (time != null) texts.add(DateTimeUtils.getRelativeTimeString(App.INSTANCE, time))
|
time?.let { DateTimeUtils.getRelativeTimeString(App.INSTANCE, it) },
|
||||||
if (!ipAddress.isNullOrEmpty()) texts.add(
|
ipAddress?.let { App.INSTANCE.getString(R.string.text_ip_location, it) }
|
||||||
App.INSTANCE.getString(
|
|
||||||
R.string.text_ip_location,
|
|
||||||
"$ipAddress"
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
if (texts.isEmpty()) return ""
|
||||||
return texts.joinToString(" ")
|
return texts.joinToString(" ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,16 +187,18 @@ private fun getDescText(
|
||||||
floor: Int,
|
floor: Int,
|
||||||
ipAddress: String?
|
ipAddress: String?
|
||||||
): String {
|
): String {
|
||||||
val texts = mutableListOf<String>()
|
val texts = listOfNotNull(
|
||||||
if (time != null) texts.add(getRelativeTimeString(App.INSTANCE, time))
|
time?.let { getRelativeTimeString(App.INSTANCE, it) },
|
||||||
if (floor > 1) texts.add(App.INSTANCE.getString(R.string.tip_post_floor, floor))
|
if (floor > 1) App.INSTANCE.getString(R.string.tip_post_floor, floor) else null,
|
||||||
if (!ipAddress.isNullOrEmpty()) texts.add(
|
if (ipAddress.isNullOrEmpty()) null else App.INSTANCE.getString(
|
||||||
App.INSTANCE.getString(
|
|
||||||
R.string.text_ip_location,
|
R.string.text_ip_location,
|
||||||
"$ipAddress"
|
ipAddress
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return texts.joinToString(" ")
|
if (texts.isEmpty()) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return texts.joinToString(" · ")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue