記錄一個bug
java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter item
我們先不看返回數(shù)據(jù):
{
"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行是 類定義的開始啊 直接是懵逼 草草
仔細(xì)觀察日志:
item 但在這個適配器里哪有item啊 找到了convert方法中的參數(shù)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 = "供給類型:知產(chǎn)綜合"
}
}
}
}
}
這個item 也就是條目的數(shù)據(jù)
我們找到網(wǎng)絡(luò)請求的地方下上斷點
再看返回數(shù)據(jù):
{
"code":"200",
"data":{
"current":1,
"hitCount":false,
"optimizeCountSql":true,
"orders":[],
"pages":1,
"records":[
null
],
"searchCount":true,
"size":10,
"total":1
},
"msg":"成功"
}
json 還能這樣操作:
"records":[
null
],
后臺這樣玩招驴,會不會被罵娘呢? 這他媽壓根不是 標(biāo)準(zhǔn)json啊玻淑,開發(fā)這么多年也是頭一次遇到 浪費我快1個小時