chore: Dev 6 发布

This commit is contained in:
HuanCheng65 2021-12-03 20:37:35 +08:00
parent a4046ea98d
commit 877d1e4aa3
5 changed files with 62 additions and 19 deletions

View File

@ -80,6 +80,21 @@ interface ITiebaApi {
goodClassifyId: String? = null goodClassifyId: String? = null
): Call<ForumPageBean> ): Call<ForumPageBean>
/**
* 吧页面异步
*
* @param forumName 吧名
* @param page 分页页码 1 开始
* @param sortType 排序类型 [com.huanchengfly.tieba.api.ForumSortType]
* @param goodClassifyId 精品贴分类 ID
*/
fun forumPageAsync(
forumName: String,
page: Int = 1,
sortType: ForumSortType = ForumSortType.REPLY_TIME,
goodClassifyId: String? = null
): Deferred<ApiResult<ForumPageBean>>
/** /**
* 楼中楼页面 * 楼中楼页面
* *

View File

@ -50,6 +50,19 @@ object MixedTiebaApiImpl : ITiebaApi {
): Call<ForumPageBean> = ): Call<ForumPageBean> =
RetrofitTiebaApi.MINI_TIEBA_API.forumPage(forumName, page, sortType.value, goodClassifyId) RetrofitTiebaApi.MINI_TIEBA_API.forumPage(forumName, page, sortType.value, goodClassifyId)
override fun forumPageAsync(
forumName: String,
page: Int,
sortType: ForumSortType,
goodClassifyId: String?
): Deferred<ApiResult<ForumPageBean>> =
RetrofitTiebaApi.MINI_TIEBA_API.forumPageAsync(
forumName,
page,
sortType.value,
goodClassifyId
)
override fun floor( override fun floor(
threadId: String, page: Int, postId: String?, subPostId: String? threadId: String, page: Int, postId: String?, subPostId: String?
): Call<SubFloorListBean> = ): Call<SubFloorListBean> =

View File

@ -115,6 +115,23 @@ interface MiniTiebaApi {
@Field("scr_w") scr_w: String = getScreenWidth().toString() @Field("scr_w") scr_w: String = getScreenWidth().toString()
): Call<ForumPageBean> ): Call<ForumPageBean>
@POST("/c/f/frs/page")
@FormUrlEncoded
fun forumPageAsync(
@Field("kw") forumName: String,
@Field("pn") page: Int = 1,
@Field("sort_type") sort_type: Int,
@Field("cid") goodClassifyId: String? = null,
@Field("is_good") is_good: String? = if (TextUtils.isEmpty(goodClassifyId)) null else "1",
@Field("q_type") q_type: String = "2",
@Field("st_type") st_type: String = "tb_forumlist",
@Field("with_group") with_group: String = "0",
@Field("rn") rn: String = "20",
@Field("scr_dip") scr_dip: String = ScreenInfo.DENSITY.toString(),
@Field("scr_h") scr_h: String = getScreenHeight().toString(),
@Field("scr_w") scr_w: String = getScreenWidth().toString()
): Deferred<ApiResult<ForumPageBean>>
@POST("/c/f/pb/floor") @POST("/c/f/pb/floor")
@FormUrlEncoded @FormUrlEncoded
fun floor( fun floor(

View File

@ -18,6 +18,8 @@ import com.huanchengfly.tieba.post.api.ForumSortType
import com.huanchengfly.tieba.post.api.ForumSortType.Companion.valueOf import com.huanchengfly.tieba.post.api.ForumSortType.Companion.valueOf
import com.huanchengfly.tieba.post.api.TiebaApi import com.huanchengfly.tieba.post.api.TiebaApi
import com.huanchengfly.tieba.post.api.models.ForumPageBean import com.huanchengfly.tieba.post.api.models.ForumPageBean
import com.huanchengfly.tieba.post.api.retrofit.doIfFailure
import com.huanchengfly.tieba.post.api.retrofit.doIfSuccess
import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaException import com.huanchengfly.tieba.post.api.retrofit.exception.TiebaException
import com.huanchengfly.tieba.post.components.dividers.ForumDivider import com.huanchengfly.tieba.post.components.dividers.ForumDivider
import com.huanchengfly.tieba.post.interfaces.OnSwitchListener import com.huanchengfly.tieba.post.interfaces.OnSwitchListener
@ -172,25 +174,21 @@ class ForumFragment : BaseFragment(), Refreshable, OnSwitchListener, ScrollTopab
} }
private fun loadMore() { private fun loadMore() {
TiebaApi.getInstance().forumPage(forumName!!, page + 1, sortType, classifyId) launchIO {
.enqueue(object : Callback<ForumPageBean> { TiebaApi.getInstance()
override fun onFailure(call: Call<ForumPageBean>, t: Throwable) { .forumPageAsync(forumName!!, page + 1, sortType, classifyId)
.doIfSuccess {
page += 1
mRefreshLayout.finishLoadMore()
mDataBean = it
pageSize = it.page?.pageSize?.toInt() ?: 0
forumAdapter.addData(it)
mRefreshLayout.setNoMoreData(it.page?.hasMore == "0")
}
.doIfFailure {
mRefreshLayout.finishLoadMore(false) mRefreshLayout.finishLoadMore(false)
} }
}
override fun onResponse(
call: Call<ForumPageBean>,
response: Response<ForumPageBean>
) {
page += 1
val forumPageBean = response.body()!!
mRefreshLayout.finishLoadMore()
mDataBean = forumPageBean
pageSize = forumPageBean.page?.pageSize?.toInt()!!
forumAdapter.addData(forumPageBean)
mRefreshLayout.setNoMoreData(mDataBean!!.page?.hasMore == "0")
}
})
} }
fun refresh() { fun refresh() {

View File

@ -1,5 +1,5 @@
versionCode=38300 versionCode=39006
versionName=4.0.0 versionName=4.0.0
isPerRelease=true isPerRelease=true
preReleaseName=dev preReleaseName=dev
preReleaseVer=5 preReleaseVer=6