fix: 修复 Bugs
This commit is contained in:
parent
f30498e83a
commit
12612f1956
|
|
@ -92,6 +92,9 @@ class ThreadMainPostAdapter(
|
|||
}
|
||||
|
||||
private fun showMenu() {
|
||||
if (threadPostBean == null) {
|
||||
return
|
||||
}
|
||||
val userInfoBean: ThreadContentBean.UserInfoBean = user
|
||||
MenuDialogFragment.newInstance(R.menu.menu_thread_item, null)
|
||||
.setOnNavigationItemSelectedListener { item: MenuItem ->
|
||||
|
|
|
|||
|
|
@ -35,13 +35,9 @@ import com.huanchengfly.tieba.post.utils.ThemeUtil
|
|||
import com.huanchengfly.tieba.post.utils.TiebaUtil
|
||||
import com.huanchengfly.tieba.post.utils.Util
|
||||
import com.huanchengfly.tieba.post.utils.anim.animSet
|
||||
import com.huanchengfly.tieba.post.widgets.ShadowLayout
|
||||
import com.huanchengfly.tieba.post.widgets.VideoPlayerStandard
|
||||
import com.scwang.smart.refresh.header.MaterialHeader
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import retrofit2.Call
|
||||
import retrofit2.Callback
|
||||
import retrofit2.Response
|
||||
|
||||
class PersonalizedFeedFragment : BaseFragment(), PersonalizedFeedAdapter.OnRefreshListener,
|
||||
Refreshable, Toolbar.OnMenuItemClickListener {
|
||||
|
|
@ -68,7 +64,7 @@ class PersonalizedFeedFragment : BaseFragment(), PersonalizedFeedAdapter.OnRefre
|
|||
lateinit var recyclerView: RecyclerView
|
||||
|
||||
@BindView(R.id.refresh_tip)
|
||||
lateinit var refreshTip: ShadowLayout
|
||||
lateinit var refreshTip: View
|
||||
|
||||
@BindView(R.id.refresh_tip_text)
|
||||
lateinit var refreshTipText: TextView
|
||||
|
|
@ -226,27 +222,19 @@ class PersonalizedFeedFragment : BaseFragment(), PersonalizedFeedAdapter.OnRefre
|
|||
}
|
||||
|
||||
private fun loadMore() {
|
||||
TiebaApi.getInstance().personalized(2, page + 1)
|
||||
.enqueue(object : Callback<PersonalizedBean> {
|
||||
override fun onFailure(call: Call<PersonalizedBean>, t: Throwable) {
|
||||
refreshLayout.finishLoadMore(false)
|
||||
}
|
||||
|
||||
override fun onResponse(
|
||||
call: Call<PersonalizedBean>,
|
||||
response: Response<PersonalizedBean>
|
||||
) {
|
||||
val personalizedBean = response.body()!!
|
||||
this@PersonalizedFeedFragment.personalizedBean = personalizedBean
|
||||
personalizedBean.threadList?.forEachIndexed { index, threadBean ->
|
||||
launchIO {
|
||||
TiebaApi.getInstance().personalizedAsync(2, page + 1)
|
||||
.doIfSuccess {
|
||||
this@PersonalizedFeedFragment.personalizedBean = it
|
||||
it.threadList?.forEachIndexed { index, threadBean ->
|
||||
threadBean.threadPersonalizedBean =
|
||||
personalizedBean.threadPersonalized?.get(index)
|
||||
it.threadPersonalized?.get(index)
|
||||
}
|
||||
val newThreadBeans: List<PersonalizedBean.ThreadBean> =
|
||||
personalizedBean.threadList?.filterNot {
|
||||
(it.abstractBeans?.size!! > 0 && BlockUtil.needBlock(it.abstractBeans[0].text)) || BlockUtil.needBlock(
|
||||
it.author?.nameShow,
|
||||
it.author?.id
|
||||
it.threadList?.filterNot { threadBean ->
|
||||
(threadBean.abstractBeans?.size!! > 0 && BlockUtil.needBlock(threadBean.abstractBeans[0].text)) || BlockUtil.needBlock(
|
||||
threadBean.author?.nameShow,
|
||||
threadBean.author?.id
|
||||
)
|
||||
}!!
|
||||
adapter.apply {
|
||||
|
|
@ -255,7 +243,10 @@ class PersonalizedFeedFragment : BaseFragment(), PersonalizedFeedAdapter.OnRefre
|
|||
page += 1
|
||||
refreshLayout.finishLoadMore(true)
|
||||
}
|
||||
})
|
||||
.doIfFailure {
|
||||
refreshLayout.finishLoadMore(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFragmentVisibleChange(isVisible: Boolean) {
|
||||
|
|
|
|||
|
|
@ -185,7 +185,11 @@ class SearchThreadFragment : BaseFragment(), ISearchFragment, NewSearchActivity.
|
|||
call: Call<SearchThreadBean>,
|
||||
response: Response<SearchThreadBean>
|
||||
) {
|
||||
val searchThreadBean = response.body()!!
|
||||
val searchThreadBean = response.body()
|
||||
if (searchThreadBean == null) {
|
||||
refreshLayout?.finishLoadMore(false)
|
||||
return
|
||||
}
|
||||
mData = searchThreadBean.data
|
||||
mData!!.postList?.let {
|
||||
searchThreadAdapter!!.insert(it)
|
||||
|
|
|
|||
|
|
@ -73,20 +73,11 @@
|
|||
android:layout_marginBottom="@dimen/card_margin" />
|
||||
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.ShadowLayout
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintRelativeLayout
|
||||
android:id="@+id/refresh_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:visibility="gone"
|
||||
app:shadow_layout_blur="8dp"
|
||||
app:shadow_layout_color="?attr/shadow_color"
|
||||
app:shadow_layout_offsetY="4dp"
|
||||
app:shadow_layout_radius="8dp"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintRelativeLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_radius_50dp"
|
||||
|
|
@ -94,7 +85,8 @@
|
|||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
app:backgroundTint="@color/default_color_accent"
|
||||
tools:backgroundTint="@color/default_color_accent">
|
||||
tools:backgroundTint="@color/default_color_accent"
|
||||
tools:visibility="visible">
|
||||
|
||||
<com.huanchengfly.tieba.post.widgets.theme.TintTextView
|
||||
android:id="@+id/refresh_tip_text"
|
||||
|
|
@ -105,5 +97,4 @@
|
|||
android:textStyle="bold"
|
||||
tools:text="更新了 12 条动态" />
|
||||
</com.huanchengfly.tieba.post.widgets.theme.TintRelativeLayout>
|
||||
</com.huanchengfly.tieba.post.widgets.ShadowLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
Loading…
Reference in New Issue