From de7d1ccb0d068b65a891f9447dad1c3e37221c63 Mon Sep 17 00:00:00 2001 From: fengyuecanzhu <1021300691@qq.com> Date: Thu, 23 Jun 2022 21:06:42 +0800 Subject: [PATCH] fix bug --- .idea/modules.xml | 3 - .idea/vcs.xml | 1 - app/src/main/assets/updatelog.fy | 2 + .../fycz/myreader/widget/page/PageView.java | 7 ++- .../main/java/xyz/fycz/dynamic/AppLoadImpl.kt | 3 +- .../java/xyz/fycz/dynamic/fix/App246Fix2.kt | 59 +++++++++++++++++++ 6 files changed, 67 insertions(+), 8 deletions(-) create mode 100644 dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix2.kt diff --git a/.idea/modules.xml b/.idea/modules.xml index d285ce1..373a6ee 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -16,9 +16,6 @@ - - - diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 6143e2f..35eb1dd 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,5 @@ - \ No newline at end of file diff --git a/app/src/main/assets/updatelog.fy b/app/src/main/assets/updatelog.fy index 8c98818..6bfbe90 100644 --- a/app/src/main/assets/updatelog.fy +++ b/app/src/main/assets/updatelog.fy @@ -1,3 +1,5 @@ +1、修复阅读界面概率性闪退的问题 + 2022.05.28 风月读书v2.4.6 更新内容: diff --git a/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java b/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java index bbef581..c53cf3f 100644 --- a/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java +++ b/app/src/main/java/xyz/fycz/myreader/widget/page/PageView.java @@ -491,9 +491,10 @@ public class PageView extends View { @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); - mPageAnim.abortAnim(); - mPageAnim.clear(); - + if (mPageAnim != null) { + mPageAnim.abortAnim(); + mPageAnim.clear(); + } mPageLoader = null; mPageAnim = null; } diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt index 763e3ca..fa7938d 100644 --- a/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt +++ b/dynamic/src/main/java/xyz/fycz/dynamic/AppLoadImpl.kt @@ -46,6 +46,7 @@ class AppLoadImpl : IAppLoader { App244Fix::class.java, App244Fix2::class.java, App246Fix::class.java, + App246Fix2::class.java, AppSubSourceFix::class.java, ) @@ -66,7 +67,7 @@ class AppLoadImpl : IAppLoader { } if (sb.isNotEmpty()) { if (sb.endsWith("\n")) sb.substring(0, sb.length - 1) - val key = "fix2022-06-21" + val key = "fix2022-06-23" val hasRead = spu.getBoolean(key, false) if (!hasRead) { announce("插件更新", "更新内容:\n$sb") diff --git a/dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix2.kt b/dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix2.kt new file mode 100644 index 0000000..380d7cd --- /dev/null +++ b/dynamic/src/main/java/xyz/fycz/dynamic/fix/App246Fix2.kt @@ -0,0 +1,59 @@ +/* + * This file is part of FYReader. + * FYReader is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * FYReader is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with FYReader. If not, see . + * + * Copyright (C) 2020 - 2022 fengyuecanzhu + */ + +package xyz.fycz.dynamic.fix + +import me.fycz.maple.MapleBridge +import me.fycz.maple.MapleUtils +import me.fycz.maple.MethodHook +import xyz.fycz.myreader.widget.page.PageView + +/** + * @author fengyue + * @date 2022/6/23 20:51 + */ +@AppFix([], ["修复阅读界面概率性闪退的问题"], "2022-06-23") +class App246Fix2 : AppFixHandle { + override fun onFix(key: String): BooleanArray { + val result = try { + fxPageView() + true + } catch (e: Exception) { + MapleUtils.log(e) + false + } + fixResult(key, "pageView", result) + return booleanArrayOf(result) + } + + private fun fxPageView() { + MapleUtils.findAndHookMethod( + PageView::class.java, + "onDetachedFromWindow", + object : MethodHook(){ + override fun beforeHookedMethod(param: MapleBridge.MethodHookParam) { + val mPageAnim = MapleUtils.getObjectField(param.thisObject, "mPageAnim") + if (mPageAnim == null){ + MapleUtils.setObjectField(param.thisObject, "mPageLoader", null) + param.result = null + } + } + } + ) + } +} \ No newline at end of file