Skip to content
This repository was archived by the owner on Jul 18, 2026. It is now read-only.

Commit 8924c75

Browse files
authored
Merge pull request #91 from misaka10032w/develop
优化部分UI界面,兼容新版搜索
2 parents 056ad5a + 9a632c0 commit 8924c75

20 files changed

Lines changed: 442 additions & 140 deletions

app/src/main/assets/search_options/duration.json

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,66 @@
99
},
1010
{
1111
"lang": {
12-
"zh-rCN": "短片(4分钟内)",
13-
"en": "Short Film (Within 4 min)",
14-
"zh-rTW": "短片(4分鐘內)"
12+
"zh-rCN": "1分钟以上",
13+
"en": "More than 1 minute",
14+
"zh-rTW": "1分鐘以上"
1515
},
16-
"search_key": "短片"
16+
"search_key": "1 分鐘 +"
1717
},
1818
{
1919
"lang": {
20-
"zh-rCN": "中长片(4至20分钟)",
21-
"en": "Medium-length Film (4 to 20 min)",
22-
"zh-rTW": "中長片(4至20分鐘)"
20+
"zh-rCN": "5分钟以上",
21+
"en": "More than 5 minute",
22+
"zh-rTW": "5分鐘以上"
2323
},
24-
"search_key": "中長片"
24+
"search_key": "5 分鐘 +"
2525
},
2626
{
2727
"lang": {
28-
"zh-rCN": "长片(20分钟以上)",
29-
"en": "Feature Film (Over 20 min)",
30-
"zh-rTW": "長片(20分鐘以上)"
28+
"zh-rCN": "10分钟以上",
29+
"en": "More than 10 minutes",
30+
"zh-rTW": "10分鐘以上"
3131
},
32-
"search_key": "長片"
32+
"search_key": "10 分鐘 +"
33+
},
34+
{
35+
"lang": {
36+
"zh-rCN": "20分钟以上",
37+
"en": "More than 20 minutes",
38+
"zh-rTW": "20分鐘以上"
39+
},
40+
"search_key": "20 分鐘 +"
41+
},
42+
{
43+
"lang": {
44+
"zh-rCN": "30分钟以上",
45+
"en": "More than 30 minutes",
46+
"zh-rTW": "30分鐘以上"
47+
},
48+
"search_key": "30 分鐘 +"
49+
},
50+
{
51+
"lang": {
52+
"zh-rCN": "60分钟以上",
53+
"en": "More than 60 minutes",
54+
"zh-rTW": "60分鐘以上"
55+
},
56+
"search_key": "60 分鐘 +"
57+
},
58+
{
59+
"lang": {
60+
"zh-rCN": "0~10分钟",
61+
"en": "0~10 minutes",
62+
"zh-rTW": "0~10分鐘"
63+
},
64+
"search_key": "0 - 10 分鐘"
65+
},
66+
{
67+
"lang": {
68+
"zh-rCN": "0~20分钟",
69+
"en": "0~20 minutes",
70+
"zh-rTW": "0~20分鐘以上"
71+
},
72+
"search_key": "0 - 20 分鐘"
3373
}
3474
]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"lang": {
4+
"zh-rCN": "全部",
5+
"en": "All",
6+
"zh-rTW": "全部"
7+
},
8+
"search_key": null
9+
},
10+
{
11+
"lang": {
12+
"zh-rCN": "过去24小时",
13+
"en": "Last 24 hours",
14+
"zh-rTW": "過去24小時"
15+
},
16+
"search_key": "過去 24 小時"
17+
},
18+
{
19+
"lang": {
20+
"zh-rCN": "过去2天",
21+
"en": "Last 2 days",
22+
"zh-rTW": "過去2天"
23+
},
24+
"search_key": "過去 2 天"
25+
},
26+
{
27+
"lang": {
28+
"zh-rCN": "过去1周",
29+
"en": "Last week",
30+
"zh-rTW": "過去1週"
31+
},
32+
"search_key": "過去 1 週"
33+
},
34+
{
35+
"lang": {
36+
"zh-rCN": "过去1个月",
37+
"en": "Last month",
38+
"zh-rTW": "過去1個月"
39+
},
40+
"search_key": "過去 1 個月"
41+
},
42+
{
43+
"lang": {
44+
"zh-rCN": "过去3个月",
45+
"en": "Last 3 months",
46+
"zh-rTW": "過去3個月"
47+
},
48+
"search_key": "過去 3 個月"
49+
},
50+
{
51+
"lang": {
52+
"zh-rCN": "过去1年",
53+
"en": "Past year",
54+
"zh-rTW": "過去1年"
55+
},
56+
"search_key": "過去 1 年"
57+
}
58+
]

app/src/main/assets/search_options/sort_option.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,13 @@
6262
"zh-rTW": "他們在看"
6363
},
6464
"search_key": "他們在看"
65+
},
66+
{
67+
"lang": {
68+
"zh-rCN": "时长最长",
69+
"en": "Longest duration",
70+
"zh-rTW": "時長最長"
71+
},
72+
"search_key": "時長最長"
6573
}
6674
]

app/src/main/java/com/yenaly/han1meviewer/logic/NetworkRepo.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ object NetworkRepo {
4545

4646
fun getHanimeSearchResult(
4747
page: Int, query: String?, genre: String?,
48-
sort: String?, broad: Boolean, year: Int?, month: Int?,
48+
sort: String?, broad: Boolean, date: String?,
4949
duration: String?, tags: Set<String>, brands: Set<String>,
5050
) = pageIOFlow(
5151
request = {
5252
HanimeNetwork.hanimeService.getHanimeSearchResult(
5353
page, query, genre, sort,
5454
if (broad) "on" else null,
55-
year, month, duration, tags, brands
55+
date, duration, tags, brands
5656
)
5757
},
5858
action = Parser::hanimeSearch

app/src/main/java/com/yenaly/han1meviewer/logic/network/ServiceCreator.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.yenaly.han1meviewer.HA1_GITHUB_API_URL
66
import com.yenaly.han1meviewer.HJson
77
import com.yenaly.han1meviewer.Preferences
88
import com.yenaly.han1meviewer.logic.network.interceptor.SpeedLimitInterceptor
9+
import com.yenaly.han1meviewer.logic.network.interceptor.UrlLoggingInterceptor
910
import com.yenaly.han1meviewer.logic.network.interceptor.UserAgentInterceptor
1011
import com.yenaly.yenaly_libs.utils.applicationContext
1112
import com.yenaly.yenaly_libs.utils.unsafeLazy
@@ -79,6 +80,7 @@ object ServiceCreator {
7980
return OkHttpClient.Builder()
8081
.connectTimeout(15, TimeUnit.SECONDS)
8182
.addInterceptor(UserAgentInterceptor)
83+
.addInterceptor(UrlLoggingInterceptor())
8284
.cache(cache)
8385
.cookieJar(HCookieJar())
8486
.proxySelector(HProxySelector())
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.yenaly.han1meviewer.logic.network.interceptor
2+
3+
import android.util.Log
4+
import okhttp3.Interceptor
5+
import okhttp3.Response
6+
import java.net.URLDecoder
7+
import java.nio.charset.StandardCharsets
8+
9+
class UrlLoggingInterceptor : Interceptor {
10+
override fun intercept(chain: Interceptor.Chain): Response {
11+
val request = chain.request()
12+
val url = request.url.toString()
13+
val decodedUrl = URLDecoder.decode(url, StandardCharsets.UTF_8.name())
14+
Log.i("NetworkRequest",decodedUrl)
15+
return chain.proceed(request)
16+
}
17+
}

app/src/main/java/com/yenaly/han1meviewer/logic/network/service/HanimeBaseService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ interface HanimeBaseService {
2222
@Query("genre") genre: String? = null,
2323
@Query("sort") sort: String? = null,
2424
@Query("broad") broad: String? = null,
25-
@Query("year") year: Int? = null,
26-
@Query("month") month: Int? = null,
25+
// @Query("year") year: Int? = null,
26+
// @Query("month") month: Int? = null,
27+
@Query("date") date: String? = null,
2728
@Query("duration") duration: String? = null,
2829
@Query("tags[]") tags: Set<String> = emptySet(),
2930
@Query("brands[]") brands: Set<String> = emptySet(),

app/src/main/java/com/yenaly/han1meviewer/ui/activity/MainActivity.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ class MainActivity : YenalyActivity<ActivityMainBinding>(), DrawerListener, Tool
165165
R.id.nv_playlist -> R.id.nv_playlist
166166
R.id.nv_watch_later -> R.id.nv_watch_later
167167
R.id.nav_settings -> R.id.nv_settings
168+
R.id.nv_subscription -> R.id.nv_subscription
168169
else -> null
169170
}
170171
if (targetId != null && targetId != currentCheckedId) {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.yenaly.han1meviewer.ui.adapter
2+
3+
import android.view.LayoutInflater
4+
import android.view.View
5+
import android.view.ViewGroup
6+
import android.widget.TextView
7+
import androidx.recyclerview.widget.RecyclerView
8+
import com.google.android.material.card.MaterialCardView
9+
import com.yenaly.han1meviewer.R
10+
import com.yenaly.han1meviewer.logic.model.SearchOption
11+
12+
class ReleaseDateAdapter(
13+
private val items: List<SearchOption>,
14+
private val onClick: (SearchOption) -> Unit
15+
) : RecyclerView.Adapter<ReleaseDateAdapter.ViewHolder>() {
16+
17+
private var selectedPosition = RecyclerView.NO_POSITION
18+
19+
inner class ViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
20+
private val card = view.findViewById<MaterialCardView>(R.id.card)
21+
private val text = view.findViewById<TextView>(R.id.textTitle)
22+
23+
fun bind(item: SearchOption, position: Int) {
24+
text.text = item.value
25+
card.strokeWidth = if (position == selectedPosition) 4 else 0
26+
card.isChecked = position == selectedPosition
27+
28+
view.setOnClickListener {
29+
val prev = selectedPosition
30+
selectedPosition = bindingAdapterPosition
31+
notifyItemChanged(prev)
32+
notifyItemChanged(selectedPosition)
33+
onClick(item)
34+
}
35+
}
36+
}
37+
38+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
39+
val view = LayoutInflater.from(parent.context)
40+
.inflate(R.layout.item_simple_card, parent, false)
41+
return ViewHolder(view)
42+
}
43+
44+
override fun getItemCount() = items.size
45+
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
46+
holder.bind(items[position], position)
47+
}
48+
}

app/src/main/java/com/yenaly/han1meviewer/ui/fragment/search/SearchFragment.kt

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,28 +212,35 @@ class SearchFragment : YenalyFragment<FragmentSearchBinding>(), StateLayoutMixin
212212
}
213213
}
214214
lifecycleScope.launch {
215-
repeatOnLifecycle(Lifecycle.State.RESUMED) {
215+
repeatOnLifecycle(Lifecycle.State.STARTED) {
216216
viewModel.refreshTriggerFlow.collect {
217217
binding.searchSrl.autoRefresh()
218-
getNewHanimeSearchResult()
218+
// getNewHanimeSearchResult()
219219
}
220220
}
221221
}
222222

223223
}
224224

225-
226225
private fun getHanimeSearchResult() {
227226
Log.d("SearchActivity", buildString {
228227
appendLine("page: ${viewModel.page}, query: ${viewModel.query}, genre: ${viewModel.genre}, ")
229228
appendLine("sort: ${viewModel.sort}, broad: ${viewModel.broad}, year: ${viewModel.year}, ")
230229
appendLine("month: ${viewModel.month}, duration: ${viewModel.duration}, ")
231-
appendLine("tagMap: ${viewModel.tagMap}, brandMap: ${viewModel.brandMap}")
230+
appendLine("tagMap: ${viewModel.tagMap}, brandMap: ${viewModel.brandMap}, approxTime:${viewModel.approxTime}")
232231
})
232+
val date: String? = when {
233+
viewModel.approxTime != null -> viewModel.approxTime
234+
viewModel.year != null -> listOfNotNull(
235+
viewModel.year?.let { "$it" },
236+
viewModel.month?.let { "$it" }
237+
).joinToString(" ")
238+
else -> null
239+
}
233240
viewModel.getHanimeSearchResult(
234241
viewModel.page,
235242
viewModel.query, viewModel.genre, viewModel.sort, viewModel.broad,
236-
viewModel.year, viewModel.month, viewModel.duration,
243+
date, viewModel.duration,
237244
viewModel.tagMap.flatten(), viewModel.brandMap.flatten()
238245
)
239246
}

0 commit comments

Comments
 (0)