MvpApp icon indicating copy to clipboard operation
MvpApp copied to clipboard

数据库里的记录可以这样交换顺序

Open Lingyuezhixing opened this issue 7 years ago • 2 comments

@Override
public void swap(int fromPos, int toPos, List<NewsTypeInfo> list) {
    NewsTypeInfo fromInfo = list.get(fromPos);
    NewsTypeInfo toInfo = list.get(toPos);
    NewsTypeInfo tem = fromInfo;
    //要重写创建对象,不能去改变源对象,因为源对象在多处使用到
    fromInfo = new NewsTypeInfo(tem.getId(), toInfo.getName(), toInfo.getTypeId());
    toInfo = new NewsTypeInfo(toInfo.getId(), tem.getName(), tem.getTypeId());
    update(fromInfo);
    update(toInfo);

}

Lingyuezhixing avatar Nov 15 '17 14:11 Lingyuezhixing

嗯,这样应该会比我之前写法好

Rukey7 avatar Nov 17 '17 03:11 Rukey7

@Lingyuezhixing 有没有更详细点的源码

yuekong avatar Mar 22 '18 02:03 yuekong