Skip to content

Commit

Permalink
[修复] 加入清单没有正确刷新
Browse files Browse the repository at this point in the history
  • Loading branch information
YenalyLiew committed Sep 7, 2024
1 parent 5d9d4b4 commit 2681d4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.yenaly.han1meviewer.logic.model

import com.yenaly.han1meviewer.ResolutionLinkMap
import com.yenaly.yenaly_libs.utils.mapToArray
import kotlinx.datetime.LocalDate

/**
Expand Down Expand Up @@ -57,7 +58,7 @@ data class HanimeVideo(
var isSelected: Boolean,
)

val titleArray get() = myListInfo.map { it.title }.toTypedArray()
val titleArray get() = myListInfo.mapToArray { it.title }
val isSelectedArray get() = myListInfo.map { it.isSelected }.toBooleanArray()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@ class VideoIntroductionFragment :
if (bitset and FAV != 0) {
holder.binding.handleFavButton(item.isFav)
}
// #issue-202: 加入清单之后不会正常刷新
if (bitset and PLAYLIST != 0) {
holder.binding.initMyList(item.myList)
}
if (bitset and SUBSCRIBE != 0) {
holder.binding.initArtist(item.artist)
}
Expand Down Expand Up @@ -543,16 +547,23 @@ class VideoIntroductionFragment :
showShortToast(R.string.login_first)
}
}
initMyList(videoData.myList)
btnToWebpage.clickTrigger(viewLifecycleOwner.lifecycle) {
browse(getHanimeVideoLink(viewModel.videoCode))
}
}

private fun ItemVideoIntroductionBinding.initMyList(myList: HanimeVideo.MyList?) {
btnMyList.setOnClickListener {
if (isAlreadyLogin) {
if (isAlreadyLogin && myList != null && myList.myListInfo.isNotEmpty()) {
requireContext().showAlertDialog {
setTitle(R.string.add_to_playlist)
setMultiChoiceItems(
videoData.myList?.titleArray,
videoData.myList?.isSelectedArray,
myList.titleArray,
myList.isSelectedArray,
) { _, index, isChecked ->
viewModel.modifyMyList(
checkNotNull(videoData.myList?.myListInfo?.get(index)).code,
myList.myListInfo[index].code,
viewModel.videoCode, isChecked, index
)
}
Expand All @@ -562,9 +573,6 @@ class VideoIntroductionFragment :
showShortToast(R.string.login_first)
}
}
btnToWebpage.clickTrigger(viewLifecycleOwner.lifecycle) {
browse(getHanimeVideoLink(viewModel.videoCode))
}
}

private fun ItemVideoIntroductionBinding.initShareButton(title: String) {
Expand Down

0 comments on commit 2681d4b

Please sign in to comment.