| | |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | |
| | | this.houseIdList = houseIdList; |
| | | } |
| | | |
| | | /** |
| | | * 删除电站 |
| | | * |
| | | * @param houseId 电站id |
| | | */ |
| | | public void delHouseId(String houseId) { |
| | | if (TextUtils.isEmpty(houseId)) { |
| | | return; |
| | | } |
| | | for (int i = 0; i < houseIdList.size(); i++) { |
| | | if (houseIdList.get(i).getHomeId().equals(houseId)) { |
| | | houseIdList.remove(i); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 移动电站位置 |
| | | * |
| | | * @param houseId 电站id |
| | | */ |
| | | public void moveHouseId(String houseId) { |
| | | if (TextUtils.isEmpty(houseId)) { |
| | | return; |
| | | } |
| | | int index = -1; |
| | | for (int i = 0; i < houseIdList.size(); i++) { |
| | | if (houseIdList.get(i).getHomeId().equals(houseId)) { |
| | | index = i; |
| | | break; |
| | | } |
| | | } |
| | | if (index == -1) { |
| | | return; |
| | | } |
| | | //index==0表示只有一个元素或者在首位,不需要移动位置 |
| | | if (index > 0) { |
| | | Collections.swap(houseIdList, index - 1, index); |
| | | } |
| | | } |
| | | |
| | | //住宅ID列表 |
| | | private List<HouseIdBean> houseIdList = new ArrayList<>(); |
| | | //住宅详情列表 |