mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
only setup RacingActivity when data has changed
This commit is contained in:
1 parent
8c3290f928
commit
d4ad49bd9c
3 files changed
+33
-6
No files matched your search
+10
@@ -31,6 +31,7 @@ import com.sap.sailing.racecommittee.app.ui.fragments.RaceInfoFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.ManagedRaceListFragment;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.ManagedRaceListFragment.FilterMode;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.raceinfo.RaceInfoListener;
|
||||
import com.sap.sailing.racecommittee.app.utils.CollectionUtils;
|
||||
|
||||
public class RacingActivity extends SessionActivity implements RaceInfoListener {
|
||||
// private final static String TAG = RacingActivity.class.getName();
|
||||
@@ -171,9 +172,18 @@ public class RacingActivity extends SessionActivity implements RaceInfoListener
|
||||
}));
|
||||
}
|
||||
|
||||
Collection<ManagedRace> lastSeenRaces = null;
|
||||
|
||||
private void onLoadRacesSucceded(CourseArea courseArea, Collection<ManagedRace> data) {
|
||||
setProgressBarIndeterminateVisibility(false);
|
||||
|
||||
// Let's do the setup stuff only when the data is changed (or its the first time)
|
||||
if (lastSeenRaces != null && CollectionUtils.isEqualCollection(data, lastSeenRaces)) {
|
||||
ExLog.i(TAG, "Same races are already loaded...");
|
||||
return;
|
||||
}
|
||||
lastSeenRaces = data;
|
||||
|
||||
registerOnService(data);
|
||||
raceListFragment.setupOn(data);
|
||||
|
||||
|
||||
+8
-1
@@ -51,6 +51,8 @@ public class ManagedRaceListFragment extends ListFragment implements JuryFlagCli
|
||||
}
|
||||
}
|
||||
|
||||
private static final String TAG = ManagedRaceListFragment.class.getName();
|
||||
|
||||
private FilterMode filterMode;
|
||||
private ManagedRaceListAdapter adapter;
|
||||
private ManagedRace selectedRace;
|
||||
@@ -110,6 +112,8 @@ public class ManagedRaceListFragment extends ListFragment implements JuryFlagCli
|
||||
}
|
||||
|
||||
public void setupOn(Collection<ManagedRace> races) {
|
||||
ExLog.i(TAG, String.format("Setting up %s with %d races.", this.getClass().getSimpleName(), races.size()));
|
||||
|
||||
unregisterOnAllRaces();
|
||||
managedRacesById.clear();
|
||||
|
||||
@@ -139,8 +143,11 @@ public class ManagedRaceListFragment extends ListFragment implements JuryFlagCli
|
||||
private void initializeViewElements() {
|
||||
// 1. Group races by <boat class, series, fleet>
|
||||
initializeRacesByGroup();
|
||||
|
||||
// 2. Remove previous view items
|
||||
viewItems.clear();
|
||||
|
||||
// 2. Create view elements from tree
|
||||
// 3. Create view elements from tree
|
||||
for (BoatClassSeriesFleet key : racesByGroup.navigableKeySet()) {
|
||||
// ... add the header view...
|
||||
viewItems.add(new RaceListDataTypeHeader(key));
|
||||
|
||||
+15
-5
@@ -1,15 +1,25 @@
|
||||
package com.sap.sailing.racecommittee.app.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
|
||||
public class CollectionUtils {
|
||||
|
||||
public static <T> ArrayList<T> newArrayList(Iterable<T> iterable) {
|
||||
ArrayList<T> list = new ArrayList<T>();
|
||||
Util.addAll(iterable, list);
|
||||
return list;
|
||||
}
|
||||
public static <T> ArrayList<T> newArrayList(final Iterable<T> iterable) {
|
||||
ArrayList<T> list = new ArrayList<T>();
|
||||
Util.addAll(iterable, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean isEqualCollection(final Collection<?> left, final Collection<?> right) {
|
||||
if (left.size() != right.size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// There may be better implementations ;-)
|
||||
return left.containsAll(right) && right.containsAll(left);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user