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() + } + } ) }