From 2546c4fa5b030eec261f4a852e617d57681db92b Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Thu, 11 Aug 2022 22:02:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=8E=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E4=B8=AD=E8=AF=BB=E5=8F=96=E7=AB=A0=E8=8A=82=E6=97=B6?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=95=B0=E6=8D=AE=E9=A1=B9=E7=BC=BA=E5=A4=B1?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../greendao/service/ChapterService.java | 11 +++++-- .../java/xyz/fycz/dynamic/fix/App250Fix.kt | 33 ++++++++++++++++++- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/xyz/fycz/myreader/greendao/service/ChapterService.java b/app/src/main/java/xyz/fycz/myreader/greendao/service/ChapterService.java index 20e1bbd..2385020 100644 --- a/app/src/main/java/xyz/fycz/myreader/greendao/service/ChapterService.java +++ b/app/src/main/java/xyz/fycz/myreader/greendao/service/ChapterService.java @@ -66,6 +66,7 @@ public class ChapterService extends BaseService { chapter.setContent(cursor.getString(8)); chapter.setStart(cursor.getInt(9)); chapter.setEnd(cursor.getInt(10)); + chapter.setVariable(cursor.getString(11)); chapters.add(chapter); } } catch (Exception e) { @@ -95,10 +96,14 @@ public class ChapterService extends BaseService { if (StringHelper.isEmpty(bookId)) return new ArrayList<>(); + return DbManager.getDaoSession().getChapterDao() + .queryBuilder() + .where(ChapterDao.Properties.BookId.eq(bookId)) + .orderAsc(ChapterDao.Properties.Number) + .list(); + /*String sql = "select * from chapter where book_id = ? order by number"; - String sql = "select * from chapter where book_id = ? order by number"; - - return findChapters(sql, new String[]{bookId}); + return findChapters(sql, new String[]{bookId});*/ } /** diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/fix/App250Fix.kt b/dynamic/src/main/java/xyz/fycz/dynamic/fix/App250Fix.kt index dfc2efb..924e95c 100644 --- a/dynamic/src/main/java/xyz/fycz/dynamic/fix/App250Fix.kt +++ b/dynamic/src/main/java/xyz/fycz/dynamic/fix/App250Fix.kt @@ -23,18 +23,49 @@ import androidx.viewbinding.ViewBinding import me.fycz.maple.MapleBridge import me.fycz.maple.MapleUtils import me.fycz.maple.MethodReplacement +import xyz.fycz.myreader.greendao.DbManager +import xyz.fycz.myreader.greendao.entity.Chapter +import xyz.fycz.myreader.greendao.gen.ChapterDao +import xyz.fycz.myreader.greendao.service.ChapterService import xyz.fycz.myreader.ui.activity.BookDetailedActivity /** * @author fengyue * @date 2022/8/11 16:44 */ -@AppFix([243, 244, 245, 246, 250], ["[书籍详情界面]取消书籍简介展开时最大行数限制(无法显示完全)"], "2022-08-11") +@AppFix( + [243, 244, 245, 246, 250], + ["[书籍详情界面]取消书籍简介展开时最大行数限制(无法显示完全)", + "修复从数据库中读取章节时部分数据项缺失的bug"], + "2022-08-11" +) class App250Fix : AppFixHandle { override fun onFix(key: String): BooleanArray { return handleFix( key, "showMoreDesc" to { fxShowMoreDesc() }, + "findBookAllChapterByBookId" to { fxFindBookAllChapterByBookId() }, + ) + } + + private fun fxFindBookAllChapterByBookId() { + MapleUtils.findAndHookMethod( + ChapterService::class.java, + "findBookAllChapterByBookId", + String::class.java, + object : MethodReplacement() { + override fun replaceHookedMethod(param: MapleBridge.MethodHookParam): Any { + val bookId = param.args[0] as String? + if (bookId.isNullOrBlank()) { + return emptyList() + } + return DbManager.getDaoSession().chapterDao + .queryBuilder() + .where(ChapterDao.Properties.BookId.eq(bookId)) + .orderAsc(ChapterDao.Properties.Number) + .list() + } + } ) }