fix: 尝试修复楼中楼无法加载更多
This commit is contained in:
parent
9256016baa
commit
ad01280ff7
|
@ -162,49 +162,52 @@ class FloorActivity : BaseActivity() {
|
|||
|
||||
private fun refresh() {
|
||||
refreshLayout.isRefreshing = true
|
||||
TiebaApi.getInstance().floor(tid!!, pn, pid, spid).enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
Toast.makeText(this@FloorActivity, t.message, Toast.LENGTH_SHORT).show()
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
refreshLayout.isRefreshing = false
|
||||
}
|
||||
TiebaApi.getInstance()
|
||||
.floor(tid!!, pn, pid, spid)
|
||||
.enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
Toast.makeText(this@FloorActivity, t.message, Toast.LENGTH_SHORT).show()
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
refreshLayout.isRefreshing = false
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body() ?: return
|
||||
pid = subFloorListBean.post!!.id
|
||||
spid = null
|
||||
if (Integer.valueOf(subFloorListBean.page!!.currentPage) >= Integer.valueOf(subFloorListBean.page.totalPage)) {
|
||||
hasMore = false
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
}
|
||||
toolbar.title = getString(R.string.title_floor_loaded, subFloorListBean.post.floor)
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.setData(subFloorListBean)
|
||||
refreshLayout.isRefreshing = false
|
||||
}
|
||||
})
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body() ?: return
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.setData(subFloorListBean)
|
||||
pid = subFloorListBean.post!!.id
|
||||
spid = null
|
||||
hasMore = subFloorListBean.page!!.currentPage.toInt() < subFloorListBean.page.totalPage.toInt()
|
||||
if (!hasMore) {
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
}
|
||||
toolbar.title = getString(R.string.title_floor_loaded, subFloorListBean.post.floor)
|
||||
refreshLayout.isRefreshing = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadMore() {
|
||||
if (hasMore) {
|
||||
TiebaApi.getInstance().floor(tid!!, pn, pid, spid).enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body()!!
|
||||
pid = subFloorListBean.post!!.id
|
||||
spid = null
|
||||
if (Integer.valueOf(subFloorListBean.page!!.currentPage) >= Integer.valueOf(subFloorListBean.page.totalPage)) {
|
||||
hasMore = false
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
if (!hasMore) return
|
||||
TiebaApi.getInstance()
|
||||
.floor(tid!!, pn, pid, spid)
|
||||
.enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
}
|
||||
pn += 1
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.addData(subFloorListBean)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body() ?: return
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.addData(subFloorListBean)
|
||||
pid = subFloorListBean.post!!.id
|
||||
spid = null
|
||||
hasMore = subFloorListBean.page!!.currentPage.toInt() < subFloorListBean.page.totalPage.toInt()
|
||||
if (!hasMore) {
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
}
|
||||
pn += 1
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -92,19 +92,16 @@ public class RecyclerFloorAdapter extends CommonBaseAdapter<SubFloorListBean.Pos
|
|||
defaultRequestOptions = new RequestOptions()
|
||||
.placeholder(R.drawable.bg_placeholder)
|
||||
.skipMemoryCache(true);
|
||||
openAutoLoadMore();
|
||||
}
|
||||
|
||||
public void setData(SubFloorListBean data) {
|
||||
dataBean = data;
|
||||
data.getSubPostList().add(0, data.getPost());
|
||||
openAutoLoadMore();
|
||||
setNewData(data.getSubPostList());
|
||||
}
|
||||
|
||||
public void addData(SubFloorListBean data) {
|
||||
dataBean = data;
|
||||
openAutoLoadMore();
|
||||
setLoadMoreData(data.getSubPostList());
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context
|
|||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
|
@ -115,7 +114,6 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
|||
appBarLayout.setBackgroundResource(R.drawable.bg_toolbar)
|
||||
mLayoutManager = MyLinearLayoutManager(attachContext)
|
||||
recyclerViewAdapter = RecyclerFloorAdapter(attachContext).apply {
|
||||
openAutoLoadMore()
|
||||
setLoadingView(R.layout.layout_footer_loading)
|
||||
setLoadEndView(R.layout.layout_footer_loadend)
|
||||
setLoadFailedView(R.layout.layout_footer_load_failed)
|
||||
|
@ -126,7 +124,7 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
|||
layoutManager = mLayoutManager
|
||||
addItemDecoration(ThreadDivider(attachContext))
|
||||
}
|
||||
if (!TextUtils.isEmpty(tid) && !TextUtils.isEmpty(pid)) {
|
||||
if (tid.isNotEmpty() && (pid.isNotEmpty() || !spid.isNullOrEmpty())) {
|
||||
refresh(jump)
|
||||
}
|
||||
}
|
||||
|
@ -155,53 +153,53 @@ class FloorFragment : BaseBottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
private fun refresh(jump: Boolean = false) {
|
||||
TiebaApi.getInstance().floor(tid, pn, pid, spid).enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
Toast.makeText(attachContext, t.message, Toast.LENGTH_SHORT).show()
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
}
|
||||
TiebaApi.getInstance()
|
||||
.floor(tid, pn, pid, spid)
|
||||
.enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
Toast.makeText(attachContext, t.message, Toast.LENGTH_SHORT).show()
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body()!!
|
||||
if (Integer.valueOf(subFloorListBean.page!!.currentPage) >= Integer.valueOf(subFloorListBean.page.totalPage)) {
|
||||
hasMore = false
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
} else {
|
||||
hasMore = true
|
||||
}
|
||||
toolbar.title = attachContext.getString(R.string.title_floor_loaded, subFloorListBean.post!!.floor)
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.setData(subFloorListBean)
|
||||
if (jump) {
|
||||
mLayoutManager!!.scrollToPositionWithOffset(1, 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body() ?: return
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.setData(subFloorListBean)
|
||||
hasMore = subFloorListBean.page!!.currentPage.toInt() < subFloorListBean.page.totalPage.toInt()
|
||||
if (!hasMore) {
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
}
|
||||
toolbar.title = attachContext.getString(R.string.title_floor_loaded, subFloorListBean.post!!.floor)
|
||||
if (jump) {
|
||||
mLayoutManager!!.scrollToPositionWithOffset(1, 0)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadMore(loadMore: Boolean) {
|
||||
if (!hasMore) return
|
||||
if (loadMore) {
|
||||
pn += 1
|
||||
}
|
||||
if (hasMore) {
|
||||
TiebaApi.getInstance().floor(tid, pn, pid, spid).enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
}
|
||||
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body()!!
|
||||
recyclerViewAdapter!!.addData(subFloorListBean)
|
||||
if (Integer.valueOf(subFloorListBean.page!!.currentPage) >= Integer.valueOf(subFloorListBean.page.totalPage)) {
|
||||
hasMore = false
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
} else {
|
||||
hasMore = true
|
||||
TiebaApi.getInstance()
|
||||
.floor(tid, pn, pid, spid)
|
||||
.enqueue(object : Callback<SubFloorListBean> {
|
||||
override fun onFailure(call: Call<SubFloorListBean>, t: Throwable) {
|
||||
recyclerViewAdapter!!.loadFailed()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
override fun onResponse(call: Call<SubFloorListBean>, response: Response<SubFloorListBean>) {
|
||||
val subFloorListBean = response.body() ?: return
|
||||
dataBean = subFloorListBean
|
||||
recyclerViewAdapter!!.addData(subFloorListBean)
|
||||
hasMore = subFloorListBean.page!!.currentPage.toInt() < subFloorListBean.page.totalPage.toInt()
|
||||
if (!hasMore) {
|
||||
recyclerViewAdapter!!.loadEnd()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -54,7 +54,7 @@ class NotifyJobService : JobService() {
|
|||
}
|
||||
|
||||
override fun onResponse(call: Call<MsgBean>, response: Response<MsgBean>) {
|
||||
val msgBean = response.body()!!
|
||||
val msgBean = response.body() ?: return
|
||||
if (notificationManager != null) {
|
||||
var total = 0
|
||||
if ("0" != msgBean.message.replyMe) {
|
||||
|
|
|
@ -121,7 +121,7 @@ class OKSignService : IntentService(TAG) {
|
|||
}
|
||||
|
||||
override fun onResponse(call: Call<SignResultBean>, response: Response<SignResultBean>) {
|
||||
val signResultBean = response.body()!!
|
||||
val signResultBean = response.body() ?: return
|
||||
if (position < signData.size - 1) {
|
||||
position += 1
|
||||
if (signResultBean.userInfo != null) {
|
||||
|
@ -154,7 +154,7 @@ class OKSignService : IntentService(TAG) {
|
|||
}
|
||||
|
||||
override fun onResponse(call: Call<ForumRecommend>, response: Response<ForumRecommend>) {
|
||||
val itemBeanList = response.body()!!.likeForum
|
||||
val itemBeanList = response.body()?.likeForum ?: return
|
||||
for ((_, forumName, _, isSign) in itemBeanList) {
|
||||
if ("1" != isSign) {
|
||||
signData.add(SignDataBean(forumName, data.data.getItbTbs()))
|
||||
|
|
Loading…
Reference in New Issue