Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在小米的安卓11手机上,会导致应用整体卡顿 #269

Open
chenglin198751 opened this issue Jul 7, 2021 · 5 comments
Open

在小米的安卓11手机上,会导致应用整体卡顿 #269

chenglin198751 opened this issue Jul 7, 2021 · 5 comments

Comments

@chenglin198751
Copy link

用户反馈应用卡顿,经过我的跟踪调试,发现在安卓11上,每个页面都卡顿。分析代码,发现,是CommonNavigator类的onLayout()方法被无限次调用,导致UI线程被占用从而整个app都卡顿,在小米的安卓11必现。别的手机的安卓11不知道是不是会出现。
我的修改办法,在CommonNavigator类中:
`` private boolean isLayout = false;

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    if (!isLayout) {
        isLayout = true;
        if (mAdapter != null) {
            preparePositionData();
            if (mIndicator != null) {
                mIndicator.onPositionDataProvide(mPositionDataList);
            }
            if (mReselectWhenLayout && mNavigatorHelper.getScrollState() == ScrollState.SCROLL_STATE_IDLE) {
                onPageSelected(mNavigatorHelper.getCurrentIndex());
                onPageScrolled(mNavigatorHelper.getCurrentIndex(), 0.0f, 0);
            }
        }
    }
}`

不知道这种修改方式是否合理,请作者评估修改下。

@sunny-zhang-98
Copy link

sunny-zhang-98 commented Aug 4, 2021

我也出现了这个情况,会导致Tab不断的恢复初始状态
最后通过修改这个属性暂时解决了
mReselectWhenLayout
我不知道作者在这个字段注释中说的极端情况是什么情况

private boolean mReselectWhenLayout = true; // PositionData准备好时,是否重新选中当前页,为true可保证在极端情况下指示器状态正确

@joymingchen
Copy link

其实也可以用onLayout中的(boolean changed)这个字段来进行判断

@zguop
Copy link

zguop commented Oct 25, 2021

有人发布解决这个问题吗

@amosxb
Copy link

amosxb commented Jun 10, 2022

没人fork一下项目么

@hackware1993
Copy link
Owner

没人fork一下项目么

很多人 fock 啊,出了什么问题?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants