Skip to content

Commit 632200d

Browse files
committed
refactor:调整逻辑
1 parent b7f8043 commit 632200d

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

floatingx/src/main/java/com/petterp/floatingx/imp/FxAppLifecycleProvider.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import java.lang.ref.WeakReference
1010
* @author petterp
1111
*/
1212
class FxAppLifecycleProvider : Application.ActivityLifecycleCallbacks {
13+
override fun onActivityPostCreated(activity: Activity, savedInstanceState: Bundle?) {
14+
updateTopActivity(activity)
15+
}
16+
1317
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
1418
updateTopActivity(activity)
1519
}

floatingx/src/main/java/com/petterp/floatingx/imp/FxBasisControlImp.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ abstract class FxBasisControlImp<F : FxBasisHelper, P : IFxPlatformProvider<F>>(
2929
override val configControl: IFxConfigControl get() = _configControl
3030
override fun getX() = getManagerView()?.x ?: 0f
3131
override fun getY() = getManagerView()?.y ?: 0f
32+
override fun isShow() = platformProvider.isShow()
3233
override fun getView() = internalView?.childView
3334
override fun getViewHolder() = internalView?.viewHolder
3435
override fun getManagerView() = internalView?.containerView
@@ -57,6 +58,7 @@ abstract class FxBasisControlImp<F : FxBasisHelper, P : IFxPlatformProvider<F>>(
5758
}
5859

5960
override fun hide() {
61+
// 这里同时增加判断状态,因为有可能view正在等待postAttach
6062
if (!isShow()) return
6163
helper.enableFx = false
6264
val fxView = getManagerView() ?: return
@@ -82,8 +84,6 @@ abstract class FxBasisControlImp<F : FxBasisHelper, P : IFxPlatformProvider<F>>(
8284
}
8385
}
8486

85-
override fun isShow() = platformProvider.isShow() == true
86-
8787
override fun updateView(@LayoutRes resource: Int) {
8888
check(resource != INVALID_LAYOUT_ID) { "resource cannot be INVALID_LAYOUT_ID!" }
8989
helper.layoutView = null

0 commit comments

Comments
 (0)