From 2b1f7aa08b3c2d1ebcd5e001ceb450edca62a077 Mon Sep 17 00:00:00 2001 From: why Date: Sat, 9 Dec 2023 21:13:01 +0800 Subject: [PATCH] =?UTF-8?q?[Feat]:=20=E5=AA=92=E4=BD=93=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xiaoyv/bangumi/helper/RouteHelper.kt | 3 + .../person/overview/PersonOverviewAdapter.kt | 1 - .../media/detail/overview/OverviewAdapter.kt | 68 ++++--- .../media/detail/overview/OverviewFragment.kt | 171 ++++++------------ .../detail/overview/OverviewViewModel.kt | 98 ++++++++-- .../overview/binder/OverviewBoardBinder.kt | 49 ----- .../binder/OverviewCharacterBinder.kt | 36 ++-- .../overview/binder/OverviewCommentBinder.kt | 23 ++- .../overview/binder/OverviewDetailBinder.kt | 40 ---- .../overview/binder/OverviewEpBinder.kt | 54 +++--- .../overview/binder/OverviewGridBinder.kt | 72 ++++++++ .../overview/binder/OverviewIndexBinder.kt | 80 -------- .../overview/binder/OverviewMakerBinder.kt | 36 ---- .../overview/binder/OverviewPreviewBinder.kt | 4 +- .../overview/binder/OverviewRatingBinder.kt | 33 ++-- .../overview/binder/OverviewRelativeBinder.kt | 14 +- .../overview/binder/OverviewReviewBinder.kt | 51 ------ .../overview/binder/OverviewSaveBinder.kt | 99 +++++----- .../overview/binder/OverviewSummaryBinder.kt | 29 +-- .../overview/binder/OverviewTagBinder.kt | 9 +- app/src/main/res/layout/fragment_overview.xml | 31 ++-- .../main/res/layout/fragment_overview_1.xml | 17 -- .../res/layout/fragment_overview_board.xml | 31 ---- .../layout/fragment_overview_character.xml | 12 +- ...l => fragment_overview_character_item.xml} | 66 ++++--- .../res/layout/fragment_overview_detail.xml | 47 ----- .../main/res/layout/fragment_overview_ep.xml | 10 +- .../res/layout/fragment_overview_index.xml | 32 ---- .../layout/fragment_overview_index_item.xml | 53 ------ .../res/layout/fragment_overview_maker.xml | 30 --- .../res/layout/fragment_overview_preview.xml | 1 + .../res/layout/fragment_overview_relative.xml | 1 + .../res/layout/fragment_overview_review.xml | 31 ---- .../res/layout/fragment_overview_summary.xml | 35 ---- .../layout/fragment_person_cooperate_item.xml | 1 + .../api/parser/entity/MediaDetailEntity.kt | 4 +- .../common/widget/state/AnimeSummaryView.kt | 14 ++ 37 files changed, 484 insertions(+), 902 deletions(-) delete mode 100644 app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewBoardBinder.kt delete mode 100644 app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewDetailBinder.kt create mode 100644 app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewGridBinder.kt delete mode 100644 app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewIndexBinder.kt delete mode 100644 app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewMakerBinder.kt delete mode 100644 app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewReviewBinder.kt delete mode 100644 app/src/main/res/layout/fragment_overview_1.xml delete mode 100644 app/src/main/res/layout/fragment_overview_board.xml rename app/src/main/res/layout/{fragment_overview_avatar_item.xml => fragment_overview_character_item.xml} (54%) delete mode 100644 app/src/main/res/layout/fragment_overview_detail.xml delete mode 100644 app/src/main/res/layout/fragment_overview_index.xml delete mode 100644 app/src/main/res/layout/fragment_overview_index_item.xml delete mode 100644 app/src/main/res/layout/fragment_overview_maker.xml delete mode 100644 app/src/main/res/layout/fragment_overview_review.xml delete mode 100644 app/src/main/res/layout/fragment_overview_summary.xml diff --git a/app/src/main/java/com/xiaoyv/bangumi/helper/RouteHelper.kt b/app/src/main/java/com/xiaoyv/bangumi/helper/RouteHelper.kt index ab63e5ff..e67aecb4 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/helper/RouteHelper.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/helper/RouteHelper.kt @@ -118,6 +118,9 @@ object RouteHelper { fun jumpIndexDetail(id: String) { + } + fun jumpTagDetail(tag: String) { + } fun jumpGroupDetail(groupId: String) { diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/feature/person/overview/PersonOverviewAdapter.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/feature/person/overview/PersonOverviewAdapter.kt index cde50101..ee725bab 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/feature/person/overview/PersonOverviewAdapter.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/feature/person/overview/PersonOverviewAdapter.kt @@ -71,7 +71,6 @@ class PersonOverviewAdapter( const val TYPE_VOICE = 6 const val TYPE_CHARACTER = 7 const val TYPE_OPUS = 8 - const val TYPE_COMMENT = 9 } data class Item( diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewAdapter.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewAdapter.kt index 31fcf456..2269906e 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewAdapter.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewAdapter.kt @@ -1,22 +1,21 @@ package com.xiaoyv.bangumi.ui.media.detail.overview +import androidx.recyclerview.widget.RecyclerView import com.chad.library.adapter.base.BaseMultiItemAdapter import com.chad.library.adapter.base.BaseMultiItemAdapter.OnItemViewTypeListener -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewBoardBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewCharacterBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewCommentBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewDetailBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewEpBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewIndexBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewMakerBinder +import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewGridBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewPreviewBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewRatingBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewRelativeBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewReviewBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewSaveBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewSummaryBinder import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewTagBinder +import com.xiaoyv.common.api.parser.entity.MediaCommentEntity import com.xiaoyv.common.api.parser.entity.MediaDetailEntity +import com.xiaoyv.common.config.bean.SampleAvatar import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener /** @@ -25,24 +24,43 @@ import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener * @author why * @since 11/30/23 */ -class OverviewAdapter(touchedListener: RecyclerItemTouchedListener) : - BaseMultiItemAdapter() { +class OverviewAdapter( + touchedListener: RecyclerItemTouchedListener, + onClickSave: (Item, Int) -> Unit, + onClickEpItem: (MediaDetailEntity.MediaProgress) -> Unit, + onClickCrtItem: (MediaDetailEntity.MediaCharacter) -> Unit, + onClickTagItem: (MediaDetailEntity.MediaTag) -> Unit, + onClickRelatedItem: (MediaDetailEntity.MediaRelative) -> Unit, + onClickCollectorItem: (SampleAvatar) -> Unit, + onClickIndexItem: (SampleAvatar) -> Unit, + onClickCommentItem: (MediaCommentEntity) -> Unit, + onClickCommentUser: (MediaCommentEntity) -> Unit, +) : BaseMultiItemAdapter() { init { - this.addItemType(TYPE_SAVE, OverviewSaveBinder {}) - .addItemType(TYPE_EP, OverviewEpBinder(touchedListener) {}) - .addItemType(TYPE_TAG, OverviewTagBinder {}) - .addItemType(TYPE_SUMMARY, OverviewSummaryBinder()) + val gridPool = RecyclerView.RecycledViewPool() + + this.addItemType(TYPE_SAVE, OverviewSaveBinder(onClickSave)) + .addItemType(TYPE_EP, OverviewEpBinder(touchedListener, onClickEpItem)) + .addItemType(TYPE_TAG, OverviewTagBinder(onClickTagItem)) + .addItemType(TYPE_SUMMARY, OverviewSummaryBinder(true)) .addItemType(TYPE_PREVIEW, OverviewPreviewBinder()) - .addItemType(TYPE_DETAIL, OverviewDetailBinder()) + .addItemType(TYPE_DETAIL, OverviewSummaryBinder(false)) .addItemType(TYPE_RATING, OverviewRatingBinder()) - .addItemType(TYPE_CHARACTER, OverviewCharacterBinder(touchedListener) {}) - .addItemType(TYPE_MAKER, OverviewMakerBinder {}) - .addItemType(TYPE_RELATIVE, OverviewRelativeBinder(touchedListener) {}) - .addItemType(TYPE_INDEX, OverviewIndexBinder(touchedListener) {}) - .addItemType(TYPE_REVIEW, OverviewReviewBinder(touchedListener,{}) {}) - .addItemType(TYPE_BOARD, OverviewBoardBinder(touchedListener) {}) - .addItemType(TYPE_COMMENT, OverviewCommentBinder(touchedListener,{}) {}) + .addItemType(TYPE_CHARACTER, OverviewCharacterBinder(touchedListener, onClickCrtItem)) + .addItemType(TYPE_RELATIVE, OverviewRelativeBinder(touchedListener, onClickRelatedItem)) + .addItemType( + TYPE_COLLECTOR, + OverviewGridBinder(gridPool, touchedListener, onClickCollectorItem) + ) + .addItemType( + TYPE_INDEX, + OverviewGridBinder(gridPool, touchedListener, onClickIndexItem) + ) + .addItemType( + TYPE_COMMENT, + OverviewCommentBinder(touchedListener, onClickCommentItem, onClickCommentUser) + ) .onItemViewType(OnItemViewTypeListener { position, list -> return@OnItemViewTypeListener list[position].type }) @@ -57,16 +75,14 @@ class OverviewAdapter(touchedListener: RecyclerItemTouchedListener) : const val TYPE_DETAIL = 6 const val TYPE_RATING = 7 const val TYPE_CHARACTER = 8 - const val TYPE_MAKER = 9 - const val TYPE_RELATIVE = 10 + const val TYPE_RELATIVE = 9 + const val TYPE_COLLECTOR = 10 const val TYPE_INDEX = 11 - const val TYPE_REVIEW = 12 - const val TYPE_BOARD = 13 - const val TYPE_COMMENT = 14 + const val TYPE_COMMENT = 12 } - data class OverviewItem( - var mediaDetailEntity: MediaDetailEntity, + data class Item( + var entity: Any, var type: Int, var title: String ) diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewFragment.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewFragment.kt index 4c1713eb..07e9c64d 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewFragment.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewFragment.kt @@ -1,38 +1,22 @@ -@file:Suppress("UNCHECKED_CAST") - package com.xiaoyv.bangumi.ui.media.detail.overview import android.os.Bundle import androidx.core.os.bundleOf -import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.lifecycle.LifecycleOwner -import com.chad.library.adapter.base.BaseMultiItemAdapter +import androidx.recyclerview.widget.LinearLayoutManager import com.xiaoyv.bangumi.databinding.FragmentOverviewBinding -import com.xiaoyv.bangumi.databinding.FragmentOverviewSaveBinding import com.xiaoyv.bangumi.helper.RouteHelper import com.xiaoyv.bangumi.ui.media.action.MediaSaveActionDialog import com.xiaoyv.bangumi.ui.media.detail.MediaDetailViewModel -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewBoardBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewCharacterBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewCommentBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewDetailBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewEpBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewIndexBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewPreviewBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewRatingBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewRelativeBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewReviewBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewSaveBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewSummaryBinder -import com.xiaoyv.bangumi.ui.media.detail.overview.binder.OverviewTagBinder import com.xiaoyv.blueprint.base.mvvm.normal.BaseViewModelFragment import com.xiaoyv.blueprint.constant.NavKey +import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.config.annotation.TopicType -import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener import com.xiaoyv.common.helper.UserHelper -import com.xiaoyv.widget.binder.BaseQuickBindingHolder -import com.xiaoyv.widget.kts.useNotNull +import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener +import com.xiaoyv.common.kts.forceCast +import com.xiaoyv.common.widget.scroll.AnimeLinearLayoutManager /** * Class: [OverviewFragment] @@ -42,69 +26,41 @@ import com.xiaoyv.widget.kts.useNotNull */ class OverviewFragment : BaseViewModelFragment() { - private val mediaViewModel by activityViewModels() + private val activityViewModel by activityViewModels() private val touchedListener = RecyclerItemTouchedListener { - mediaViewModel.vpEnableLiveData.value = it + activityViewModel.vpEnableLiveData.value = it } - private var viewHolders: HashMap> = hashMapOf() - - /** - * RecyclerView 多 Type 效果不太好,这里改写直接进入全部渲染 - */ - private val viewBinderTypes: HashMap> by lazy { - hashMapOf>().apply { - put(OverviewAdapter.TYPE_SAVE, OverviewSaveBinder { - if (UserHelper.isLogin) { - MediaSaveActionDialog.show( - childFragmentManager, - viewModel.mediaDetailLiveData.value?.collectState - ) { - viewModel.refreshCollectState(it) - refreshCollectStateView() - } - } else { - RouteHelper.jumpLogin() - } - }) - put(OverviewAdapter.TYPE_EP, OverviewEpBinder(touchedListener) { + private val overviewAdapter by lazy { + OverviewAdapter( + touchedListener = touchedListener, + onClickSave = { item, position -> + showCollectPanel(item, position) + }, + onClickEpItem = { RouteHelper.jumpTopicDetail(it.id, TopicType.TYPE_EP) - }) - put(OverviewAdapter.TYPE_TAG, OverviewTagBinder {}) - put(OverviewAdapter.TYPE_SUMMARY, OverviewSummaryBinder()) - put(OverviewAdapter.TYPE_PREVIEW, OverviewPreviewBinder()) - put(OverviewAdapter.TYPE_DETAIL, OverviewDetailBinder()) - put(OverviewAdapter.TYPE_RATING, OverviewRatingBinder()) - put(OverviewAdapter.TYPE_CHARACTER, OverviewCharacterBinder(touchedListener) { + }, + onClickCrtItem = { RouteHelper.jumpPerson(it.id, true) - }) -// put(OverviewAdapter.TYPE_MAKER, OverviewMakerBinder { -// RouteHelper.jumpPerson(it.id) -// }) - put(OverviewAdapter.TYPE_RELATIVE, OverviewRelativeBinder(touchedListener) { + }, + onClickTagItem = { + RouteHelper.jumpTagDetail(it.tagName) + }, + onClickRelatedItem = { RouteHelper.jumpMediaDetail(it.id) - }) - put(OverviewAdapter.TYPE_INDEX, OverviewIndexBinder(touchedListener) {}) - put(OverviewAdapter.TYPE_REVIEW, OverviewReviewBinder(touchedListener, { - RouteHelper.jumpBlogDetail(it.id) - }, { + }, + onClickCollectorItem = { + RouteHelper.jumpUserDetail(it.id) + }, + onClickIndexItem = { + RouteHelper.jumpIndexDetail(it.id) + }, + onClickCommentItem = {}, + onClickCommentUser = { RouteHelper.jumpUserDetail(it.userId) - })) - put(OverviewAdapter.TYPE_BOARD, OverviewBoardBinder(touchedListener) {}) - put(OverviewAdapter.TYPE_COMMENT, OverviewCommentBinder(touchedListener, { - - }, { - RouteHelper.jumpUserDetail(it.userId) - })) - } - } - - - private val overviewAdapter by lazy { - OverviewAdapter(RecyclerItemTouchedListener { - mediaViewModel.vpEnableLiveData.value = it - }) + } + ) } override fun initArgumentsData(arguments: Bundle) { @@ -113,20 +69,17 @@ class OverviewFragment : BaseViewModelFragment - val holder = listener.onCreate(hostActivity, binding.llContainer, key) - binding.llContainer.addView(holder.itemView) - viewHolders[key] = holder as BaseQuickBindingHolder<*> - } + viewModel.queryMediaInfo() } override fun LifecycleOwner.initViewObserver() { @@ -134,31 +87,18 @@ class OverviewFragment : BaseViewModelFragment - val adapterListener = - viewBinderTypes[overviewItem.type] as? BaseMultiItemAdapter.OnMultiItemAdapterListener> - val bindingHolder = viewHolders[overviewItem.type] - if (bindingHolder != null && adapterListener != null) { - adapterListener.onBind(bindingHolder, index, overviewItem) - } - } - } + overviewAdapter.submitList(it) + binding.stateView.showContent() + } UserHelper.observe(this) { viewModel.queryMediaInfo() @@ -169,18 +109,17 @@ class OverviewFragment : BaseViewModelFragment - useNotNull(viewModel.mediaDetailLiveData.value) { - val newItem = OverviewAdapter.OverviewItem(this, OverviewAdapter.TYPE_SAVE, "收藏") - - adapterListener.onBind(bindingHolder, position, newItem) + + private fun showCollectPanel(item: OverviewAdapter.Item, position: Int) { + if (!UserHelper.isLogin) { + RouteHelper.jumpLogin() + return + } + val forceCast = item.entity.forceCast() + MediaSaveActionDialog.show(childFragmentManager, forceCast.collectState) { + val entity = viewModel.refreshCollectState(it) ?: return@show + item.entity = entity + overviewAdapter[position] = item } } diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewViewModel.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewViewModel.kt index 2282dff0..e45b5ef5 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewViewModel.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/OverviewViewModel.kt @@ -8,6 +8,8 @@ import com.xiaoyv.common.api.parser.entity.MediaCollectForm import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.api.parser.impl.parserMediaDetail import com.xiaoyv.common.config.annotation.MediaDetailType +import com.xiaoyv.common.config.annotation.SampleImageGridClickType +import com.xiaoyv.common.config.bean.SampleAvatar import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -21,14 +23,16 @@ class OverviewViewModel : BaseViewModel() { internal var mediaId: String = "" internal val mediaDetailLiveData = MutableLiveData() - internal val mediaBinderListLiveData = MutableLiveData>() + internal val mediaBinderListLiveData = MutableLiveData>() fun queryMediaInfo() { launchUI( stateView = loadingViewState, error = { - mediaDetailLiveData.value = null it.printStackTrace() + + mediaDetailLiveData.value = null + mediaBinderListLiveData.value = emptyList() }, block = { val (mediaEntity, binderList) = withContext(Dispatchers.IO) { @@ -46,29 +50,83 @@ class OverviewViewModel : BaseViewModel() { ) } - private fun buildBinderList(entity: MediaDetailEntity): List = - listOf( - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_SAVE, "收藏"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_EP, "章节"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_TAG, "标签"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_SUMMARY, "简介"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_PREVIEW, "预览"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_DETAIL, "详情"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_RATING, "评分"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_CHARACTER, "人物"), -// OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_MAKER, "制作人员"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_RELATIVE, "相关的条目"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_INDEX, "推荐的目录"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_REVIEW, "评论"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_BOARD, "讨论板"), - OverviewAdapter.OverviewItem(entity, OverviewAdapter.TYPE_COMMENT, "吐槽") + private fun buildBinderList(entity: MediaDetailEntity): List { + val items = mutableListOf() + + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_SAVE, "收藏")) + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_EP, "章节")) + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_TAG, "标签")) + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_SUMMARY, "简介")) + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_PREVIEW, "预览")) + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_DETAIL, "详情")) + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_RATING, "评分")) + + // 角色介绍 + if (entity.characters.isNotEmpty()) { + items.add( + OverviewAdapter.Item( + entity.characters, + OverviewAdapter.TYPE_CHARACTER, + "角色介绍" + ) + ) + } + + // 相关的媒体条目 + if (entity.relativeMedia.isNotEmpty()) { + items.add( + OverviewAdapter.Item( + entity.relativeMedia, + OverviewAdapter.TYPE_RELATIVE, + "相关的条目" + ) + ) + } + + // 谁在看这部动画 + if (entity.whoSee.isNotEmpty()) items.add( + OverviewAdapter.Item( + entity.whoSee.map { + SampleAvatar( + id = it.id, + image = it.avatar, + title = it.name, + desc = it.time, + type = SampleImageGridClickType.TYPE_USER + ) + }, + OverviewAdapter.TYPE_COLLECTOR, "谁在看这部动画" + ) + ) + + // 推荐本条目的目录 + if (entity.recommendIndex.isNotEmpty()) items.add( + OverviewAdapter.Item( + entity.recommendIndex.map { + SampleAvatar( + id = it.id, + image = it.userAvatar, + title = it.title, + desc = it.userName, + type = SampleImageGridClickType.TYPE_INDEX + ) + }, OverviewAdapter.TYPE_INDEX, "推荐本条目的目录" + ) ) + // 吐槽 + if (entity.comments.isNotEmpty()) { + items.add(OverviewAdapter.Item(entity, OverviewAdapter.TYPE_COMMENT, "吐槽")) + } + + return items + } + /** * 刷新收藏模型 */ - fun refreshCollectState(it: MediaCollectForm) { + fun refreshCollectState(it: MediaCollectForm): MediaDetailEntity? { mediaDetailLiveData.value?.collectState = it - mediaDetailLiveData.value = mediaDetailLiveData.value + return mediaDetailLiveData.value } } \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewBoardBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewBoardBinder.kt deleted file mode 100644 index 538c5551..00000000 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewBoardBinder.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.xiaoyv.bangumi.ui.media.detail.overview.binder - -import android.content.Context -import android.view.ViewGroup -import com.chad.library.adapter.base.BaseMultiItemAdapter -import com.xiaoyv.bangumi.R -import com.xiaoyv.bangumi.databinding.FragmentOverviewBoardBinding -import com.xiaoyv.bangumi.ui.media.detail.board.MediaBoardAdapter -import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter -import com.xiaoyv.common.api.parser.entity.MediaBoardEntity -import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener -import com.xiaoyv.common.kts.inflater -import com.xiaoyv.common.kts.setOnDebouncedChildClickListener -import com.xiaoyv.widget.binder.BaseQuickBindingHolder - -/** - * Class: [OverviewBoardBinder] - * - * @author why - * @since 11/30/23 - */ -class OverviewBoardBinder( - private val touchedListener: RecyclerItemTouchedListener, - private val clickItemListener: (MediaBoardEntity) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { - - private val itemAdapter by lazy { MediaBoardAdapter() } - - override fun onBind( - holder: BaseQuickBindingHolder, - position: Int, - item: OverviewAdapter.OverviewItem? - ) { - item ?: return - holder.binding.rvBoard.adapter = itemAdapter - holder.binding.rvBoard.addOnItemTouchListener(touchedListener) - holder.binding.rvBoard.setInitialPrefetchItemCount(item.mediaDetailEntity.boards.size) - itemAdapter.submitList(item.mediaDetailEntity.boards) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_board, block = clickItemListener) - } - - override fun onCreate( - context: Context, - parent: ViewGroup, - viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewBoardBinding.inflate(context.inflater, parent, false) - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCharacterBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCharacterBinder.kt index ca3d1c7e..f4a1fb1b 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCharacterBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCharacterBinder.kt @@ -4,18 +4,21 @@ import android.content.Context import android.view.ViewGroup import androidx.core.view.isVisible import androidx.recyclerview.widget.DiffUtil +import com.blankj.utilcode.util.SpanUtils import com.chad.library.adapter.base.BaseMultiItemAdapter import com.xiaoyv.bangumi.R -import com.xiaoyv.bangumi.databinding.FragmentOverviewAvatarItemBinding import com.xiaoyv.bangumi.databinding.FragmentOverviewCharacterBinding +import com.xiaoyv.bangumi.databinding.FragmentOverviewCharacterItemBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.common.kts.loadImageAnimate import com.xiaoyv.common.kts.setOnDebouncedChildClickListener import com.xiaoyv.widget.binder.BaseQuickBindingHolder import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter +import com.xiaoyv.widget.kts.spi /** * Class: [OverviewCharacterBinder] @@ -26,23 +29,24 @@ import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter class OverviewCharacterBinder( private val touchedListener: RecyclerItemTouchedListener, private val clickItemListener: (MediaDetailEntity.MediaCharacter) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { +) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { private val itemAdapter by lazy { - ItemAdapter() + ItemAdapter().apply { + setOnDebouncedChildClickListener(R.id.item_character, block = clickItemListener) + } } override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return holder.binding.rvCharacter.adapter = itemAdapter holder.binding.rvCharacter.addOnItemTouchListener(touchedListener) - holder.binding.rvCharacter.setInitialPrefetchItemCount(item.mediaDetailEntity.characters.size) - itemAdapter.submitList(item.mediaDetailEntity.characters) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_character, block = clickItemListener) + holder.binding.rvCharacter.setInitialPrefetchItemCount(5) + itemAdapter.submitList(item.entity.forceCast()) } override fun onCreate( @@ -54,13 +58,19 @@ class OverviewCharacterBinder( ) private class ItemAdapter : BaseQuickDiffBindingAdapter(DiffItemCallback) { - override fun BaseQuickBindingHolder.converted(item: MediaDetailEntity.MediaCharacter) { + FragmentOverviewCharacterItemBinding>(DiffItemCallback) { + override fun BaseQuickBindingHolder.converted(item: MediaDetailEntity.MediaCharacter) { binding.ivAvatar.loadImageAnimate(item.avatar) - binding.tvName.text = item.characterNameCn.ifBlank { item.characterName } - binding.tvJob.text = item.jobs.joinToString(";") - binding.tvComment.text = String.format("+%d", item.saveCount) - binding.tvComment.isVisible = item.saveCount != 0 + binding.tvJobs.text = item.jobs.joinToString(";") + binding.tvTimes.text = String.format("+%d", item.saveCount) + binding.tvTimes.isVisible = item.saveCount != 0 + + SpanUtils.with(binding.tvName) + .append(item.characterNameCn.ifBlank { item.characterName }) + .appendLine() + .append(item.personJob + ":" + item.persons.joinToString("、") { it.personName }) + .setFontSize(12.spi) + .create() } private object DiffItemCallback : diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCommentBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCommentBinder.kt index 44d60ed2..0dcbf293 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCommentBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewCommentBinder.kt @@ -8,7 +8,9 @@ import com.xiaoyv.bangumi.databinding.FragmentOverviewCommentBinding import com.xiaoyv.bangumi.ui.media.detail.comments.MediaCommentAdapter import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter import com.xiaoyv.common.api.parser.entity.MediaCommentEntity +import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.common.kts.setOnDebouncedChildClickListener import com.xiaoyv.widget.binder.BaseQuickBindingHolder @@ -23,21 +25,28 @@ class OverviewCommentBinder( private val touchedListener: RecyclerItemTouchedListener, private val clickItemListener: (MediaCommentEntity) -> Unit, private val clickUserListener: (MediaCommentEntity) -> Unit, -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { - private val itemAdapter by lazy { MediaCommentAdapter() } +) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { + + private val itemAdapter by lazy { + MediaCommentAdapter().apply { + setOnDebouncedChildClickListener(R.id.item_comment, block = clickItemListener) + setOnDebouncedChildClickListener(R.id.iv_avatar, block = clickUserListener) + } + } override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return holder.binding.rvComment.adapter = itemAdapter holder.binding.rvComment.addOnItemTouchListener(touchedListener) - holder.binding.rvComment.setInitialPrefetchItemCount(item.mediaDetailEntity.comments.size) - itemAdapter.submitList(item.mediaDetailEntity.comments) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_comment, block = clickItemListener) - itemAdapter.setOnDebouncedChildClickListener(R.id.iv_avatar, block = clickUserListener) + + item.entity.forceCast().apply { + holder.binding.rvComment.setInitialPrefetchItemCount(comments.size) + itemAdapter.submitList(comments) + } } override fun onCreate( diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewDetailBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewDetailBinder.kt deleted file mode 100644 index 317dfc58..00000000 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewDetailBinder.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.xiaoyv.bangumi.ui.media.detail.overview.binder - -import android.content.Context -import android.view.ViewGroup -import com.chad.library.adapter.base.BaseMultiItemAdapter -import com.xiaoyv.bangumi.databinding.FragmentOverviewDetailBinding -import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter -import com.xiaoyv.common.kts.inflater -import com.xiaoyv.widget.binder.BaseQuickBindingHolder - -/** - * Class: [OverviewDetailBinder] - * - * @author why - * @since 11/30/23 - */ -class OverviewDetailBinder : - BaseMultiItemAdapter.OnMultiItemAdapterListener> { - override fun onBind( - holder: BaseQuickBindingHolder, - position: Int, - item: OverviewAdapter.OverviewItem? - ) { - item ?: return - holder.binding.tvDetailContent.text = null - item.mediaDetailEntity.infos.forEach { - holder.binding.tvDetailContent.append(it) - holder.binding.tvDetailContent.append("\n") - } - holder.binding.tvDetailContent.append("...") - } - - override fun onCreate( - context: Context, - parent: ViewGroup, - viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewDetailBinding.inflate(context.inflater, parent, false) - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewEpBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewEpBinder.kt index 2094d270..aea83b67 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewEpBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewEpBinder.kt @@ -3,20 +3,22 @@ package com.xiaoyv.bangumi.ui.media.detail.overview.binder import android.content.Context import android.content.res.ColorStateList import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil import com.chad.library.adapter.base.BaseMultiItemAdapter import com.xiaoyv.bangumi.R import com.xiaoyv.bangumi.databinding.FragmentOverviewEpBinding import com.xiaoyv.bangumi.databinding.FragmentOverviewEpItemBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter import com.xiaoyv.common.api.parser.entity.MediaDetailEntity +import com.xiaoyv.common.helper.callback.IdDiffItemCallback import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener import com.xiaoyv.common.kts.GoogleAttr +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.common.kts.setOnDebouncedChildClickListener import com.xiaoyv.widget.binder.BaseQuickBindingHolder import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter import com.xiaoyv.widget.kts.getAttrColor +import com.xiaoyv.widget.kts.subListLimit /** * Class: [OverviewEpBinder] @@ -27,35 +29,46 @@ import com.xiaoyv.widget.kts.getAttrColor class OverviewEpBinder( private val touchedListener: RecyclerItemTouchedListener, private val clickItemListener: (MediaDetailEntity.MediaProgress) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { +) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { + + /** + * 最大显示 48 个 + */ + private val subSize = 24 private val itemAdapter by lazy { - ItemAdapter() + ItemAdapter().apply { + setOnDebouncedChildClickListener(R.id.item_ep, block = clickItemListener) + } } override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return holder.binding.tvEpMyProgress.text = String.format("%s/10", 1) - holder.binding.rvEp.adapter = itemAdapter - holder.binding.rvEp.addOnItemTouchListener(touchedListener) - itemAdapter.submitList(item.mediaDetailEntity.progressList) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_ep, block = clickItemListener) + holder.binding.tvTitleEp.title = item.title + itemAdapter.submitList( + item.entity.forceCast().progressList + .subListLimit(subSize) + ) } override fun onCreate( context: Context, parent: ViewGroup, viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewEpBinding.inflate(context.inflater, parent, false) - ) + ): BaseQuickBindingHolder { + val binding = FragmentOverviewEpBinding.inflate(context.inflater, parent, false) + binding.rvEp.adapter = itemAdapter + binding.rvEp.addOnItemTouchListener(touchedListener) + return BaseQuickBindingHolder(binding) + } private class ItemAdapter : BaseQuickDiffBindingAdapter(DiffItemCallback) { + FragmentOverviewEpItemBinding>(IdDiffItemCallback()) { override fun BaseQuickBindingHolder.converted(item: MediaDetailEntity.MediaProgress) { binding.tvEp.text = item.no @@ -75,22 +88,5 @@ class OverviewEpBinder( } } } - - private object DiffItemCallback : - DiffUtil.ItemCallback() { - override fun areItemsTheSame( - oldItem: MediaDetailEntity.MediaProgress, - newItem: MediaDetailEntity.MediaProgress - ): Boolean { - return oldItem.id == newItem.id - } - - override fun areContentsTheSame( - oldItem: MediaDetailEntity.MediaProgress, - newItem: MediaDetailEntity.MediaProgress - ): Boolean { - return oldItem == newItem - } - } } } \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewGridBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewGridBinder.kt new file mode 100644 index 00000000..b7e0aa4c --- /dev/null +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewGridBinder.kt @@ -0,0 +1,72 @@ +package com.xiaoyv.bangumi.ui.media.detail.overview.binder + +import android.content.Context +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.chad.library.adapter.base.BaseMultiItemAdapter +import com.xiaoyv.bangumi.R +import com.xiaoyv.bangumi.databinding.FragmentPersonOverviewGridBinding +import com.xiaoyv.bangumi.databinding.FragmentPersonOverviewGridItemBinding +import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter +import com.xiaoyv.common.config.bean.SampleAvatar +import com.xiaoyv.common.helper.callback.IdDiffItemCallback +import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener +import com.xiaoyv.common.kts.forceCast +import com.xiaoyv.common.kts.inflater +import com.xiaoyv.common.kts.loadImageAnimate +import com.xiaoyv.common.kts.setOnDebouncedChildClickListener +import com.xiaoyv.widget.binder.BaseQuickBindingHolder +import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter + +/** + * Class: [OverviewGridBinder] + * + * @author why + * @since 12/6/23 + */ +class OverviewGridBinder( + private val pool: RecyclerView.RecycledViewPool, + private val touchedListener: RecyclerItemTouchedListener, + private val clickItem: (SampleAvatar) -> Unit +) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { + + private val itemAdapter by lazy { + ItemAdapter().apply { + setOnDebouncedChildClickListener(R.id.item_grid, block = clickItem) + } + } + + override fun onBind( + holder: BaseQuickBindingHolder, + position: Int, + item: OverviewAdapter.Item? + ) { + item ?: return + holder.binding.tvItemTitle.text = item.title + holder.binding.rvGrid.adapter = itemAdapter + itemAdapter.submitList(item.entity.forceCast()) + } + + override fun onCreate( + context: Context, + parent: ViewGroup, + viewType: Int + ): BaseQuickBindingHolder { + val binding = FragmentPersonOverviewGridBinding.inflate(context.inflater, parent, false) + binding.rvGrid.setRecycledViewPool(pool) + binding.rvGrid.addOnItemTouchListener(touchedListener) + return BaseQuickBindingHolder(binding) + } + + /** + * 横向 Grid + */ + private class ItemAdapter : BaseQuickDiffBindingAdapter(IdDiffItemCallback()) { + override fun BaseQuickBindingHolder.converted(item: SampleAvatar) { + binding.ivAvatar.loadImageAnimate(item.image) + binding.tvName.text = item.title + binding.tvDesc.text = item.desc + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewIndexBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewIndexBinder.kt deleted file mode 100644 index 7318ff60..00000000 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewIndexBinder.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.xiaoyv.bangumi.ui.media.detail.overview.binder - -import android.content.Context -import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil -import com.chad.library.adapter.base.BaseMultiItemAdapter -import com.xiaoyv.bangumi.R -import com.xiaoyv.bangumi.databinding.FragmentOverviewIndexBinding -import com.xiaoyv.bangumi.databinding.FragmentOverviewIndexItemBinding -import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter -import com.xiaoyv.common.api.parser.entity.MediaDetailEntity -import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener -import com.xiaoyv.common.kts.inflater -import com.xiaoyv.common.kts.loadImageAnimate -import com.xiaoyv.common.kts.setOnDebouncedChildClickListener -import com.xiaoyv.widget.binder.BaseQuickBindingHolder -import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter - -/** - * Class: [OverviewIndexBinder] - * - * @author why - * @since 11/30/23 - */ -class OverviewIndexBinder( - private val touchedListener: RecyclerItemTouchedListener, - private val clickItemListener: (MediaDetailEntity.MediaIndex) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { - - private val itemAdapter by lazy { - ItemAdapter() - } - - override fun onBind( - holder: BaseQuickBindingHolder, - position: Int, - item: OverviewAdapter.OverviewItem? - ) { - item ?: return - holder.binding.rvIndex.adapter = itemAdapter - holder.binding.rvIndex.addOnItemTouchListener(touchedListener) - holder.binding.rvIndex.setInitialPrefetchItemCount(item.mediaDetailEntity.recommendIndex.size) - itemAdapter.submitList(item.mediaDetailEntity.recommendIndex) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_index, block = clickItemListener) - } - - override fun onCreate( - context: Context, - parent: ViewGroup, - viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewIndexBinding.inflate(context.inflater, parent, false) - ) - - private class ItemAdapter : BaseQuickDiffBindingAdapter(DiffItemCallback) { - override fun BaseQuickBindingHolder.converted(item: MediaDetailEntity.MediaIndex) { - binding.ivAvatar.loadImageAnimate(item.userAvatar) - binding.tvName.text = item.title - binding.tvJob.text = item.userName - } - - private object DiffItemCallback : - DiffUtil.ItemCallback() { - override fun areItemsTheSame( - oldItem: MediaDetailEntity.MediaIndex, - newItem: MediaDetailEntity.MediaIndex - ): Boolean { - return oldItem.id == newItem.id - } - - override fun areContentsTheSame( - oldItem: MediaDetailEntity.MediaIndex, - newItem: MediaDetailEntity.MediaIndex - ): Boolean { - return oldItem == newItem - } - } - } -} \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewMakerBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewMakerBinder.kt deleted file mode 100644 index ee594856..00000000 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewMakerBinder.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.xiaoyv.bangumi.ui.media.detail.overview.binder - -import android.content.Context -import android.view.ViewGroup -import com.chad.library.adapter.base.BaseMultiItemAdapter -import com.xiaoyv.bangumi.databinding.FragmentOverviewMakerBinding -import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter -import com.xiaoyv.common.api.parser.entity.MediaDetailEntity -import com.xiaoyv.common.kts.inflater -import com.xiaoyv.widget.binder.BaseQuickBindingHolder - -/** - * Class: [OverviewMakerBinder] - * - * @author why - * @since 11/30/23 - */ -class OverviewMakerBinder( - private val clickItemListener: (MediaDetailEntity.MediaCharacter) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { - override fun onBind( - holder: BaseQuickBindingHolder, - position: Int, - item: OverviewAdapter.OverviewItem? - ) { - item ?: return - } - - override fun onCreate( - context: Context, - parent: ViewGroup, - viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewMakerBinding.inflate(context.inflater, parent, false) - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewPreviewBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewPreviewBinder.kt index cce8a18a..5d1b47a4 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewPreviewBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewPreviewBinder.kt @@ -15,11 +15,11 @@ import com.xiaoyv.widget.binder.BaseQuickBindingHolder * @since 11/30/23 */ class OverviewPreviewBinder : - BaseMultiItemAdapter.OnMultiItemAdapterListener> { + BaseMultiItemAdapter.OnMultiItemAdapterListener> { override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { } diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRatingBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRatingBinder.kt index 442a19b2..64886fa9 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRatingBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRatingBinder.kt @@ -5,6 +5,8 @@ import android.view.ViewGroup import com.chad.library.adapter.base.BaseMultiItemAdapter import com.xiaoyv.bangumi.databinding.FragmentOverviewRatingBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter +import com.xiaoyv.common.api.parser.entity.MediaDetailEntity +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.widget.binder.BaseQuickBindingHolder @@ -15,30 +17,25 @@ import com.xiaoyv.widget.binder.BaseQuickBindingHolder * @since 11/30/23 */ class OverviewRatingBinder : - BaseMultiItemAdapter.OnMultiItemAdapterListener> { + BaseMultiItemAdapter.OnMultiItemAdapterListener> { override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return - holder.binding.tvScore.text = - String.format("%.1f", item.mediaDetailEntity.rating.globalRating) - if (item.mediaDetailEntity.rating.globalRank != 0) { - holder.binding.tvScoreTip.text = String.format( - "#%d %s", - item.mediaDetailEntity.rating.globalRank, - item.mediaDetailEntity.rating.description - ) - } else { - holder.binding.tvScoreTip.text = String.format( - "%s", - item.mediaDetailEntity.rating.description - ) - } - holder.binding.tvRatingStandardDeviation.text = - String.format("%.2f", item.mediaDetailEntity.rating.standardDeviation) + item.entity.forceCast().rating.apply { + holder.binding.tvScore.text = String.format("%.1f", globalRating) + if (globalRank != 0) { + holder.binding.tvScoreTip.text = String.format("#%d %s", globalRank, description) + } else { + holder.binding.tvScoreTip.text = String.format("%s", description) + } + + holder.binding.tvRatingStandardDeviation.text = + String.format("%.2f", standardDeviation) + } } override fun onCreate( diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRelativeBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRelativeBinder.kt index 7a34fdf6..12ac849e 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRelativeBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewRelativeBinder.kt @@ -10,6 +10,7 @@ import com.xiaoyv.bangumi.databinding.FragmentOverviewRelativeItemBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.common.kts.loadImageAnimate import com.xiaoyv.common.kts.setOnDebouncedChildClickListener @@ -25,23 +26,24 @@ import com.xiaoyv.widget.binder.BaseQuickDiffBindingAdapter class OverviewRelativeBinder( private val touchedListener: RecyclerItemTouchedListener, private val clickItemListener: (MediaDetailEntity.MediaRelative) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { +) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { private val itemAdapter by lazy { - ItemAdapter() + ItemAdapter().apply { + setOnDebouncedChildClickListener(R.id.item_related, block = clickItemListener) + } } override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return holder.binding.rvRelative.adapter = itemAdapter holder.binding.rvRelative.addOnItemTouchListener(touchedListener) - holder.binding.rvRelative.setInitialPrefetchItemCount(item.mediaDetailEntity.relativeMedia.size) - itemAdapter.submitList(item.mediaDetailEntity.relativeMedia) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_related, block = clickItemListener) + holder.binding.rvRelative.setInitialPrefetchItemCount(5) + itemAdapter.submitList(item.entity.forceCast()) } override fun onCreate( diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewReviewBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewReviewBinder.kt deleted file mode 100644 index 15f36b20..00000000 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewReviewBinder.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.xiaoyv.bangumi.ui.media.detail.overview.binder - -import android.content.Context -import android.view.ViewGroup -import com.chad.library.adapter.base.BaseMultiItemAdapter -import com.xiaoyv.bangumi.R -import com.xiaoyv.bangumi.databinding.FragmentOverviewReviewBinding -import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter -import com.xiaoyv.bangumi.ui.media.detail.review.MediaReviewAdapter -import com.xiaoyv.common.api.parser.entity.MediaReviewEntity -import com.xiaoyv.common.helper.callback.RecyclerItemTouchedListener -import com.xiaoyv.common.kts.inflater -import com.xiaoyv.common.kts.setOnDebouncedChildClickListener -import com.xiaoyv.widget.binder.BaseQuickBindingHolder - -/** - * Class: [OverviewReviewBinder] - * - * @author why - * @since 11/30/23 - */ -class OverviewReviewBinder( - private val touchedListener: RecyclerItemTouchedListener, - private val clickItemListener: (MediaReviewEntity) -> Unit, - private val clickUserListener: (MediaReviewEntity) -> Unit -) : BaseMultiItemAdapter.OnMultiItemAdapterListener> { - - private val itemAdapter by lazy { MediaReviewAdapter() } - - override fun onBind( - holder: BaseQuickBindingHolder, - position: Int, - item: OverviewAdapter.OverviewItem? - ) { - item ?: return - holder.binding.rvReview.adapter = itemAdapter - holder.binding.rvReview.addOnItemTouchListener(touchedListener) - holder.binding.rvReview.setInitialPrefetchItemCount(item.mediaDetailEntity.reviews.size) - itemAdapter.submitList(item.mediaDetailEntity.reviews) - itemAdapter.setOnDebouncedChildClickListener(R.id.item_review, block = clickItemListener) - itemAdapter.setOnDebouncedChildClickListener(R.id.iv_avatar, block = clickUserListener) - } - - override fun onCreate( - context: Context, - parent: ViewGroup, - viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewReviewBinding.inflate(context.inflater, parent, false) - ) -} \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSaveBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSaveBinder.kt index 857eeb17..5168ae0e 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSaveBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSaveBinder.kt @@ -1,18 +1,19 @@ package com.xiaoyv.bangumi.ui.media.detail.overview.binder import android.content.Context -import android.view.View import android.view.ViewGroup import com.blankj.utilcode.util.ColorUtils import com.blankj.utilcode.util.StringUtils import com.chad.library.adapter.base.BaseMultiItemAdapter import com.xiaoyv.bangumi.databinding.FragmentOverviewSaveBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter +import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.config.GlobalConfig import com.xiaoyv.common.config.annotation.InterestType import com.xiaoyv.common.kts.CommonColor import com.xiaoyv.common.kts.CommonString import com.xiaoyv.common.kts.GoogleAttr +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.common.kts.tint import com.xiaoyv.widget.binder.BaseQuickBindingHolder @@ -25,64 +26,68 @@ import com.xiaoyv.widget.kts.getAttrColor * @author why * @since 11/30/23 */ -class OverviewSaveBinder(private var onSaveBtnClickListener: (View) -> Unit) : - BaseMultiItemAdapter.OnMultiItemAdapterListener> { +class OverviewSaveBinder(private var onSaveBtnClickListener: (OverviewAdapter.Item, Int) -> Unit) : + BaseMultiItemAdapter.OnMultiItemAdapterListener> { override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return + item.entity.forceCast().apply { + holder.binding.tvSaveSummary.text = StringUtils.getString( + CommonString.media_save_summary, + countWish, + countCollect, + countDoing, + countOnHold, + countDropped + ) - holder.binding.tvSaveSummary.text = StringUtils.getString( - CommonString.media_save_summary, - item.mediaDetailEntity.countWish, - item.mediaDetailEntity.countCollect, - item.mediaDetailEntity.countDoing, - item.mediaDetailEntity.countOnHold, - item.mediaDetailEntity.countDropped - ) - holder.binding.tvSave.text = StringUtils.getString( - CommonString.media_save_tip, - InterestType.string(item.mediaDetailEntity.collectState.interest), - GlobalConfig.mediaTypeName(item.mediaDetailEntity.mediaType) - ) - holder.binding.tvSave.setOnFastLimitClickListener(onMultiClick = onSaveBtnClickListener) + holder.binding.tvSave.text = StringUtils.getString( + CommonString.media_save_tip, + InterestType.string(collectState.interest), + GlobalConfig.mediaTypeName(mediaType) + ) + holder.binding.tvSave.setOnFastLimitClickListener { + onSaveBtnClickListener(item, position) + } - item.mediaDetailEntity.collectState.apply { - when (interest) { - InterestType.TYPE_WISH -> { - holder.binding.tvSave.backgroundTintList = - ColorUtils.getColor(CommonColor.save_wish).tint - } + collectState.apply { + when (interest) { + InterestType.TYPE_WISH -> { + holder.binding.tvSave.backgroundTintList = + ColorUtils.getColor(CommonColor.save_wish).tint + } - InterestType.TYPE_COLLECT -> { - holder.binding.tvSave.backgroundTintList = - ColorUtils.getColor(CommonColor.save_collect).tint - } + InterestType.TYPE_COLLECT -> { + holder.binding.tvSave.backgroundTintList = + ColorUtils.getColor(CommonColor.save_collect).tint + } - InterestType.TYPE_DO -> { - holder.binding.tvSave.backgroundTintList = - ColorUtils.getColor(CommonColor.save_do).tint - } + InterestType.TYPE_DO -> { + holder.binding.tvSave.backgroundTintList = + ColorUtils.getColor(CommonColor.save_do).tint + } - InterestType.TYPE_ON_HOLD -> { - holder.binding.tvSave.backgroundTintList = - ColorUtils.getColor(CommonColor.save_on_hold).tint - } + InterestType.TYPE_ON_HOLD -> { + holder.binding.tvSave.backgroundTintList = + ColorUtils.getColor(CommonColor.save_on_hold).tint + } - InterestType.TYPE_DROPPED -> { - holder.binding.tvSave.backgroundTintList = - ColorUtils.getColor(CommonColor.save_dropped).tint - } + InterestType.TYPE_DROPPED -> { + holder.binding.tvSave.backgroundTintList = + ColorUtils.getColor(CommonColor.save_dropped).tint + } - else -> { - holder.binding.tvSave.backgroundTintList = - holder.binding.root.context.getAttrColor(GoogleAttr.colorPrimary).tint - holder.binding.tvSave.text = StringUtils.getString( - CommonString.media_save_click, - GlobalConfig.mediaTypeName(item.mediaDetailEntity.mediaType) - ) + else -> { + holder.binding.tvSave.backgroundTintList = + holder.binding.root.context.getAttrColor(GoogleAttr.colorPrimary).tint + holder.binding.tvSave.text = StringUtils.getString( + CommonString.media_save_click, + GlobalConfig.mediaTypeName(mediaType) + ) + } } } } diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSummaryBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSummaryBinder.kt index 4b88a1f2..e427773b 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSummaryBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewSummaryBinder.kt @@ -3,10 +3,10 @@ package com.xiaoyv.bangumi.ui.media.detail.overview.binder import android.content.Context import android.view.ViewGroup import com.chad.library.adapter.base.BaseMultiItemAdapter -import com.xiaoyv.bangumi.databinding.FragmentOverviewSummaryBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter -import com.xiaoyv.common.kts.inflater -import com.xiaoyv.widget.binder.BaseQuickBindingHolder +import com.xiaoyv.common.api.parser.entity.MediaDetailEntity +import com.xiaoyv.common.kts.forceCast +import com.xiaoyv.common.widget.state.AnimeSummaryView /** * Class: [OverviewSummaryBinder] @@ -14,22 +14,29 @@ import com.xiaoyv.widget.binder.BaseQuickBindingHolder * @author why * @since 11/30/23 */ -class OverviewSummaryBinder : - BaseMultiItemAdapter.OnMultiItemAdapterListener> { +class OverviewSummaryBinder(private val isSummary: Boolean) : + BaseMultiItemAdapter.OnMultiItemAdapterListener { + override fun onBind( - holder: BaseQuickBindingHolder, + holder: AnimeSummaryView.Holder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return - holder.binding.tvSummaryContent.text = item.mediaDetailEntity.subjectSummary + holder.summaryView.section.title = item.title + + item.entity.forceCast().apply { + if (isSummary) { + holder.summaryView.summary = subjectSummary + } else { + holder.summaryView.summaries = infos + } + } } override fun onCreate( context: Context, parent: ViewGroup, viewType: Int - ) = BaseQuickBindingHolder( - FragmentOverviewSummaryBinding.inflate(context.inflater, parent, false) - ) + ) = AnimeSummaryView.createHolder(context, parent) } \ No newline at end of file diff --git a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewTagBinder.kt b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewTagBinder.kt index d849a96d..84b2b91d 100644 --- a/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewTagBinder.kt +++ b/app/src/main/java/com/xiaoyv/bangumi/ui/media/detail/overview/binder/OverviewTagBinder.kt @@ -9,6 +9,7 @@ import com.xiaoyv.bangumi.databinding.FragmentOverviewTagItemBinding import com.xiaoyv.bangumi.ui.media.detail.overview.OverviewAdapter import com.xiaoyv.common.api.parser.entity.MediaDetailEntity import com.xiaoyv.common.kts.GoogleAttr +import com.xiaoyv.common.kts.forceCast import com.xiaoyv.common.kts.inflater import com.xiaoyv.widget.binder.BaseQuickBindingHolder import com.xiaoyv.widget.callback.setOnFastLimitClickListener @@ -23,18 +24,18 @@ import com.xiaoyv.widget.kts.getAttrColor * @since 11/30/23 */ class OverviewTagBinder(private val clickItemListener: (MediaDetailEntity.MediaTag) -> Unit) : - BaseMultiItemAdapter.OnMultiItemAdapterListener> { + BaseMultiItemAdapter.OnMultiItemAdapterListener> { override fun onBind( holder: BaseQuickBindingHolder, position: Int, - item: OverviewAdapter.OverviewItem? + item: OverviewAdapter.Item? ) { item ?: return holder.binding.boxTag.removeAllViews() - val context = holder.binding.root.context - for (tag in item.mediaDetailEntity.tags) { + + for (tag in item.entity.forceCast().tags) { val binding = FragmentOverviewTagItemBinding.inflate( context.inflater, holder.binding.boxTag, diff --git a/app/src/main/res/layout/fragment_overview.xml b/app/src/main/res/layout/fragment_overview.xml index 2dca77cd..8177500d 100644 --- a/app/src/main/res/layout/fragment_overview.xml +++ b/app/src/main/res/layout/fragment_overview.xml @@ -1,24 +1,17 @@ - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:orientation="vertical" /> - - - - - + + diff --git a/app/src/main/res/layout/fragment_overview_1.xml b/app/src/main/res/layout/fragment_overview_1.xml deleted file mode 100644 index 807ca155..00000000 --- a/app/src/main/res/layout/fragment_overview_1.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_board.xml b/app/src/main/res/layout/fragment_overview_board.xml deleted file mode 100644 index 1bca931a..00000000 --- a/app/src/main/res/layout/fragment_overview_board.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_character.xml b/app/src/main/res/layout/fragment_overview_character.xml index 7330c79f..be231c34 100644 --- a/app/src/main/res/layout/fragment_overview_character.xml +++ b/app/src/main/res/layout/fragment_overview_character.xml @@ -5,12 +5,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + app:spanCount="3" + tools:listitem="@layout/fragment_overview_character_item" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_avatar_item.xml b/app/src/main/res/layout/fragment_overview_character_item.xml similarity index 54% rename from app/src/main/res/layout/fragment_overview_avatar_item.xml rename to app/src/main/res/layout/fragment_overview_character_item.xml index 27457167..eff17ab3 100644 --- a/app/src/main/res/layout/fragment_overview_avatar_item.xml +++ b/app/src/main/res/layout/fragment_overview_character_item.xml @@ -3,17 +3,14 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/item_character" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:clickable="true" - android:focusable="true"> + android:layout_width="match_parent" + android:layout_height="wrap_content"> + app:layout_constraintTop_toTopOf="@+id/iv_avatar" + tools:text="歌手、作曲家" /> + app:layout_constraintEnd_toEndOf="@id/iv_avatar" + app:layout_constraintStart_toEndOf="@+id/tv_name" + app:layout_constraintTop_toTopOf="@+id/tv_name" + tools:text="+12" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_detail.xml b/app/src/main/res/layout/fragment_overview_detail.xml deleted file mode 100644 index a255058b..00000000 --- a/app/src/main/res/layout/fragment_overview_detail.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_ep.xml b/app/src/main/res/layout/fragment_overview_ep.xml index ef154f37..29c5a385 100644 --- a/app/src/main/res/layout/fragment_overview_ep.xml +++ b/app/src/main/res/layout/fragment_overview_ep.xml @@ -5,17 +5,10 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_index_item.xml b/app/src/main/res/layout/fragment_overview_index_item.xml deleted file mode 100644 index fb28d0b8..00000000 --- a/app/src/main/res/layout/fragment_overview_index_item.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_maker.xml b/app/src/main/res/layout/fragment_overview_maker.xml deleted file mode 100644 index 6688d21d..00000000 --- a/app/src/main/res/layout/fragment_overview_maker.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_preview.xml b/app/src/main/res/layout/fragment_overview_preview.xml index 1f74a06b..7c0d8f53 100644 --- a/app/src/main/res/layout/fragment_overview_preview.xml +++ b/app/src/main/res/layout/fragment_overview_preview.xml @@ -22,6 +22,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" + android:nestedScrollingEnabled="false" android:orientation="vertical" android:paddingHorizontal="@dimen/ui_size_8" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" diff --git a/app/src/main/res/layout/fragment_overview_relative.xml b/app/src/main/res/layout/fragment_overview_relative.xml index 5f8eb5ea..6391ed16 100644 --- a/app/src/main/res/layout/fragment_overview_relative.xml +++ b/app/src/main/res/layout/fragment_overview_relative.xml @@ -23,6 +23,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" + android:nestedScrollingEnabled="false" android:orientation="horizontal" android:paddingHorizontal="@dimen/ui_size_8" app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" diff --git a/app/src/main/res/layout/fragment_overview_review.xml b/app/src/main/res/layout/fragment_overview_review.xml deleted file mode 100644 index 8ccab401..00000000 --- a/app/src/main/res/layout/fragment_overview_review.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_overview_summary.xml b/app/src/main/res/layout/fragment_overview_summary.xml deleted file mode 100644 index 98b9eddb..00000000 --- a/app/src/main/res/layout/fragment_overview_summary.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_cooperate_item.xml b/app/src/main/res/layout/fragment_person_cooperate_item.xml index b47a164e..1a359b7b 100644 --- a/app/src/main/res/layout/fragment_person_cooperate_item.xml +++ b/app/src/main/res/layout/fragment_person_cooperate_item.xml @@ -40,6 +40,7 @@ android:layout_height="wrap_content" android:layout_marginEnd="@dimen/ui_size_12" android:ellipsize="end" + android:lineSpacingMultiplier="1.25" android:maxLines="2" android:paddingVertical="@dimen/ui_size_6" android:textAppearance="?attr/textAppearanceBodyMedium" diff --git a/lib-common/src/main/java/com/xiaoyv/common/api/parser/entity/MediaDetailEntity.kt b/lib-common/src/main/java/com/xiaoyv/common/api/parser/entity/MediaDetailEntity.kt index 866a85f5..10a38505 100644 --- a/lib-common/src/main/java/com/xiaoyv/common/api/parser/entity/MediaDetailEntity.kt +++ b/lib-common/src/main/java/com/xiaoyv/common/api/parser/entity/MediaDetailEntity.kt @@ -133,12 +133,12 @@ data class MediaDetailEntity( @SerializedName("titleCn") var titleCn: String = "", @SerializedName("firstTime") var firstTime: String = "", @SerializedName("duration") var duration: String = "", - @SerializedName("id") var id: String = "", + @SerializedName("id") override var id: String = "", @SerializedName("no") var no: String = "", @SerializedName("notEp") var notEp: Boolean = false, @SerializedName("isRelease") var isRelease: Boolean = false, @SerializedName("commentCount") var commentCount: Int = 0 - ) : Parcelable + ) : Parcelable,IdEntity @Parcelize @Keep diff --git a/lib-common/src/main/java/com/xiaoyv/common/widget/state/AnimeSummaryView.kt b/lib-common/src/main/java/com/xiaoyv/common/widget/state/AnimeSummaryView.kt index 9679ab16..a526349b 100644 --- a/lib-common/src/main/java/com/xiaoyv/common/widget/state/AnimeSummaryView.kt +++ b/lib-common/src/main/java/com/xiaoyv/common/widget/state/AnimeSummaryView.kt @@ -27,6 +27,20 @@ class AnimeSummaryView @JvmOverloads constructor( binding.tvSummaryContent.text = value.ifBlank { "暂时没有介绍呢!" } } + var summaries: List = emptyList() + set(value) { + field = value + if (value.isEmpty()) { + binding.tvSummaryContent.text = "暂时没有内容呢!" + } else { + binding.tvSummaryContent.text = null + value.forEach { + binding.tvSummaryContent.append(it) + binding.tvSummaryContent.append("\n") + } + } + } + class Holder(private val view: AnimeSummaryView) : RecyclerView.ViewHolder(view) {