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

在onLayout里触发onPageSelected所导致的Bug #159

Open
ZZombiee opened this issue Dec 29, 2018 · 3 comments
Open

在onLayout里触发onPageSelected所导致的Bug #159

ZZombiee opened this issue Dec 29, 2018 · 3 comments

Comments

@ZZombiee
Copy link

我的列表里菜单可以弹出键盘
只要弹出键盘,就会触发CommonNavigator的onLayout,然后间接触发onPageSelected,而我又在这个回调里设置了不同Fragment的刷新操作
现象就变成了弹出键盘就触发刷新,产生了较为严重的Bug
我觉得至少需要加一个监听,onPageSelectChanged

@ZZombiee
Copy link
Author

ZZombiee commented Dec 29, 2018

public class YNavigator extends CommonNavigator {
    private int mIndex = -1;

    public YNavigator(Context context) {
        super(context);
    }

    @Override
    public void onPageSelected(int position) {
        if (mIndex != position)
            onPageSelectChanged(mIndex, position);
        super.onPageSelected(position);
        mIndex = position;
    }

    public void onPageSelectChanged(int position, int goal) {
        if (getAdapter() != null) {
            if (getPagerIndicator() != null && getPagerIndicator() instanceof YLinePageIndicator) {
                ((YLinePageIndicator) getPagerIndicator()).onPageSelectChanged(position, goal);
            }
        }

    }
}
  @Override
            public IPagerIndicator getIndicator(Context context) {
                YLinePageIndicator indicator = new YLinePageIndicator(context) {
                    @Override
                    public void onPageSelectChanged(int position, int goal) {
                        L.d("YLinePageIndicator", "onPageSelectChanged:" + position + "," + goal);
                        ((TabFragment) tabAdapter.getItem(goal)).getDetail();
                    }

                    @Override
                    public void onPageSelected(int position) {
                        L.d("YLinePageIndicator", "onPageSelected:" + position + "");
                    }
                };
                indicator.setLineHeight(AppUtils.auto_height_px(getResources().getDimension(R
                        .dimen.p1)));
                indicator.setColors(context.getResources().getColor(R.color.btn_orange));
                return indicator;
            }

这样就好了

@mybirthfather
Copy link

我也有这个问题但是我是要在onSelected 的时候 reset 我的某一部分数据 但是现在 弹出键盘就给我初始化了 卧槽 我蒙蔽了

@spuermax
Copy link

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

3 participants