fix bugs.
This commit is contained in:
@@ -13,7 +13,7 @@ import com.xscm.moduleutil.utils.ImageUtils;
|
||||
*/
|
||||
public class LikeUserAdapter<T> extends BaseQuickAdapter<T, BaseViewHolder> {
|
||||
public LikeUserAdapter() {
|
||||
super(R.layout.item_like_user);
|
||||
super(R.layout.item_like_user_2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ public class GsonUtils {
|
||||
GSON = new GsonBuilder()
|
||||
.serializeNulls() // 序列化 null 值
|
||||
.registerTypeAdapterFactory(new BaseModelTypeAdapterFactory())
|
||||
.registerTypeAdapter(String.class,new NullToEmptyStringAdapter())
|
||||
.create();
|
||||
}
|
||||
return GSON;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.xscm.moduleutil.utils
|
||||
|
||||
import com.google.gson.TypeAdapter
|
||||
import com.google.gson.stream.JsonReader
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.google.gson.stream.JsonWriter
|
||||
|
||||
class NullToEmptyStringAdapter : TypeAdapter<String>() {
|
||||
override fun write(out: JsonWriter, value: String?) {
|
||||
out.value(value ?: "")
|
||||
}
|
||||
|
||||
override fun read(`in`: JsonReader): String {
|
||||
return if (`in`.peek() == JsonToken.NULL) {
|
||||
`in`.nextNull()
|
||||
"" // null → 空字符串
|
||||
} else {
|
||||
`in`.nextString() ?: ""
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,9 @@ public class CommentDialogFragment extends BaseMvpDialogFragment<CommentPresente
|
||||
|
||||
@Override
|
||||
public void getCommentList(List<CircleListBean.LikeList> likeLists) {
|
||||
if (likeLists == null){
|
||||
return;
|
||||
}
|
||||
mBinding.tvNum.setText("已有"+likeLists.size()+"人点赞");
|
||||
likeListAdapter.setNewData(likeLists);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user