feat: 优化代码

pull/165/head
kunfei 5 years ago
parent 3b33b12bd0
commit 93de67f4ff
  1. 7
      app/src/main/java/io/legado/app/service/help/ReadBook.kt
  2. 12
      app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt
  3. 52
      app/src/main/res/drawable/ic_launcher1_b.xml
  4. BIN
      app/src/main/res/mipmap-hdpi/ic_launcher.png
  5. BIN
      app/src/main/res/mipmap-mdpi/ic_launcher.png
  6. BIN
      app/src/main/res/mipmap-xhdpi/ic_launcher.png
  7. BIN
      app/src/main/res/mipmap-xxhdpi/ic_launcher.png
  8. BIN
      app/src/main/res/mipmap-xxxhdpi/ic_launcher.png

@ -33,7 +33,7 @@ object ReadBook {
var curTextChapter: TextChapter? = null var curTextChapter: TextChapter? = null
var nextTextChapter: TextChapter? = null var nextTextChapter: TextChapter? = null
var webBook: WebBook? = null var webBook: WebBook? = null
var msg: String? = null private var msg: String? = null
private val loadingChapters = arrayListOf<Int>() private val loadingChapters = arrayListOf<Int>()
fun resetData(book: Book, noSource: (name: String, author: String) -> Unit) { fun resetData(book: Book, noSource: (name: String, author: String) -> Unit) {
@ -64,6 +64,11 @@ object ReadBook {
} }
} }
fun upMsg(msg: String?) {
this.msg = msg
callBack?.upContent()
}
fun moveToNextPage() { fun moveToNextPage() {
durPageIndex++ durPageIndex++
callBack?.upContent() callBack?.upContent()

@ -117,15 +117,16 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
App.db.bookChapterDao().insert(*cList.toTypedArray()) App.db.bookChapterDao().insert(*cList.toTypedArray())
App.db.bookDao().update(book) App.db.bookDao().update(book)
ReadBook.chapterSize = cList.size ReadBook.chapterSize = cList.size
ReadBook.upMsg(null)
ReadBook.loadContent(resetPageOffset = true) ReadBook.loadContent(resetPageOffset = true)
} else { } else {
changeDruChapterIndex(cList) changeDruChapterIndex(cList)
} }
} else { } else {
toast(R.string.error_load_toc) ReadBook.upMsg(context.getString(R.string.error_load_toc))
} }
}?.onError { }?.onError {
toast(R.string.error_load_toc) ReadBook.upMsg(context.getString(R.string.error_load_toc))
} }
} }
} }
@ -133,6 +134,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun changeTo(book1: Book) { fun changeTo(book1: Book) {
execute { execute {
ReadBook.upMsg(null)
ReadBook.book?.let { ReadBook.book?.let {
App.db.bookDao().delete(it) App.db.bookDao().delete(it)
} }
@ -171,11 +173,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
} }
} }
}.onStart { }.onStart {
ReadBook.msg = "正在自动换源" ReadBook.upMsg("正在自动换源")
ReadBook.callBack?.upContent()
}.onFinally { }.onFinally {
ReadBook.msg = null ReadBook.upMsg(null)
ReadBook.callBack?.upContent()
} }
} }

@ -7,49 +7,49 @@
<path <path
android:pathData="M0,0h108v108h-108z" android:pathData="M0,0h108v108h-108z"
android:fillColor="#4d4d4d" /> android:fillColor="#4d4d4d" />
<path android:pathData="M0,108H54V65c0,-12 -54,-5 -54,-5Z"> <path android:pathData="M0,108H54V65c0,-12 -54,-5 -54,-5Z">
<aapt:attr name="android:fillColor"> <aapt:attr name="android:fillColor">
<gradient <gradient
android:startY="79.9" android:startY="79.9"
android:startX="0.62" android:startX="0.62"
android:endY="88.57" android:endY="88.57"
android:endX="53.06" android:endX="53.06"
android:type="linear"> android:type="linear">
<item <item
android:offset="0" android:offset="0"
android:color="#FFFFFFFF" /> android:color="#FFFFFFFF" />
<item <item
android:offset="1" android:offset="1"
android:color="#FFCCCCCC" /> android:color="#FFCCCCCC" />
</gradient> </gradient>
</aapt:attr> </aapt:attr>
</path> </path>
<path <path
android:pathData="M108,108H54V65c0,-12 54,-5 54,-5Z" android:pathData="M108,108H54V65c0,-12 54,-5 54,-5Z"
android:fillColor="#fff" /> android:fillColor="#f2f2f2" />
<path android:pathData="M71.5,69 L78,75V58a94.89,94.89 0,0 0,-13 0.75V75Z"> <path android:pathData="M71.5,69 L78,75V58a94.89,94.89 0,0 0,-13 0.75V75Z">
<aapt:attr name="android:fillColor"> <aapt:attr name="android:fillColor">
<gradient <gradient
android:startY="58.1" android:startY="58.1"
android:startX="71.5" android:startX="71.5"
android:endY="75" android:endY="75"
android:endX="71.5" android:endX="71.5"
android:type="linear"> android:type="linear">
<item <item
android:offset="0" android:offset="0"
android:color="#FFFFFFFF" /> android:color="#FFFFFFFF" />
<item <item
android:offset="0.24" android:offset="0.24"
android:color="#FFFFE1DD" /> android:color="#FFFFE1DD" />
<item <item
android:offset="0.58" android:offset="0.58"
android:color="#FFFFBEB6" /> android:color="#FFFFBEB6" />
<item <item
android:offset="0.84" android:offset="0.84"
android:color="#FFFFA89D" /> android:color="#FFFFA89D" />
<item <item
android:offset="1" android:offset="1"
android:color="#FFFFA094" /> android:color="#FFFFA094" />
</gradient> </gradient>
</aapt:attr> </aapt:attr>
</path> </path>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Loading…
Cancel
Save