Skip to content

Commit

Permalink
chore: 新增或移除选项时根据标题重新排序
Browse files Browse the repository at this point in the history
Signed-off-by: xihan123 <srxqzxs@vip.qq.com>
  • Loading branch information
xihan123 committed Aug 29, 2023
1 parent ed663b6 commit f795dc1
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions app/src/main/kotlin/cn/xihan/qdds/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,17 @@ fun MutableList<OptionEntity.SelectedModel>.updateSelectedListOptionEntity(newCo
plusAssign(newConfig)
}
}
return this
return this.sortedBy { it.title }.toMutableList()
}

/**
* 删除列表选项标题
*/
fun MutableList<OptionEntity.SelectedModel>.deleteSelectedOption(newConfigurations: List<OptionEntity.SelectedModel>): MutableList<OptionEntity.SelectedModel> {
fun MutableList<OptionEntity.SelectedModel>.deleteSelectedOption(newConfigurations: List<OptionEntity.SelectedModel>): List<OptionEntity.SelectedModel> {
this.removeAll {
it.title !in newConfigurations.map { newConfigurationItem -> newConfigurationItem.title }
}
return this
return this.sortedBy { it.title }
}

/**
Expand All @@ -665,7 +665,7 @@ fun MutableList<String>.updateStringListOptionEntity(newConfigurations: List<Str
plusAssign(newConfig)
}
}
return this
return this.sortedBy { it }
}

fun String.loge() {
Expand Down Expand Up @@ -823,15 +823,20 @@ fun Any?.mToString(): String = when (this) {
is Serializable -> this.toJSONString()
is Parcelable -> this.toJSONString()
else -> {
if (this?.javaClass?.name?.contains("Entity") == true || this?.javaClass?.name?.contains("Model") == true || this?.javaClass?.name?.contains(
"Bean"
) == true || this?.javaClass?.name?.contains("Result") == true
) this.toJSONString()
else if (this?.javaClass?.name?.contains("QDHttpResp") == true) {
val list = listOf(
"Entity",
"Model",
"Bean",
"Result",
)

if (list.any { this?.javaClass?.name?.contains(it) == true })
this.toJSONString()
else if (this?.javaClass?.name?.contains("QDHttpResp") == true)
this.getParamList<String>().toString()
} else {
else
this?.toString() ?: "null"
}

}
}

Expand Down

0 comments on commit f795dc1

Please sign in to comment.