房间公告入口文字居中,去除CancellationException的toast

This commit is contained in:
huangjian
2023-03-31 11:56:55 +08:00
parent ec9c3a9a42
commit e208dc6950
4 changed files with 10 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.nnbc123.core.utils.toast
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
@@ -15,7 +16,11 @@ open class BaseViewModel : ViewModel() {
fun safeLaunch(
needLoading: Boolean = false,
onError: (e: Throwable) -> Unit = { it.message.toast() },
onError: (e: Throwable) -> Unit = {
if (it !is CancellationException) {
it.message.toast()
}
},
onComplete: (() -> Unit)? = null,
block: suspend CoroutineScope.() -> Unit
) {

View File

@@ -87,7 +87,7 @@ class CpViewModel : BaseViewModel() {
fun getCpRelation(uid: Long) {
safeLaunch(
true,
false,
block = {
CpModel.userCpRelation(uid)?.let {
_cpRelation.value = it

View File

@@ -41,8 +41,7 @@
android:layout_marginStart="15dp"
android:background="@drawable/shape_white_alpha_10_radius_100"
android:drawableStart="@drawable/ic_notice_board"
android:drawablePadding="3dp"
android:gravity="center_vertical"
android:gravity="center"
android:includeFontPadding="false"
android:onClick="@{click}"
android:paddingStart="6dp"

View File

@@ -25,5 +25,5 @@ only_arm64=false
channel_file=channel.txt
version_name=1.0.1
version_code=101
version_name=1.1.0
version_code=110