Skip to content

Commit

Permalink
[Feat]: 章节收藏状态增加撤销
Browse files Browse the repository at this point in the history
  • Loading branch information
why committed Dec 21, 2023
1 parent 58418c7 commit dd6794c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/com/xiaoyv/bangumi/base/BaseListFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ abstract class BaseListFragment<T, VM : BaseListViewModel<T>> :
*/
open val loadingBias: Float = 0.5f

/**
* 刷新时是否滑动到顶部
*/
open val scrollTopWhenRefresh: Boolean = true

internal val contentAdapter: BaseDifferAdapter<T, *> by lazy {
onCreateContentAdapter()
}
Expand Down Expand Up @@ -75,7 +80,7 @@ abstract class BaseListFragment<T, VM : BaseListViewModel<T>> :
} else {
binding.rvContent.adapter = adapterHelper.adapter
}
autoInitData()
autoInitData()
}


Expand Down Expand Up @@ -113,7 +118,7 @@ abstract class BaseListFragment<T, VM : BaseListViewModel<T>> :
}

contentAdapter.submitList(it) {
if (viewModel.isRefresh) {
if (viewModel.isRefresh && scrollTopWhenRefresh) {
layoutManager?.scrollToPositionWithOffset(0, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class MediaEpCollectDialog : DialogFragment() {
append(entity.titleCn)
}
binding.tvDesc.text = entity.time
binding.tvComment.text = String.format("讨论:%d", entity.commentCount)
binding.tvComment.text = String.format("讨论:%d,点击查看", entity.commentCount)

binding.tvComment.setOnFastLimitClickListener {
jumpDetail(entity)
Expand Down Expand Up @@ -106,7 +106,8 @@ class MediaEpCollectDialog : DialogFragment() {
}

else -> {
InterestType.TYPE_UNKNOWN
entity.collectType = InterestType.TYPE_UNKNOWN
EpCollectType.TYPE_REMOVE
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class MediaChapterFragment : BaseListFragment<MediaChapterEntity, MediaChapterVi
override val loadingBias: Float
get() = 0.3f

override val scrollTopWhenRefresh: Boolean
get() = false

override fun initArgumentsData(arguments: Bundle) {
viewModel.mediaId = arguments.getString(NavKey.KEY_STRING).orEmpty()
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/fragment_media_action_ep_collect.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@
android:padding="@dimen/ui_size_0"
android:text="抛弃"
android:textAppearance="?attr/textAppearanceBodyMedium" />

<com.xiaoyv.common.widget.button.AnimeButton
android:id="@+id/btn_remove"
style="@style/Widget.Material3.Button.OutlinedButton"
android:layout_width="@dimen/ui_size_0"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="@dimen/ui_size_0"
android:text="撤销"
android:textAppearance="?attr/textAppearanceBodyMedium" />
</com.google.android.material.button.MaterialButtonToggleGroup>

<com.xiaoyv.common.widget.image.AnimeImageView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import androidx.annotation.StringDef
EpCollectType.TYPE_WATCHED,
EpCollectType.TYPE_QUEUE,
EpCollectType.TYPE_DROP,
EpCollectType.TYPE_REMOVE
)
@Retention(AnnotationRetention.SOURCE)
annotation class EpCollectType {
companion object {
const val TYPE_WATCHED = "watched"
const val TYPE_QUEUE = "queue"
const val TYPE_DROP = "drop"
const val TYPE_REMOVE = "remove"
}
}

0 comments on commit dd6794c

Please sign in to comment.