fix ProfileSwitch loading

This commit is contained in:
Milos Kozak 2020-05-23 22:16:55 +02:00
parent 8ae817cdda
commit 3d1b500395

View file

@ -1531,7 +1531,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
//add last one without duration
ProfileSwitch last = getLastProfileSwitchWithoutDuration();
if (last != null) {
if (!profileSwitches.contains(last))
if (!isInList(profileSwitches, last))
profileSwitches.add(last);
}
return profileSwitches;
@ -1541,6 +1541,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
return new ArrayList<>();
}
boolean isInList(List<ProfileSwitch> profileSwitches, ProfileSwitch last) {
for (ProfileSwitch ps : profileSwitches) {
if (ps.isEqual(last)) return true;
}
return false;
}
@Nullable
private ProfileSwitch getLastProfileSwitchWithoutDuration() {
try {