fix: 修复搜索用户报错
This commit is contained in:
parent
b2b875b082
commit
d8323ba48b
|
@ -0,0 +1,19 @@
|
|||
package com.huanchengfly.tieba.api.adapters;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.huanchengfly.tieba.api.models.SearchUserBean;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class UserExactMatchAdapter implements JsonDeserializer<SearchUserBean.UserBean> {
|
||||
@Override
|
||||
public SearchUserBean.UserBean deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
if (json.isJsonArray()) {
|
||||
return null;
|
||||
}
|
||||
return context.deserialize(json, typeOfT);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package com.huanchengfly.tieba.api.models;
|
|||
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.huanchengfly.tieba.api.adapters.ExactMatchAdapter;
|
||||
import com.huanchengfly.tieba.api.adapters.UserExactMatchAdapter;
|
||||
import com.huanchengfly.tieba.api.adapters.UserFuzzyMatchAdapter;
|
||||
import com.huanchengfly.tieba.post.models.BaseBean;
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class SearchUserBean extends BaseBean {
|
|||
private int pageNum;
|
||||
@SerializedName("has_more")
|
||||
private int hasMore;
|
||||
@JsonAdapter(ExactMatchAdapter.class)
|
||||
@JsonAdapter(UserExactMatchAdapter.class)
|
||||
private UserBean exactMatch;
|
||||
@JsonAdapter(UserFuzzyMatchAdapter.class)
|
||||
private List<UserBean> fuzzyMatch;
|
||||
|
|
|
@ -116,12 +116,12 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
|||
setLoadingView(R.layout.layout_footer_loading)
|
||||
setLoadEndView(R.layout.layout_footer_loadend)
|
||||
setLoadFailedView(R.layout.layout_footer_load_failed)
|
||||
setOnLoadMoreListener { loadMore(!it) }
|
||||
setOnLoadMoreListener { load(it) }
|
||||
}
|
||||
recyclerView.apply {
|
||||
adapter = recyclerViewAdapter
|
||||
layoutManager = mLayoutManager
|
||||
addItemDecoration(ThreadDivider(attachContext))
|
||||
layoutManager = mLayoutManager
|
||||
adapter = recyclerViewAdapter
|
||||
}
|
||||
if (tid.isNotEmpty() && (pid.isNotEmpty() || !spid.isNullOrEmpty())) {
|
||||
refresh(jump)
|
||||
|
@ -175,8 +175,8 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
|||
})
|
||||
}
|
||||
|
||||
private fun loadMore(loadMore: Boolean) {
|
||||
if (loadMore) {
|
||||
private fun load(reload: Boolean) {
|
||||
if (!reload) {
|
||||
pn += 1
|
||||
}
|
||||
TiebaApi.getInstance()
|
||||
|
|
Loading…
Reference in New Issue