Skip to content

Commit

Permalink
v3.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
15dd committed Jan 9, 2025
1 parent e20fc33 commit d328429
Show file tree
Hide file tree
Showing 32 changed files with 149 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId = "com.cyh128.hikari_novel"
minSdk = 24
targetSdk = 35
versionCode = 241231
versionName = "3.4.0"
versionCode = 250109
versionName = "3.5.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -80,11 +80,10 @@ dependencies {
//android相关
implementation("androidx.core:core-ktx:1.15.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.13.0-alpha08")
implementation("com.google.android.material:material:1.13.0-alpha09")
implementation("androidx.constraintlayout:constraintlayout:2.2.0")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.viewpager2:viewpager2:1.1.0")

implementation("androidx.navigation:navigation-fragment-ktx:2.8.5")
implementation("androidx.navigation:navigation-ui-ktx:2.8.5")

Expand All @@ -106,7 +105,7 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.7")

//协程
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0-RC")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0")

//html解析
Expand All @@ -119,7 +118,7 @@ dependencies {
implementation("com.trendyol:medusa:0.12.1")

//持久化存储
implementation("com.tencent:mmkv:1.3.7")
implementation("com.tencent:mmkv:2.0.2")

//图片加载
implementation("com.github.bumptech.glide:glide:4.16.0")
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Binary file modified app/release/baselineProfiles/0/app-release.dm
Binary file not shown.
Binary file modified app/release/baselineProfiles/1/app-release.dm
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 241231,
"versionName": "3.4.0",
"versionCode": 250109,
"versionName": "3.5.0",
"outputFile": "app-release.apk"
}
],
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

<uses-permission android:name="android.permission.INTERNET"/>

<!-- TODO material design 3自适应颜色图标 https://blog.csdn.net/minping9101/article/details/129436383 -->
<application
android:name=".HikariApp"
android:allowBackup="true"
Expand Down
Binary file modified app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ abstract class BaseActivity<VB : ViewBinding> : AppCompatActivity() {
val intent = Intent(this, this::class.java)
startActivity(intent)
finish()
overridePendingTransition(0, 0) //TODO 去掉切换动画
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,40 @@ import android.animation.ObjectAnimator
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.ViewModelStoreOwner
import androidx.lifecycle.viewModelScope
import com.cyh128.hikari_novel.R
import com.cyh128.hikari_novel.data.model.Novel
import com.cyh128.hikari_novel.databinding.ItemChapterCcssBinding
import com.cyh128.hikari_novel.databinding.ItemChapterVcssBinding
import com.cyh128.hikari_novel.util.ResourceUtil
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import pokercc.android.expandablerecyclerview.ExpandableAdapter

class NovelChapterListAdapter(
private val viewModelStoreOwner: ViewModelStoreOwner,
private var viewModel: NovelInfoViewModel,
private val novel: Novel,
private val onItemClick: (volume: Int, chapter: Int) -> Unit,
private val onLongClick: (cid: String) -> Unit
) : ExpandableAdapter<ExpandableAdapter.ViewHolder>() {
private val viewModel by lazy { ViewModelProvider(viewModelStoreOwner)[NovelInfoViewModel::class.java] }
internal class GroupViewHolder(val binding: ItemChapterVcssBinding) : ViewHolder(binding.root) {
val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())

internal class GroupViewHolder(val binding: ItemChapterVcssBinding) : ViewHolder(binding.root)
internal class ChildViewHolder(val binding: ItemChapterCcssBinding) : ViewHolder(binding.root)
fun clean() {
scope.cancel() // 取消所有协程
}
}

internal class ChildViewHolder(val binding: ItemChapterCcssBinding) : ViewHolder(binding.root) {
val scope = CoroutineScope(Dispatchers.Main + SupervisorJob())

fun clean() {
scope.cancel() // 取消所有协程
}
}

override fun getChildCount(groupPosition: Int): Int = novel.volume[groupPosition].chapters.size

Expand Down Expand Up @@ -87,7 +98,7 @@ class NovelChapterListAdapter(
.start()
}

viewModel.viewModelScope.launch(Dispatchers.IO) {
holder.scope.launch(Dispatchers.IO) {
viewModel.getReadHistoryByVolume(groupPosition).collect {
withContext(Dispatchers.Main) {
if (it.isNullOrEmpty()) {
Expand Down Expand Up @@ -137,7 +148,7 @@ class NovelChapterListAdapter(
true
}

viewModel.viewModelScope.launch(Dispatchers.IO) {
holder.scope.launch(Dispatchers.IO) {
viewModel.getReadHistoryByCid(novel.volume[groupPosition].chapters[childPosition].cid).collect {
withContext(Dispatchers.Main) {
if (it == null) {
Expand All @@ -163,4 +174,14 @@ class NovelChapterListAdapter(
}
}
}

override fun onViewDetachedFromWindow(holder: ViewHolder) {
//终止协程,防止内存泄漏
when (holder) {
is GroupViewHolder -> holder.clean()
is ChildViewHolder -> holder.clean()
}
super.onViewDetachedFromWindow(holder)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import android.os.Bundle
import android.text.Html
import android.view.Menu
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.view.WindowCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.marginLeft
import androidx.core.view.marginRight
import androidx.core.view.marginTop
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
Expand All @@ -22,6 +27,7 @@ import com.cyh128.hikari_novel.ui.view.main.home.search.SearchActivity
import com.cyh128.hikari_novel.ui.view.other.PhotoViewActivity
import com.cyh128.hikari_novel.util.launchWithLifecycle
import com.cyh128.hikari_novel.util.openUrl
import com.cyh128.hikari_novel.util.setMargin
import com.cyh128.hikari_novel.util.startActivity
import com.drake.channel.receiveEvent
import com.google.android.material.dialog.MaterialAlertDialogBuilder
Expand All @@ -30,13 +36,28 @@ import kotlinx.coroutines.flow.last
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch


@AndroidEntryPoint
class NovelInfoActivity : BaseActivity<ActivityNovelInfoBinding>() {
private val viewModel by lazy { ViewModelProvider(this)[NovelInfoViewModel::class.java] }
private var chapterAdapter: NovelChapterListAdapter? = null

override fun onCreate(savedInstanceState: Bundle?) {
enableEdgeToEdge()

super.onCreate(savedInstanceState)

ViewCompat.setOnApplyWindowInsetsListener(binding.ervANovelInfo) { v, insets ->
val navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
v.setPadding(navigationBars.left, navigationBars.top, navigationBars.right, navigationBars.bottom)
insets
}//edgeToEdge
ViewCompat.setOnApplyWindowInsetsListener(binding.fabANovelInfo) { v, insets ->
val navigationBars = insets.getInsets(WindowInsetsCompat.Type.navigationBars())
v.setMargin(v.marginLeft, v.marginTop, v.marginRight, navigationBars.bottom)
insets
}//edgeToEdge

viewModel.aid = intent.getStringExtra("aid")!!

setSupportActionBar(binding.tbANovelInfo)
Expand Down Expand Up @@ -105,7 +126,11 @@ class NovelInfoActivity : BaseActivity<ActivityNovelInfoBinding>() {

override fun onDestroy() {
super.onDestroy()
chapterAdapter = null

//防止内存泄漏
binding.ervANovelInfo.adapter = null
binding.ervANovelInfo.setOnApplyWindowInsetsListener(null)
binding.fabANovelInfo.setOnApplyWindowInsetsListener(null)
}

private fun setInfoView() { //设置小说信息
Expand Down Expand Up @@ -170,7 +195,7 @@ class NovelInfoActivity : BaseActivity<ActivityNovelInfoBinding>() {
}

chapterAdapter = NovelChapterListAdapter(
viewModelStoreOwner = this@NovelInfoActivity,
viewModel = this@NovelInfoActivity.viewModel,
novel = viewModel.novel,
onItemClick = { volumePos: Int, chapterPos: Int ->
if (viewModel.readOrientation == ReaderOrientation.Vertical) {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/cyh128/hikari_novel/util/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.cyh128.hikari_novel.util
import android.content.Intent
import android.content.res.Configuration
import android.net.Uri
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -84,4 +87,10 @@ fun String.urlEncode(enc: String? = null): String {
Locale.TRADITIONAL_CHINESE -> URLEncoder.encode(this, "BIG5-HKSCS")
else -> URLEncoder.encode(this, "GBK")
}
}

fun View.setMargin(left: Int, top: Int, right: Int, bottom: Int) {
this.updateLayoutParams<ViewGroup.MarginLayoutParams> {
setMargins(left, top, right, bottom)
}
}
30 changes: 30 additions & 0 deletions app/src/main/res/drawable/applogo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M209.42,161.89C210.94,161.89 212.45,161.89 213.97,161.9C214.77,161.9 215.57,161.91 216.39,161.91C218.95,161.91 221.5,161.92 224.06,161.94C225.79,161.94 227.52,161.95 229.25,161.95C233.5,161.96 237.75,161.98 242,162C241.35,168.8 240.22,175.38 238.82,182.07C238.61,183.11 238.39,184.15 238.17,185.22C237.49,188.52 236.81,191.82 236.13,195.13C235.45,198.4 234.78,201.67 234.1,204.94C233.67,207.05 233.23,209.16 232.8,211.27C231.86,215.79 230.93,220.3 230.05,224.83C229.91,225.53 229.77,226.24 229.63,226.96C229.27,228.77 228.92,230.59 228.57,232.4C228,235 228,235 227,237C276.5,237.49 276.5,237.49 327,238C326.37,243.07 325.69,248 324.79,253.01C324.67,253.66 324.55,254.31 324.43,254.99C324.05,257.13 323.66,259.27 323.27,261.41C322.99,262.93 322.72,264.46 322.44,265.98C321.86,269.19 321.28,272.4 320.7,275.61C319.97,279.61 319.25,283.62 318.53,287.63C316.84,296.98 315.14,306.33 313.43,315.67C313.14,317.24 312.85,318.81 312.57,320.37C311.73,324.96 310.88,329.55 310.03,334.14C309.77,335.56 309.51,336.98 309.25,338.4C308.89,340.34 308.53,342.28 308.17,344.22C307.97,345.32 307.77,346.41 307.56,347.54C307,350 307,350 306,351C303.41,351.09 300.84,351.12 298.25,351.1C297.47,351.1 296.7,351.09 295.9,351.09C293.41,351.09 290.92,351.08 288.44,351.06C286.76,351.06 285.07,351.05 283.39,351.05C279.26,351.04 275.13,351.02 271,351C271.78,343.48 273.33,336.15 274.87,328.75C275.16,327.37 275.44,325.99 275.73,324.62C276.47,321 277.23,317.39 277.98,313.77C278.59,310.84 279.2,307.9 279.8,304.97C280.53,301.44 281.26,297.91 282,294.38C282.13,293.72 282.27,293.06 282.41,292.37C282.81,290.48 283.2,288.58 283.6,286.68C283.82,285.6 284.04,284.53 284.27,283.42C285.15,279.27 286.08,275.14 287,271C254.82,270.51 254.82,270.51 222,270C220.35,278.58 218.7,287.16 217,296C216.06,300.69 215.11,305.38 214.14,310.06C213.91,311.2 213.67,312.33 213.43,313.5C212.95,315.83 212.46,318.16 211.98,320.5C211.23,324.08 210.49,327.67 209.75,331.25C209.28,333.54 208.8,335.83 208.33,338.13C208.11,339.19 207.89,340.26 207.66,341.36C207.46,342.34 207.25,343.31 207.04,344.32C206.87,345.18 206.69,346.04 206.5,346.92C206,349 206,349 205,351C193.78,351 182.56,351 171,351C172.12,339.75 172.12,339.75 172.99,335.15C173.19,334.1 173.38,333.04 173.58,331.95C173.8,330.82 174.02,329.68 174.24,328.51C174.6,326.59 174.96,324.67 175.31,322.74C175.71,320.66 176.1,318.57 176.49,316.49C177.78,309.63 179.06,302.77 180.35,295.91C180.83,293.35 181.3,290.8 181.78,288.24C184.41,274.2 187,260.16 189.59,246.11C190.28,242.39 190.96,238.67 191.65,234.95C191.99,233.11 191.99,233.11 192.33,231.24C192.79,228.76 193.24,226.28 193.7,223.81C194.84,217.62 195.98,211.43 197.12,205.25C198.2,199.36 199.28,193.47 200.37,187.58C200.78,185.38 201.18,183.18 201.59,180.98C202.14,177.96 202.7,174.94 203.26,171.92C203.42,171.02 203.58,170.12 203.75,169.2C205.09,162.03 205.09,162.03 209.42,161.89Z"
android:fillColor="#191919"/>
<path
android:pathData="M308,162C319.22,162 330.44,162 342,162C340.87,172.13 340.87,172.13 339.91,176.92C339.59,178.52 339.59,178.52 339.26,180.15C338.92,181.83 338.92,181.83 338.57,183.55C338.33,184.73 338.09,185.9 337.85,187.12C337.34,189.59 336.84,192.06 336.33,194.53C335.56,198.32 334.8,202.1 334.04,205.89C333.55,208.3 333.06,210.71 332.57,213.11C332.34,214.25 332.11,215.38 331.88,216.54C331.66,217.6 331.44,218.65 331.22,219.73C331.03,220.65 330.85,221.58 330.65,222.53C330,225 330,225 328,229C317.44,229 306.88,229 296,229C297.13,218.87 297.13,218.87 298.02,213.98C298.21,212.89 298.41,211.8 298.61,210.67C298.82,209.52 299.03,208.38 299.25,207.2C299.47,205.99 299.69,204.79 299.91,203.56C300.37,201.03 300.83,198.51 301.29,195.99C302,192.12 302.7,188.25 303.41,184.38C303.85,181.92 304.3,179.46 304.75,177.01C304.96,175.85 305.17,174.69 305.39,173.49C305.58,172.42 305.78,171.35 305.98,170.25C306.16,169.3 306.33,168.36 306.51,167.39C307,165 307,165 308,162Z"
android:fillColor="#9E005D"/>
<path
android:pathData="M248,285C250.64,285 253.28,285 256,285C253.28,300.73 250.38,316.41 247.25,332.06C247.1,332.84 246.94,333.61 246.78,334.41C246.34,336.62 245.9,338.83 245.45,341.04C245.2,342.31 244.94,343.58 244.68,344.89C244,348 244,348 243,351C240.69,351 238.38,351 236,351C236.6,343.13 237.95,335.51 239.5,327.77C239.75,326.54 239.99,325.32 240.24,324.05C240.88,320.82 241.52,317.59 242.17,314.35C242.83,311.04 243.48,307.73 244.14,304.42C245.42,297.94 246.71,291.47 248,285Z"
android:fillColor="#B3B3B3"/>
<path
android:pathData="M230,285C232.31,285 234.62,285 237,285C236.29,292.55 234.96,299.91 233.5,307.35C233.25,308.6 233.01,309.85 232.76,311.14C232.12,314.44 231.48,317.74 230.83,321.04C230.17,324.42 229.52,327.8 228.86,331.18C227.58,337.79 226.29,344.39 225,351C222.69,351 220.38,351 218,351C217.66,343.76 218.94,337.12 220.37,330.04C220.61,328.81 220.85,327.59 221.1,326.32C221.74,323.08 222.39,319.84 223.04,316.61C223.57,313.96 224.09,311.31 224.62,308.65C225.24,305.49 225.87,302.33 226.5,299.16C226.73,297.97 226.97,296.79 227.21,295.56C227.43,294.46 227.65,293.37 227.88,292.24C228.07,291.27 228.26,290.31 228.46,289.31C229,287 229,287 230,285Z"
android:fillColor="#B3B3B3"/>
<path
android:pathData="M253,162C255.64,162 258.28,162 261,162C258.67,176.06 256.07,190.06 253.36,204.05C252.99,205.94 252.63,207.82 252.27,209.71C251.75,212.39 251.23,215.07 250.71,217.74C250.55,218.56 250.39,219.38 250.23,220.22C249.11,225.89 249.11,225.89 248,227C245.67,227.04 243.33,227.04 241,227C241.78,219.84 243.12,212.82 244.5,205.75C244.75,204.5 244.99,203.24 245.24,201.95C245.88,198.64 246.52,195.33 247.17,192.03C247.83,188.64 248.48,185.26 249.14,181.87C250.42,175.25 251.71,168.62 253,162Z"
android:fillColor="#B3B3B3"/>
<path
android:pathData="M267,285C269.31,285 271.62,285 274,285C273.4,292.87 272.05,300.49 270.5,308.23C270.13,310.07 270.13,310.07 269.76,311.95C269.12,315.18 268.48,318.41 267.83,321.65C267.17,324.96 266.52,328.27 265.86,331.58C264.58,338.06 263.29,344.53 262,351C259.36,351 256.72,351 254,351C256.68,336.29 259.44,321.6 262.28,306.93C262.59,305.31 262.91,303.69 263.22,302.07C263.66,299.79 264.1,297.5 264.55,295.22C264.68,294.53 264.81,293.85 264.95,293.14C265.49,290.35 266.1,287.7 267,285Z"
android:fillColor="#B3B3B3"/>
<path
android:pathData="M272,162C274.31,162 276.62,162 279,162C278.45,169.84 277.29,177.42 275.75,185.13C275.53,186.23 275.31,187.34 275.09,188.49C274.63,190.81 274.17,193.13 273.71,195.45C273,199.02 272.29,202.58 271.59,206.14C271.15,208.41 270.7,210.67 270.25,212.94C270.04,214 269.83,215.07 269.61,216.17C269.42,217.15 269.22,218.14 269.02,219.15C268.84,220.02 268.67,220.88 268.49,221.78C268,224 268,224 267,227C264.69,227 262.38,227 260,227C260.6,219.47 261.8,212.16 263.25,204.75C263.47,203.62 263.69,202.49 263.91,201.32C264.37,198.94 264.83,196.57 265.29,194.19C266,190.55 266.7,186.9 267.41,183.26C267.85,180.95 268.3,178.63 268.75,176.32C268.96,175.23 269.17,174.14 269.39,173.01C269.58,172 269.78,170.99 269.98,169.96C270.16,169.07 270.33,168.18 270.51,167.27C271,165 271,165 272,162Z"
android:fillColor="#B3B3B3"/>
<path
android:pathData="M294.06,161.94C295.52,161.97 295.52,161.97 297,162C297.35,169.33 296.02,176.08 294.59,183.25C294.35,184.5 294.11,185.76 293.85,187.05C293.21,190.36 292.56,193.67 291.9,196.97C291.23,200.36 290.57,203.74 289.91,207.13C288.61,213.75 287.31,220.38 286,227C283.36,227 280.72,227 278,227C280.33,212.94 282.93,198.94 285.64,184.95C286.01,183.06 286.37,181.18 286.73,179.29C287.25,176.61 287.77,173.93 288.29,171.26C288.45,170.44 288.61,169.62 288.77,168.78C290.1,162.02 290.1,162.02 294.06,161.94Z"
android:fillColor="#B3B3B3"/>
</vector>
Loading

0 comments on commit d328429

Please sign in to comment.