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

有动态更新数据源的方法吗 #30

Open
monkey008 opened this issue Mar 23, 2018 · 2 comments
Open

有动态更新数据源的方法吗 #30

monkey008 opened this issue Mar 23, 2018 · 2 comments

Comments

@monkey008
Copy link

翻了下源码 没找到相应的方法

@monkey008
Copy link
Author

monkey008 commented Mar 23, 2018

目前只能通过重新setData来重复添加旧数据+新数据

        marqueeView.stopFlipping();
        marqueeData.addAll(Arrays.asList("1", "2", "3"));
        marqueeFactory.setData(marqueeData);
        marqueeView.startFlipping();

总感觉不够优雅 因为需要把旧数据和新数据重新setData一次
MarqueeFactory应该提供直接更新的方法才好
但是我看MarqueeFactory类里相应的方法被设置成private了

我觉得如果将notifyDataChanged方法这样扩展应该是可以的

public void notifyDataChanged() {
        if (this.dataList == null) {
            return;
        }
        if (mViews != null){
            mViews.clear();
        }else {
            mViews = new ArrayList<>();
        }
        for (int i = 0; i < dataList.size(); i++) {
            E data = dataList.get(i);
            T mView = generateMarqueeItemView(data);
            mViews.add(mView);
        }
        if (isAttachedToMarqueeView()) {
            setChanged();
            notifyObservers(COMMAND_UPDATE_DATA);
        }
    }

@gq630960023
Copy link

我这里减少数据的长度,

marqueeFactory.setData(marqueeData);
marqueeView.startFlipping();

如果正好滚动到边界, 会直接崩溃。

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

2 participants