MagicIndicator icon indicating copy to clipboard operation
MagicIndicator copied to clipboard

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

Open chenglin198751 opened this issue 3 years ago • 5 comments

用户反馈应用卡顿,经过我的跟踪调试,发现在安卓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);
            }
        }
    }
}`

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

chenglin198751 avatar Jul 07 '21 01:07 chenglin198751

我也出现了这个情况,会导致Tab不断的恢复初始状态 最后通过修改这个属性暂时解决了 mReselectWhenLayout 我不知道作者在这个字段注释中说的极端情况是什么情况 https://github.com/hackware1993/MagicIndicator/blob/e14fa79267c1977b0f51f593598ad50b2d08d11a/magicindicator/src/main/java/net/lucode/hackware/magicindicator/buildins/commonnavigator/CommonNavigator.java#L52

sunny-zhang-98 avatar Aug 04 '21 10:08 sunny-zhang-98

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

joymingchen avatar Sep 23 '21 06:09 joymingchen

有人发布解决这个问题吗

zguop avatar Oct 25 '21 03:10 zguop

没人fork一下项目么

amosxb avatar Jun 10 '22 02:06 amosxb

没人fork一下项目么

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

hackware1993 avatar Jun 10 '22 02:06 hackware1993