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

初始化时候批量插入底部list数据,为什么重启app会默认多插n倍的数据? #32

Open
dukezhao opened this issue Oct 30, 2017 · 1 comment

Comments

@dukezhao
Copy link

e kgwfqhz 9s n 122g dvv

@dukezhao
Copy link
Author

代码:
private void initMyData() {

    //init data
    final List<Schedule> mData = new ArrayList<>();
    for (int i = 0; i < 3; i++) {
        Schedule schedule = new Schedule();
        schedule.setTitle("new test" + i);
        schedule.setState(0);
        schedule.setTime(mTime);
        schedule.setYear(mCurrentSelectYear);
        schedule.setMonth(mCurrentSelectMonth);
        schedule.setDay(mCurrentSelectDay);
        mData.add(schedule);
    }
    for (int i = 0; i < mData.size(); i++) {
        addMySchedule(mData.get(i));
    }
}

private void addMySchedule(Schedule schedule) {


    new AddScheduleTask(mActivity, new OnTaskFinishedListener<Schedule>() {
        @Override
        public void onTaskFinished(Schedule data) {
            if (data != null) {
                mScheduleAdapter.insertItem(data);

                rLNoTask.setVisibility(View.GONE);
                mTime = 0;
                updateTaskHintUi(mScheduleAdapter.getItemCount() - 2);
            }
        }
    }, schedule).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

}

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

1 participant