|
76 | 76 | import java.util.ArrayList; |
77 | 77 | import java.util.Collections; |
78 | 78 | import java.util.Date; |
79 | | -import java.util.HashMap; |
80 | 79 | import java.util.List; |
81 | 80 | import java.util.Locale; |
82 | 81 | import java.util.Map; |
83 | 82 | import java.util.Objects; |
84 | 83 | import java.util.Set; |
85 | 84 | import java.util.UUID; |
86 | | -import java.util.function.BiConsumer; |
87 | 85 |
|
88 | 86 | import androidx.annotation.NonNull; |
89 | 87 | import androidx.annotation.Nullable; |
@@ -1067,33 +1065,24 @@ public void removeAllFiles() { |
1067 | 1065 | notifyDataSetChanged(); |
1068 | 1066 | } |
1069 | 1067 |
|
1070 | | - public void removeFileIndicator(OCFile file) { |
1071 | | - if (file != null) { |
1072 | | - file.setFileIndicator(null); |
1073 | | - notifyItemChanged(file); |
1074 | | - } |
1075 | | - } |
1076 | | - |
1077 | 1068 | public void updateFileIndicators(Map<Long, FileIndicator> indicators) { |
1078 | 1069 | if (indicators == null || indicators.isEmpty()) { |
1079 | 1070 | return; |
1080 | 1071 | } |
1081 | 1072 |
|
1082 | | - Map<Long, Integer> positionMap = new HashMap<>(mFiles.size()); |
1083 | | - for (int i = 0; i < mFiles.size(); i++) { |
1084 | | - positionMap.put(mFiles.get(i).getFileId(), i); |
1085 | | - } |
| 1073 | + for (OCFile file: mFiles) { |
| 1074 | + final var fileIndicator = indicators.get(file.getFileId()); |
| 1075 | + if (fileIndicator == null) { |
| 1076 | + continue; |
| 1077 | + } |
1086 | 1078 |
|
1087 | | - indicators.forEach((id, fileIndicator) -> { |
1088 | | - Integer position = positionMap.get(id); |
1089 | | - if (position != null) { |
1090 | | - OCFile file = mFiles.get(position); |
1091 | | - Integer newIndicator = fileIndicator.getIconRes(); |
1092 | | - if (!Objects.equals(file.getFileIndicator(), newIndicator)) { |
1093 | | - file.setFileIndicator(newIndicator); |
1094 | | - notifyItemChanged(file); |
1095 | | - } |
| 1079 | + final var newIndicator = fileIndicator.getIconRes(); |
| 1080 | + if (Objects.equals(file.getFileIndicator(), newIndicator)) { |
| 1081 | + continue; |
1096 | 1082 | } |
1097 | | - }); |
| 1083 | + |
| 1084 | + file.setFileIndicator(newIndicator); |
| 1085 | + notifyItemChanged(file); |
| 1086 | + } |
1098 | 1087 | } |
1099 | 1088 | } |
0 commit comments