Skip to content

Commit 0d4eb3c

Browse files
committed
1.替换繁简转换jar包
2.优化包体积。
1 parent 2dd625a commit 0d4eb3c

File tree

13 files changed

+36
-45
lines changed

13 files changed

+36
-45
lines changed

app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ dependencies {
138138
implementation 'io.noties.markwon:core:4.6.0'
139139
implementation 'io.noties.markwon:image-glide:4.6.0'
140140
//转换繁体
141-
implementation 'com.hankcs:hanlp:portable-1.7.8'
142-
141+
implementation files('libs/ZHConverter.jar')
143142
//brvah
144143
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.6'
145144

app/libs/ZHConverter.jar

103 KB
Binary file not shown.

app/proguard-rules.pro

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@
215215
public static ** valueOf(java.lang.String);
216216
}
217217

218-
219-
-keep class com.burst.k17reader_sdk.** { *; }
220-
-keep class com.chineseall.reader.utils.** { *; }
221-
222218
-keep class org.litepal.** { *;}
223219
-keep class * extends org.litepal.crud.DataSupport { *;}
224220
-keep class * extends org.litepal.crud.LitePalSupport { *;}
@@ -230,7 +226,4 @@
230226
public static ** valueOf(java.lang.String);
231227
}
232228

233-
-dontwarn com.youth.banner.**
234-
-keep class com.youth.banner.**{*;}
235-
236-
-keep class com.android.vending.billing.**
229+
-keep class com.spreada.utils.chinese.**

app/src/main/java/com/novel/read/App.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import android.provider.Settings
99
import androidx.annotation.RequiresApi
1010
import androidx.appcompat.app.AppCompatDelegate
1111
import androidx.multidex.MultiDexApplication
12+
import com.bumptech.glide.Glide
1213
import com.jeremyliao.liveeventbus.LiveEventBus
1314
import com.novel.read.constant.AppConst.channelIdDownload
1415
import com.novel.read.constant.AppConst.channelIdReadAloud
@@ -120,4 +121,18 @@ class App : MultiDexApplication() {
120121
}
121122
}
122123

124+
125+
override fun onLowMemory() {
126+
super.onLowMemory()
127+
Glide.get(this).clearMemory()
128+
}
129+
130+
override fun onTrimMemory(level: Int) {
131+
super.onTrimMemory(level)
132+
if (level == TRIM_MEMORY_UI_HIDDEN) {
133+
Glide.get(this).clearMemory()
134+
}
135+
Glide.get(this).trimMemory(level)
136+
}
137+
123138
}

app/src/main/java/com/novel/read/constant/PreferKey.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ object PreferKey {
1414
const val ttsSpeechRate = "ttsSpeechRate"
1515
const val prevKeys = "prevKeyCodes"
1616
const val nextKeys = "nextKeyCodes"
17-
const val showRss = "showRss"
1817
const val bookshelfLayout = "bookshelfLayout"
1918
const val bookshelfSort = "bookshelfSort"
2019
const val recordLog = "recordLog"

app/src/main/java/com/novel/read/help/AppConfig.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ object AppConfig {
5555
}
5656
}
5757

58-
val autoRefreshBook: Boolean
59-
get() = App.INSTANCE.getPrefBoolean(R.string.pk_auto_refresh)
60-
6158
var threadCount: Int
6259
get() = App.INSTANCE.getPrefInt(PreferKey.threadCount, 16)
6360
set(value) {
@@ -83,7 +80,7 @@ object AppConfig {
8380
val clickAllNext: Boolean get() = App.INSTANCE.getPrefBoolean(PreferKey.clickAllNext, false)
8481

8582
var chineseConverterType: Int
86-
get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType,2)
83+
get() = App.INSTANCE.getPrefInt(PreferKey.chineseConverterType,1)
8784
set(value) {
8885
App.INSTANCE.putPrefInt(PreferKey.chineseConverterType, value)
8986
}

app/src/main/java/com/novel/read/help/BookHelp.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.novel.read.help
22

33
import android.util.Log
4-
import com.hankcs.hanlp.HanLP
54
import com.novel.read.App
65
import com.novel.read.constant.AppPattern
76
import com.novel.read.constant.EventBus
@@ -14,6 +13,7 @@ import com.novel.read.utils.ext.*
1413
import com.novel.read.help.coroutine.Coroutine
1514
import com.novel.read.network.repository.ImageRepository
1615
import com.novel.read.utils.NetworkUtils
16+
import com.spreada.utils.chinese.ZHConverter
1717
import kotlinx.coroutines.Dispatchers.Main
1818
import kotlinx.coroutines.delay
1919
import kotlinx.coroutines.withContext
@@ -367,12 +367,12 @@ object BookHelp {
367367
try {
368368
when (AppConfig.chineseConverterType) {
369369
1 -> {
370-
title1 = HanLP.convertToSimplifiedChinese(title1)
371-
content1 = HanLP.convertToSimplifiedChinese(content1)
370+
title1=ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(title1)
371+
content1=ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(content1)
372372
}
373373
2 -> {
374-
title1 = HanLP.convertToTraditionalChinese(title1)
375-
content1 = HanLP.convertToTraditionalChinese(content1)
374+
title1=ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(title1)
375+
content1=ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(content1)
376376
}
377377
}
378378
} catch (e: Exception) {

app/src/main/java/com/novel/read/network/repository/SearchRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.novel.read.network.repository
22

3-
import com.hankcs.hanlp.HanLP
43
import com.novel.read.network.ServiceCreator
54
import com.novel.read.utils.ext.GSON
5+
import com.spreada.utils.chinese.ZHConverter
66
import kotlinx.coroutines.Dispatchers
77
import kotlinx.coroutines.withContext
88
import okhttp3.MediaType
@@ -14,7 +14,7 @@ class SearchRepository {
1414

1515
suspend fun searchBook(page: Int, pageSize: Int, key: String) = withContext(Dispatchers.IO) {
1616
val map = HashMap<String, String>()
17-
val key1 = HanLP.convertToSimplifiedChinese(key)
17+
val key1 = ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(key)
1818
map["pageNum"] = page.toString()
1919
map["pageSize"] = pageSize.toString()
2020
map["searchTerms"] = key1

app/src/main/java/com/novel/read/service/help/ReadBook.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package com.novel.read.service.help
22

33
import androidx.lifecycle.MutableLiveData
4-
import com.hankcs.hanlp.HanLP
54
import com.novel.read.App
6-
import com.novel.read.constant.AppConst
75
import com.novel.read.constant.BookType
86
import com.novel.read.data.db.entity.Book
97
import com.novel.read.data.db.entity.BookChapter
@@ -16,6 +14,7 @@ import com.novel.read.help.IntentDataHelp
1614
import com.novel.read.help.ReadBookConfig
1715
import com.novel.read.service.BaseReadAloudService
1816
import com.novel.read.help.coroutine.Coroutine
17+
import com.spreada.utils.chinese.ZHConverter
1918
import io.legado.app.ui.book.read.page.provider.ChapterProvider
2019
import io.legado.app.ui.book.read.page.provider.ImageProvider
2120
import kotlinx.coroutines.Dispatchers
@@ -25,7 +24,6 @@ import kotlinx.coroutines.launch
2524
import org.jetbrains.anko.getStackTraceString
2625
import org.jetbrains.anko.toast
2726

28-
2927
object ReadBook {
3028
var titleDate = MutableLiveData<String>()
3129
var book: Book? = null
@@ -354,8 +352,8 @@ object ReadBook {
354352
Coroutine.async {
355353
if (chapter.chapterIndex in durChapterIndex - 1..durChapterIndex + 1) {
356354
chapter.chapterName = when (AppConfig.chineseConverterType) {
357-
1 -> HanLP.convertToSimplifiedChinese(chapter.chapterName)
358-
2 -> HanLP.convertToTraditionalChinese(chapter.chapterName)
355+
1 -> ZHConverter.getInstance(ZHConverter.SIMPLIFIED).convert(chapter.chapterName)
356+
2 -> ZHConverter.getInstance(ZHConverter.TRADITIONAL).convert(chapter.chapterName)
359357
else -> chapter.chapterName
360358
}
361359
val contents = BookHelp.disposeContent(

app/src/main/java/com/novel/read/ui/main/mail/MailViewModel.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ import com.novel.read.network.repository.HomeRepository
99

1010
class MailViewModel(application: Application) : BaseViewModel(application) {
1111
private val homeRepository by lazy { HomeRepository() }
12+
1213
var homeResp = MutableLiveData<HomeResp>()
1314
val refreshStatus = MutableLiveData<Int>()
15+
1416
fun getAll() {
1517
refreshStatus.value = AppConst.loading
1618
launch(block = {
1719
homeResp.value = homeRepository.getHomeBook(AppConst.home)
1820
refreshStatus.value = AppConst.complete
1921
}, error = {
2022
refreshStatus.value = AppConst.error
21-
},showErrorToast = false)
23+
}, showErrorToast = false)
2224
}
25+
2326
}

0 commit comments

Comments
 (0)