Skip to content

Commit

Permalink
[优化] 微调新番导览界面视觉效果
Browse files Browse the repository at this point in the history
[更新] 补充关键H帧相关 README.md
  • Loading branch information
YenalyLiew committed Apr 14, 2024
1 parent dd9847a commit 001f853
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 33 deletions.
33 changes: 19 additions & 14 deletions app/src/main/assets/h_keyframes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 须知
Expand Down Expand Up @@ -56,7 +56,9 @@ clone 仓库步骤:
```json
{
"videoCode": "84711",
"group": "aaa",
"title": "abc",
"episode": 1,
"author": "yenaly",
"keyframes": [
{
Expand All @@ -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 |

#### 怎么获取「顶点」位置?

Expand Down Expand Up @@ -114,11 +119,11 @@ push 到远程仓库:

以上步骤完成后,就可以将代码从本地仓库推送到远程仓库了。

> 注意,提交信息的格式为:`[关键H帧] 添加/修改/删除 <影片代号>`
> 注意,提交信息的格式为:`[HKeyframe] 添加/修改/删除 <影片名称>`
>
> 简繁都行,英文也行。
>
> 例如:`[关键H帧] 修改 12345`
> 例如:`[HKeyframe] 添加 初恋时间系列`
### Pull Request

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ class PreviewActivity : YenalyActivity<ActivityPreviewBinding, PreviewViewModel>

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 {
Expand Down Expand Up @@ -138,11 +145,23 @@ class PreviewActivity : YenalyActivity<ActivityPreviewBinding, PreviewViewModel>
}
}
})
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)
Expand All @@ -152,6 +171,7 @@ class PreviewActivity : YenalyActivity<ActivityPreviewBinding, PreviewViewModel>
binding.vpNews.offscreenPageLimit = 1
binding.vpNews.registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
shouldTriggerScroll = false
binding.rvTourSimplified.smoothScrollToPosition(position)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class HKeyframeRvAdapter(
*/
var isLocal: Boolean = true

var isShared: Boolean = false

companion object {
val COMPARATOR = object : DiffUtil.ItemCallback<HKeyframeEntity.Keyframe>() {
override fun areItemsTheSame(
Expand Down Expand Up @@ -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<MaterialButton>(R.id.btn_edit).apply {
setOnClickListener {
val position = viewHolder.bindingAdapterPosition
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

/**
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class SharedHKeyframesRvAdapter : BaseDifferAdapter<HKeyframeType, QuickViewHold
}

companion object {

val COMPARATOR = object : DiffUtil.ItemCallback<HKeyframeType>() {
override fun areItemsTheSame(
oldItem: HKeyframeType,
Expand Down Expand Up @@ -92,6 +91,7 @@ class SharedHKeyframesRvAdapter : BaseDifferAdapter<HKeyframeType, QuickViewHold
layoutManager = LinearLayoutManager(context)
adapter = HKeyframeRvAdapter(item.videoCode, item).apply {
isLocal = item.author == null
isShared = true
}
}
holder.setText(R.id.tv_author, "@${item.author}")
Expand Down
33 changes: 24 additions & 9 deletions app/src/main/res/layout/item_hanime_preview_news_v2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,41 @@
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/per80_transparent_black"
android:background="@color/per70_transparent_black"
android:contentDescription="@null" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:clipToPadding="false"
android:paddingHorizontal="8dp">

<TextView
android:id="@+id/tv_title"
<LinearLayout
android:layout_marginStart="-8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:ellipsize="end"
android:maxLines="2"
android:textAppearance="@style/TextAppearance.Material3.TitleLarge"
android:textSize="20sp"
tools:text="123122342424242424342234" />
android:layout_height="wrap_content">

<View
android:layout_width="8dp"
android:layout_height="match_parent"
android:layout_marginVertical="4dp"
android:background="@color/red" />

<TextView
android:id="@+id/tv_title"
style="@style/TextAppearance.Material3.TitleLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:textSize="24sp"
android:textStyle="bold"
tools:text="1234 -v 125" />

</LinearLayout>

<TextView
android:id="@+id/tv_video_title"
Expand Down

0 comments on commit 001f853

Please sign in to comment.