记录一个bug
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter item


我们先不看返回数据:
{
"code":"200",
"data":{
"current":1,
"hitCount":false,
"optimizeCountSql":true,
"orders":[],
"pages":1,
"records":[
null
],
"searchCount":true,
"size":10,
"total":1
},
"msg":"成功"
}
一个列表 使用的是 BAV BaseQuickAdapter
我们定位到 CollectionSupplyListAdapter的 13行

这他妈 13行是 类定义的开始啊 直接是懵逼 草草
仔细观察日志:

item 但在这个适配器里哪有item啊 找到了convert方法中的参数item
class CollectionSupplyListAdapter constructor(
layoutId: Int,
data: ArrayList<CollectionSupplyListBean.DataDTO.RecordsDTO>
) :
BaseQuickAdapter<CollectionSupplyListBean.DataDTO.RecordsDTO, BaseViewHolder>(layoutId, data),
LoadMoreModule {
override fun convert(holder: BaseViewHolder, item: CollectionSupplyListBean.DataDTO.RecordsDTO) {
holder.setText(R.id.tv_item_supply_list_create_time, item.pubTime)
.setText(R.id.tv_item_supply_list_title, item.supplyTitle)
// .setText(R.id.tv_item_supply_type, if (item.supply_quote_type == "1") item.supply_quote else "面议")
.setText(R.id.tv_item_supply_type, item.supplyQuoteTypeText)
.setText(R.id.tv_item_supply_service_location, item.supplyArea)
.setText(R.id.tv_item_supply_list_status, item.statusText)
var businessType = holder.getView<TextView>(R.id.tv_item_supply_business_type)
item.supplyType?.let {
when (it) {
"1" -> {
businessType.text = "供给类型:法律"
}
"2" -> {
businessType.text = "供给类型:财税"
}
"3" -> {
businessType.text = "供给类型:投融资"
}
"4" -> {
businessType.text = "供给类型:知产综合"
}
}
}
}
}
这个item 也就是条目的数据

我们找到网络请求的地方下上断点

再看返回数据:
{
"code":"200",
"data":{
"current":1,
"hitCount":false,
"optimizeCountSql":true,
"orders":[],
"pages":1,
"records":[
null
],
"searchCount":true,
"size":10,
"total":1
},
"msg":"成功"
}
json 还能这样操作:
"records":[
null
],
后台这样玩,会不会被骂娘呢? 这他妈压根不是 标准json啊,开发这么多年也是头一次遇到 浪费我快1个小时
网友评论