diff --git a/app/src/main/java/com/huanchengfly/tieba/api/adapters/UserExactMatchAdapter.java b/app/src/main/java/com/huanchengfly/tieba/api/adapters/UserExactMatchAdapter.java new file mode 100644 index 00000000..99e4518c --- /dev/null +++ b/app/src/main/java/com/huanchengfly/tieba/api/adapters/UserExactMatchAdapter.java @@ -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 { + @Override + public SearchUserBean.UserBean deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { + if (json.isJsonArray()) { + return null; + } + return context.deserialize(json, typeOfT); + } +} diff --git a/app/src/main/java/com/huanchengfly/tieba/api/models/SearchUserBean.java b/app/src/main/java/com/huanchengfly/tieba/api/models/SearchUserBean.java index 95728659..aba0b45c 100644 --- a/app/src/main/java/com/huanchengfly/tieba/api/models/SearchUserBean.java +++ b/app/src/main/java/com/huanchengfly/tieba/api/models/SearchUserBean.java @@ -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 fuzzyMatch; diff --git a/app/src/main/java/com/huanchengfly/tieba/post/fragments/FloorFragment.kt b/app/src/main/java/com/huanchengfly/tieba/post/fragments/FloorFragment.kt index a4671608..329224ea 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/fragments/FloorFragment.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/fragments/FloorFragment.kt @@ -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()