diff --git a/app/src/main/assets/updateLog.md b/app/src/main/assets/updateLog.md index 87ba8e640..12171a213 100644 --- a/app/src/main/assets/updateLog.md +++ b/app/src/main/assets/updateLog.md @@ -4,6 +4,9 @@ * 先在旧版阅读(2.x)中进行备份,然后在新版阅读(3.x)【我的】->【备份与恢复】,选择【导入旧版本数据】,提示存储权限,选择允许即可导入成功。 * 注意:由于安卓10更改了权限策略,还需要给「允许安装其他应用」的权限才能导入源。MIUI11也需要此权限。 +**2019/12/23** +* 修复每次打开翻页模式恢复默认的bug + **2019/12/22** * 更新音频播放界面 diff --git a/app/src/main/java/io/legado/app/App.kt b/app/src/main/java/io/legado/app/App.kt index 1b757bde7..ee3e4f5f6 100644 --- a/app/src/main/java/io/legado/app/App.kt +++ b/app/src/main/java/io/legado/app/App.kt @@ -18,7 +18,7 @@ import io.legado.app.help.ActivityHelp import io.legado.app.help.CrashHandler import io.legado.app.help.ReadBookConfig import io.legado.app.lib.theme.ThemeStore -import io.legado.app.ui.widget.page.ChapterProvider +import io.legado.app.ui.book.read.page.ChapterProvider import io.legado.app.utils.getCompatColor import io.legado.app.utils.getPrefInt import io.legado.app.utils.isNightTheme diff --git a/app/src/main/java/io/legado/app/constant/PreferKey.kt b/app/src/main/java/io/legado/app/constant/PreferKey.kt index d4f54bb5d..4217e376d 100644 --- a/app/src/main/java/io/legado/app/constant/PreferKey.kt +++ b/app/src/main/java/io/legado/app/constant/PreferKey.kt @@ -14,4 +14,5 @@ object PreferKey { const val processText = "process_text" const val cleanCache = "cleanCache" const val lastGroup = "lastGroup" + const val pageAnim = "pageAnim" } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/help/ActivityHelp.kt b/app/src/main/java/io/legado/app/help/ActivityHelp.kt index fa15510f7..ca7c20f5f 100644 --- a/app/src/main/java/io/legado/app/help/ActivityHelp.kt +++ b/app/src/main/java/io/legado/app/help/ActivityHelp.kt @@ -1,7 +1,6 @@ package io.legado.app.help import android.app.Activity -import io.legado.app.utils.LogUtils import java.lang.ref.WeakReference import java.util.* @@ -13,7 +12,6 @@ object ActivityHelp { private val activities: MutableList> = arrayListOf() fun size(): Int { - LogUtils.d("xxxx", activities.size.toString()) return activities.size } diff --git a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt index 7f3cbb34e..c657f621e 100644 --- a/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt +++ b/app/src/main/java/io/legado/app/service/BaseReadAloudService.kt @@ -26,7 +26,7 @@ import io.legado.app.help.MediaHelp import io.legado.app.receiver.MediaButtonReceiver import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.ReadBookActivity -import io.legado.app.ui.widget.page.TextChapter +import io.legado.app.ui.book.read.page.TextChapter import io.legado.app.utils.getPrefBoolean import io.legado.app.utils.postEvent diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 7603c0ab3..451883b55 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -11,8 +11,8 @@ import io.legado.app.help.IntentDataHelp import io.legado.app.help.coroutine.Coroutine import io.legado.app.model.WebBook import io.legado.app.service.BaseReadAloudService -import io.legado.app.ui.widget.page.ChapterProvider -import io.legado.app.ui.widget.page.TextChapter +import io.legado.app.ui.book.read.page.ChapterProvider +import io.legado.app.ui.book.read.page.TextChapter import kotlinx.coroutines.* import kotlinx.coroutines.Dispatchers.Main diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index c166d4b96..fdc95233d 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -29,14 +29,14 @@ import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.config.* import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.BG_COLOR import io.legado.app.ui.book.read.config.BgTextConfigDialog.Companion.TEXT_COLOR +import io.legado.app.ui.book.read.page.ChapterProvider +import io.legado.app.ui.book.read.page.PageView +import io.legado.app.ui.book.read.page.delegate.PageDelegate import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.changesource.ChangeSourceDialog import io.legado.app.ui.chapterlist.ChapterListActivity import io.legado.app.ui.replacerule.ReplaceRuleActivity import io.legado.app.ui.replacerule.edit.ReplaceEditDialog -import io.legado.app.ui.widget.page.ChapterProvider -import io.legado.app.ui.widget.page.PageView -import io.legado.app.ui.widget.page.delegate.PageDelegate import io.legado.app.utils.* import kotlinx.android.synthetic.main.activity_book_read.* import kotlinx.android.synthetic.main.dialog_download_choice.view.* diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt index a816677f0..ea050dac8 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt @@ -11,6 +11,7 @@ import androidx.core.view.get import androidx.fragment.app.DialogFragment import io.legado.app.R import io.legado.app.constant.Bus +import io.legado.app.constant.PreferKey import io.legado.app.help.ImageLoader import io.legado.app.help.ReadBookConfig import io.legado.app.lib.dialogs.selector @@ -66,7 +67,7 @@ class ReadStyleDialog : DialogFragment() { } private fun initData() { - requireContext().getPrefInt("pageAnim").let { + requireContext().getPrefInt(PreferKey.pageAnim).let { if (it >= 0 && it < rg_page_anim.childCount) { rg_page_anim.check(rg_page_anim[it].id) } @@ -179,7 +180,7 @@ class ReadStyleDialog : DialogFragment() { rg_page_anim.onCheckedChange { _, checkedId -> for (i in 0 until rg_page_anim.childCount) { if (checkedId == rg_page_anim[i].id) { - requireContext().putPrefInt("pageAnim", i) + requireContext().putPrefInt(PreferKey.pageAnim, i) val activity = activity if (activity is ReadBookActivity) { activity.page_view.upPageAnim(i) diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt similarity index 98% rename from app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt index 25b68e6c3..63cc6748d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ChapterProvider.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.text.Spannable import android.text.SpannableStringBuilder diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentSelectActionCallback.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentSelectActionCallback.kt similarity index 96% rename from app/src/main/java/io/legado/app/ui/widget/page/ContentSelectActionCallback.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/ContentSelectActionCallback.kt index 76a4b669a..cfce5f27b 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentSelectActionCallback.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentSelectActionCallback.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.view.ActionMode import android.view.Menu diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt similarity index 99% rename from app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt index 3a73c3227..190e31ac9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.annotation.SuppressLint import android.content.Context diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt similarity index 95% rename from app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt index 4f371949d..41d4b937f 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.annotation.SuppressLint import android.content.Context @@ -133,7 +133,9 @@ class ContentView : FrameLayout { fun scrollTo(pos: Int?) { if (pos != null) { content_text_view.post { - content_text_view.scrollTo(0, content_text_view.layout.getLineTop(pos)) + if (content_text_view.layout.lineCount >= pos) { + content_text_view.scrollTo(0, content_text_view.layout.getLineTop(pos)) + } } } } diff --git a/app/src/main/java/io/legado/app/ui/widget/page/DataSource.kt b/app/src/main/java/io/legado/app/ui/book/read/page/DataSource.kt similarity index 89% rename from app/src/main/java/io/legado/app/ui/widget/page/DataSource.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/DataSource.kt index d7efe18a5..7c93e52c2 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/DataSource.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/DataSource.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page interface DataSource { val isScrollDelegate: Boolean diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageFactory.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageFactory.kt similarity index 90% rename from app/src/main/java/io/legado/app/ui/widget/page/PageFactory.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/PageFactory.kt index 72eaa5eda..6f39f2992 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/PageFactory.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageFactory.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page abstract class PageFactory(protected val dataSource: DataSource) { diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt similarity index 95% rename from app/src/main/java/io/legado/app/ui/widget/page/PageView.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 4dc4193f8..9d17e0f18 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.annotation.SuppressLint import android.content.Context @@ -6,11 +6,13 @@ import android.graphics.Canvas import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout +import io.legado.app.constant.PreferKey import io.legado.app.help.ReadBookConfig import io.legado.app.service.help.ReadBook -import io.legado.app.ui.widget.page.curl.CurlView -import io.legado.app.ui.widget.page.delegate.* +import io.legado.app.ui.book.read.page.curl.CurlView +import io.legado.app.ui.book.read.page.delegate.* import io.legado.app.utils.activity +import io.legado.app.utils.getPrefInt class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), @@ -37,7 +39,7 @@ class PageView(context: Context, attrs: AttributeSet) : upBg() setWillNotDraw(false) pageFactory = TextPageFactory(this) - upPageAnim() + upPageAnim(context.getPrefInt(PreferKey.pageAnim)) curPage?.callBack = this } @@ -88,7 +90,7 @@ class PageView(context: Context, attrs: AttributeSet) : } } - fun upPageAnim(pageAnim: Int = 0) { + fun upPageAnim(pageAnim: Int) { if (curlView != null) { removeView(curlView) curlView = null diff --git a/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt b/app/src/main/java/io/legado/app/ui/book/read/page/TextChapter.kt similarity index 98% rename from app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/TextChapter.kt index d9c57c4ce..a4dacac60 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/TextChapter.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.text.SpannableStringBuilder import kotlin.math.min diff --git a/app/src/main/java/io/legado/app/ui/widget/page/TextPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/TextPage.kt similarity index 96% rename from app/src/main/java/io/legado/app/ui/widget/page/TextPage.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/TextPage.kt index 44f47d098..4950bf68a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/TextPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/TextPage.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import android.text.Spannable import android.text.SpannableStringBuilder diff --git a/app/src/main/java/io/legado/app/ui/widget/page/TextPageFactory.kt b/app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt similarity index 98% rename from app/src/main/java/io/legado/app/ui/widget/page/TextPageFactory.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt index d5aaa68d7..8423d04ab 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/TextPageFactory.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/TextPageFactory.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page +package io.legado.app.ui.book.read.page import io.legado.app.service.help.ReadBook diff --git a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlMesh.java b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlMesh.java similarity index 99% rename from app/src/main/java/io/legado/app/ui/widget/page/curl/CurlMesh.java rename to app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlMesh.java index f0e5a3fff..65ddbc363 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlMesh.java +++ b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlMesh.java @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page.curl; +package io.legado.app.ui.book.read.page.curl; import android.graphics.Bitmap; import android.graphics.Color; diff --git a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlPage.kt b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlPage.kt similarity index 99% rename from app/src/main/java/io/legado/app/ui/widget/page/curl/CurlPage.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlPage.kt index 5f6ad5bb1..88f2fb16c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlPage.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlPage.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page.curl +package io.legado.app.ui.book.read.page.curl import android.graphics.Bitmap import android.graphics.Canvas diff --git a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlRenderer.kt b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlRenderer.kt similarity index 99% rename from app/src/main/java/io/legado/app/ui/widget/page/curl/CurlRenderer.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlRenderer.kt index aeec2472b..6d44ee1ee 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlRenderer.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlRenderer.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page.curl +package io.legado.app.ui.book.read.page.curl import android.graphics.Color import android.graphics.PointF diff --git a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlView.kt similarity index 99% rename from app/src/main/java/io/legado/app/ui/widget/page/curl/CurlView.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlView.kt index 1124d71d0..ecd5d410d 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/curl/CurlView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/curl/CurlView.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page.curl +package io.legado.app.ui.book.read.page.curl import android.content.Context import android.graphics.PixelFormat diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/CoverPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt similarity index 96% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/CoverPageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt index 10ac07abd..c30affba3 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/CoverPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/CoverPageDelegate.kt @@ -1,9 +1,9 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.graphics.Canvas import android.graphics.Matrix import android.graphics.drawable.GradientDrawable -import io.legado.app.ui.widget.page.PageView +import io.legado.app.ui.book.read.page.PageView class CoverPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/EventExtensions.kt similarity index 86% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/EventExtensions.kt index 99916e27a..05d6b28a3 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/EventExtensions.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.view.MotionEvent diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/HorizontalPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt similarity index 94% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/HorizontalPageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt index 1f2b3fa42..ef43b929e 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/HorizontalPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/HorizontalPageDelegate.kt @@ -1,7 +1,7 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.view.MotionEvent -import io.legado.app.ui.widget.page.PageView +import io.legado.app.ui.book.read.page.PageView import io.legado.app.utils.screenshot import kotlin.math.abs diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/NoAnimPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt similarity index 78% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/NoAnimPageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt index 7008455b8..8837698d0 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/NoAnimPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/NoAnimPageDelegate.kt @@ -1,7 +1,7 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.graphics.Canvas -import io.legado.app.ui.widget.page.PageView +import io.legado.app.ui.book.read.page.PageView class NoAnimPageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { override fun onScrollStart() { diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt similarity index 98% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 0c6585df8..c9e0ca546 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -1,4 +1,4 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.graphics.Bitmap import android.graphics.Canvas @@ -9,8 +9,8 @@ import android.widget.Scroller import androidx.annotation.CallSuper import androidx.interpolator.view.animation.FastOutLinearInInterpolator import com.google.android.material.snackbar.Snackbar -import io.legado.app.ui.widget.page.ContentView -import io.legado.app.ui.widget.page.PageView +import io.legado.app.ui.book.read.page.ContentView +import io.legado.app.ui.book.read.page.PageView import io.legado.app.utils.screenshot import io.legado.app.utils.snackbar import kotlin.math.abs diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt similarity index 97% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/ScrollPageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index 4e333bd1c..bf8a51a02 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -1,9 +1,9 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.graphics.Canvas import android.graphics.Matrix import android.view.MotionEvent -import io.legado.app.ui.widget.page.PageView +import io.legado.app.ui.book.read.page.PageView import io.legado.app.utils.screenshot import kotlin.math.abs diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/SimulationPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt similarity index 94% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/SimulationPageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt index a83d548a2..eb58e616c 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/SimulationPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SimulationPageDelegate.kt @@ -1,10 +1,10 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.graphics.Canvas import android.view.MotionEvent -import io.legado.app.ui.widget.page.PageView -import io.legado.app.ui.widget.page.curl.CurlPage -import io.legado.app.ui.widget.page.curl.CurlView +import io.legado.app.ui.book.read.page.PageView +import io.legado.app.ui.book.read.page.curl.CurlPage +import io.legado.app.ui.book.read.page.curl.CurlView import io.legado.app.utils.screenshot import kotlin.math.abs diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/SlidePageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt similarity index 94% rename from app/src/main/java/io/legado/app/ui/widget/page/delegate/SlidePageDelegate.kt rename to app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt index 2615976e6..24c0781d7 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/SlidePageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/SlidePageDelegate.kt @@ -1,8 +1,8 @@ -package io.legado.app.ui.widget.page.delegate +package io.legado.app.ui.book.read.page.delegate import android.graphics.Canvas import android.graphics.Matrix -import io.legado.app.ui.widget.page.PageView +import io.legado.app.ui.book.read.page.PageView class SlidePageDelegate(pageView: PageView) : HorizontalPageDelegate(pageView) { diff --git a/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt b/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt index 72356b869..2ae90c8a5 100644 --- a/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt +++ b/app/src/main/java/io/legado/app/ui/download/DownloadActivity.kt @@ -1,16 +1,35 @@ package io.legado.app.ui.download import android.os.Bundle +import androidx.lifecycle.LiveData +import androidx.lifecycle.Observer +import androidx.recyclerview.widget.LinearLayoutManager import io.legado.app.R import io.legado.app.base.BaseActivity +import io.legado.app.data.entities.Book +import kotlinx.android.synthetic.main.activity_download.* class DownloadActivity : BaseActivity(R.layout.activity_download) { + lateinit var adapter: DownloadAdapter + private var bookshelfLiveData: LiveData>? = null override fun onActivityCreated(savedInstanceState: Bundle?) { - + initRecyclerView() + initLiveData() } + private fun initRecyclerView() { + recycler_view.layoutManager = LinearLayoutManager(this) + adapter = DownloadAdapter(this) + recycler_view.adapter = adapter + } + private fun initLiveData() { + bookshelfLiveData?.removeObservers(this) + bookshelfLiveData?.observe(this, Observer { + adapter.setItems(it) + }) + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt b/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt new file mode 100644 index 000000000..8407633ff --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt @@ -0,0 +1,18 @@ +package io.legado.app.ui.download + +import android.content.Context +import io.legado.app.R +import io.legado.app.base.adapter.ItemViewHolder +import io.legado.app.base.adapter.SimpleRecyclerAdapter +import io.legado.app.data.entities.Book + + +class DownloadAdapter(context: Context) : + SimpleRecyclerAdapter(context, R.layout.item_download) { + + + override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList) { + + } + +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_book_read.xml b/app/src/main/res/layout/activity_book_read.xml index 1d86c11d0..245e4ac49 100644 --- a/app/src/main/res/layout/activity_book_read.xml +++ b/app/src/main/res/layout/activity_book_read.xml @@ -4,13 +4,13 @@ android:layout_height="match_parent" android:orientation="vertical"> - - diff --git a/app/src/main/res/layout/activity_download.xml b/app/src/main/res/layout/activity_download.xml index d829e291c..2f7ebd6f2 100644 --- a/app/src/main/res/layout/activity_download.xml +++ b/app/src/main/res/layout/activity_download.xml @@ -1,7 +1,19 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_download.xml b/app/src/main/res/layout/item_download.xml new file mode 100644 index 000000000..d829e291c --- /dev/null +++ b/app/src/main/res/layout/item_download.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index d6ad84daf..410efe662 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -27,7 +27,7 @@ -