From 001f8538d1ada4b405f3c98707fc979c4d399627 Mon Sep 17 00:00:00 2001 From: Yenaly <2021214976@stu.cqupt.edu.cn> Date: Sun, 14 Apr 2024 21:26:30 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]=20=E5=BE=AE=E8=B0=83?= =?UTF-8?q?=E6=96=B0=E7=95=AA=E5=AF=BC=E8=A7=88=E7=95=8C=E9=9D=A2=E8=A7=86?= =?UTF-8?q?=E8=A7=89=E6=95=88=E6=9E=9C=20[=E6=9B=B4=E6=96=B0]=20=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E5=85=B3=E9=94=AEH=E5=B8=A7=E7=9B=B8=E5=85=B3=20READM?= =?UTF-8?q?E.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/assets/h_keyframes/README.md | 33 +++++++++++-------- .../ui/activity/PreviewActivity.kt | 26 +++++++++++++-- .../ui/adapter/HKeyframesRvAdapter.kt | 3 ++ .../ui/adapter/HanimePreviewNewsRvAdapter.kt | 9 ++--- .../ui/adapter/SharedHKeyframesRvAdapter.kt | 2 +- .../layout/item_hanime_preview_news_v2.xml | 33 ++++++++++++++----- 6 files changed, 73 insertions(+), 33 deletions(-) diff --git a/app/src/main/assets/h_keyframes/README.md b/app/src/main/assets/h_keyframes/README.md index 11d7880d..dcb11d6d 100644 --- a/app/src/main/assets/h_keyframes/README.md +++ b/app/src/main/assets/h_keyframes/README.md @@ -10,8 +10,8 @@ 前在屏幕**左上角**倒计时提醒(可调整)。在 0-1s 时,会精确到一位小数,方便你更好的控制时间。 此外,还提供了**共享关键H帧集**。这些关键H帧是内置于软件里的,来源于贡献者在 GitHub -上的补充。目前是随着版本更新来更新共享关键H帧集,暂时不考虑服务器在线共享之类的(太危险), -~~前提是有贡献者来帮忙补充~~。 +上的补充。目前是随着版本更新(或 CI 实时更新)来更新共享关键H帧集,暂时不考虑服务器在线共享之类的(太危险)。 + [共享关键库位置](https://github.com/YenalyLiew/Han1meViewer/blob/master/app/src/main/assets/h_keyframes) ## 须知 @@ -56,7 +56,9 @@ clone 仓库步骤: ```json { "videoCode": "84711", + "group": "aaa", "title": "abc", + "episode": 1, "author": "yenaly", "keyframes": [ { @@ -73,17 +75,20 @@ clone 仓库步骤: 介绍一下每一个键值是干什么的: -> 注意:`author`为`null`时代表个人本地储存的,不为空才代表是共享的。所以不允许 JSON 文件里出现`null` -> 的`author`。 - -| 键 | 值类型 | 作用 | -|-----------|-------------------|----------------------------------------| -| videoCode | string (not null) | 影片代号,用于识别影片 | -| title | string (not null) | 影片标题,看得清晰些 | -| author | string (not null) | 关键H帧作者,也就是你,**而不是**影片作者! | -| keyframes | array | 关键H帧列表 | +> 注意-1:`author`为`null`时代表个人本地储存的,不为空才代表是共享的。所以不允许 JSON 文件里出现`null`的`author`。 +> +> 注意-2:编写前务必查询当前已上传的关键H帧是否存在。假设有一人已上传 AAA 的第一集,group 名为`aaa`,title 为`aaa-01`,你也要按照他的方式进行修改,不要自行更改 group 名为`AAA`。如果你觉得你的命名更准确、更优质,也可以选择将其所有当前系列的group名和title名一起修改。 + +| 键 | 值类型 | 作用 | +| --------- | ----------------- | ------------------------------------------------------------ | +| videoCode | string (not null) | 影片代号,用于识别影片 | +| group | string (nullable) | 影片系列名称,用于影片分组,为 null 代表无系列 | +| title | string (not null) | 影片标题,看得清晰些 | +| episode | number | 影片集数,如果无系列请填 0 | +| author | string (not null) | 关键H帧作者,也就是你,**而不是**影片作者! | +| keyframes | array | 关键H帧列表 | | position | number | 「顶点」位置,怎么获取下面说,两个 position 必须间隔 5s 及以上 | -| prompt | string (nullable) | 「顶点」提示,最好少于五个字,或 null | +| prompt | string (nullable) | 「顶点」提示,最好少于五个字,或 null | #### 怎么获取「顶点」位置? @@ -114,11 +119,11 @@ push 到远程仓库: 以上步骤完成后,就可以将代码从本地仓库推送到远程仓库了。 -> 注意,提交信息的格式为:`[关键H帧] 添加/修改/删除 <影片代号>` +> 注意,提交信息的格式为:`[HKeyframe] 添加/修改/删除 <影片名称>` > > 简繁都行,英文也行。 > -> 例如:`[关键H帧] 修改 12345` +> 例如:`[HKeyframe] 添加 初恋时间系列` ### Pull Request diff --git a/app/src/main/java/com/yenaly/han1meviewer/ui/activity/PreviewActivity.kt b/app/src/main/java/com/yenaly/han1meviewer/ui/activity/PreviewActivity.kt index 4f9945f3..ad37e294 100644 --- a/app/src/main/java/com/yenaly/han1meviewer/ui/activity/PreviewActivity.kt +++ b/app/src/main/java/com/yenaly/han1meviewer/ui/activity/PreviewActivity.kt @@ -60,7 +60,14 @@ class PreviewActivity : YenalyActivity private val dateUtils = DateUtils() + /** + * 左右滑动 VP 时,不触发 onScrollStateChanged,防止触发两次 binding.vpNews.setCurrentItem + * 导致滑动不流畅。 + */ + private var shouldTriggerScroll = false + private val tourSimplifiedAdapter = HanimePreviewTourRvAdapter() + private val linearSnapHelper = LinearSnapHelper() private val newsAdapter = HanimePreviewNewsRvAdapter() private val tourLayoutManager by unsafeLazy { @@ -138,11 +145,23 @@ class PreviewActivity : YenalyActivity } } }) + linearSnapHelper.attachToRecyclerView(this) + addOnScrollListener(object : RecyclerView.OnScrollListener() { + override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { + super.onScrollStateChanged(recyclerView, newState) + if (newState == RecyclerView.SCROLL_STATE_IDLE) { + if (shouldTriggerScroll) { + val view = linearSnapHelper.findSnapView(tourLayoutManager) + val position = view?.let(::getChildAdapterPosition) + ?: RecyclerView.NO_POSITION + binding.vpNews.setCurrentItem(position, false) + } + shouldTriggerScroll = true + } + } + }) } - val linearSnapHelper = LinearSnapHelper() - linearSnapHelper.attachToRecyclerView(binding.rvTourSimplified) - tourSimplifiedAdapter.setOnItemClickListener { _, _, position -> binding.vpNews.setCurrentItem(position, false) binding.appBar.setExpanded(false, true) @@ -152,6 +171,7 @@ class PreviewActivity : YenalyActivity binding.vpNews.offscreenPageLimit = 1 binding.vpNews.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() { override fun onPageSelected(position: Int) { + shouldTriggerScroll = false binding.rvTourSimplified.smoothScrollToPosition(position) } }) diff --git a/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HKeyframesRvAdapter.kt b/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HKeyframesRvAdapter.kt index 2f16425a..ea137f8e 100644 --- a/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HKeyframesRvAdapter.kt +++ b/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HKeyframesRvAdapter.kt @@ -191,6 +191,8 @@ class HKeyframeRvAdapter( */ var isLocal: Boolean = true + var isShared: Boolean = false + companion object { val COMPARATOR = object : DiffUtil.ItemCallback() { override fun areItemsTheSame( @@ -231,6 +233,7 @@ class HKeyframeRvAdapter( viewType: Int, ): QuickViewHolder { return QuickViewHolder(R.layout.item_h_keyframe, parent).also { viewHolder -> + if (isShared) return@also viewHolder.getView(R.id.btn_edit).apply { setOnClickListener { val position = viewHolder.bindingAdapterPosition diff --git a/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HanimePreviewNewsRvAdapter.kt b/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HanimePreviewNewsRvAdapter.kt index b34f2cf9..e545b76d 100644 --- a/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HanimePreviewNewsRvAdapter.kt +++ b/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/HanimePreviewNewsRvAdapter.kt @@ -1,7 +1,6 @@ package com.yenaly.han1meviewer.ui.adapter import android.content.Context -import android.graphics.Color import android.view.LayoutInflater import android.view.ViewGroup import android.widget.ImageView @@ -10,7 +9,6 @@ import coil.load import com.chad.library.adapter4.BaseQuickAdapter import com.chad.library.adapter4.viewholder.DataBindingHolder import com.chad.library.adapter4.viewholder.QuickViewHolder -import com.itxca.spannablex.spannable import com.lxj.xpopup.XPopup import com.yenaly.han1meviewer.R import com.yenaly.han1meviewer.VIDEO_CODE @@ -19,8 +17,8 @@ import com.yenaly.han1meviewer.logic.model.HanimePreview import com.yenaly.han1meviewer.ui.activity.PreviewActivity import com.yenaly.han1meviewer.ui.activity.VideoActivity import com.yenaly.han1meviewer.ui.popup.CoilImageLoader +import com.yenaly.han1meviewer.ui.view.BlurTransformation import com.yenaly.han1meviewer.util.notNull -import com.yenaly.yenaly_libs.utils.dp import com.yenaly.yenaly_libs.utils.startActivity /** @@ -45,10 +43,9 @@ class HanimePreviewNewsRvAdapter : item.notNull() holder.binding.ivCoverBig.load(item.coverUrl) { crossfade(true) + transformations(BlurTransformation(context)) } - holder.binding.tvTitle.text = spannable { - item.title.quote(Color.RED, stripeWidth = 4.dp, gapWidth = 4.dp) - } + holder.binding.tvTitle.text = item.title holder.binding.tvIntroduction.text = item.introduction holder.binding.tvBrand.text = item.brand holder.binding.tvReleaseDate.text = item.releaseDate diff --git a/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/SharedHKeyframesRvAdapter.kt b/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/SharedHKeyframesRvAdapter.kt index ed1577cd..90a2ed44 100644 --- a/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/SharedHKeyframesRvAdapter.kt +++ b/app/src/main/java/com/yenaly/han1meviewer/ui/adapter/SharedHKeyframesRvAdapter.kt @@ -31,7 +31,6 @@ class SharedHKeyframesRvAdapter : BaseDifferAdapter() { override fun areItemsTheSame( oldItem: HKeyframeType, @@ -92,6 +91,7 @@ class SharedHKeyframesRvAdapter : BaseDifferAdapter - + android:layout_height="wrap_content"> + + + + + +