mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 10:09:42 +00:00
preparing filter and comparator, adding stuff to FilterableRace
Change-Id: I8a1e54c5cadb8626a28a5647cc8c53a485e0d309
This commit is contained in:
1 parent
02fefbac8b
commit
a833c463c6
8 files changed
+74
-19
No files matched your search
+4
@@ -226,4 +226,8 @@ public class ManagedRaceImpl implements ManagedRace {
|
||||
return zeroBasedIndexInFleet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZeroBasedSeriesIndex() {
|
||||
return Util.indexOf(getRaceGroup().getSeries(), getSeries());
|
||||
}
|
||||
}
|
||||
+13
-4
@@ -9,6 +9,15 @@ import com.sap.sailing.domain.common.LeaderboardNameConstants;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
/**
|
||||
* Represents a triple of {@link RaceGroup} (representing a regatta or a flexible leaderboard), a {@link SeriesBase series}
|
||||
* and a {@link Fleet}. An instance can be constructed for a {@link ManagedRace} which then extracts these three properties
|
||||
* from the race. Note that equal objects of this type can result for different races as long as they are in the equal
|
||||
* {@link RaceGroup}, {@link SeriesBase series} and {@link Fleet}.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class RaceGroupSeriesFleet {
|
||||
|
||||
private RaceGroup raceGroup;
|
||||
@@ -21,7 +30,6 @@ public class RaceGroupSeriesFleet {
|
||||
raceGroup = race.getRaceGroup();
|
||||
series = race.getSeries();
|
||||
fleet = race.getFleet();
|
||||
|
||||
seriesOrder = getSeriesIndex(race, series);
|
||||
fleetOrder = getFleetIndex(series.getFleets(), race.getFleet());
|
||||
}
|
||||
@@ -30,6 +38,10 @@ public class RaceGroupSeriesFleet {
|
||||
return Util.indexOf(race.getRaceGroup().getSeries(), series);
|
||||
}
|
||||
|
||||
private int getFleetIndex(Iterable<? extends Fleet> fleets, Fleet fleet) {
|
||||
return Util.indexOf(fleets, fleet);
|
||||
}
|
||||
|
||||
public RaceGroup getRaceGroup() {
|
||||
return raceGroup;
|
||||
}
|
||||
@@ -131,7 +143,4 @@ public class RaceGroupSeriesFleet {
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getFleetIndex(Iterable<? extends Fleet> fleets, Fleet fleet) {
|
||||
return Util.indexOf(fleets, fleet);
|
||||
}
|
||||
}
|
||||
+12
-6
@@ -6,17 +6,23 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.widget.Filter;
|
||||
|
||||
import com.sap.sailing.domain.base.racegroup.CurrentRaceComparator;
|
||||
import com.sap.sailing.domain.base.racegroup.CurrentRaceFilter;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sailing.racecommittee.app.domain.impl.RaceGroupSeriesFleet;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.RaceListFragment.FilterMode;
|
||||
|
||||
import android.widget.Filter;
|
||||
|
||||
/**
|
||||
* Filters races by status.
|
||||
* <p/>
|
||||
* For each "run" of unscheduled races only the first will be taken.
|
||||
* For each "run" of finished races only the last will be taken.
|
||||
* Filters {@link ManagedRace} objects by status and place in the regatta structure. See {@link CurrentRaceFilter}. If
|
||||
* the {@link #filterMode} is {@link FilterMode#ALL}, no filtering takes place at all, and all races will be displayed.
|
||||
* If the {@link #filterMode} is {@link FilterMode#ACTIVE}, the set of races to be displayed is computed using a
|
||||
* {@link CurrentRaceFilter}. For each race to be displayed, a {@link RaceListDataTypeRace} view item is produced. The
|
||||
* races are grouped into sections, one for each series, and the items within each such series section are ordered using
|
||||
* a {@link CurrentRaceComparator} while the series sections are ordered by the order in which the series appear in the
|
||||
* Race Group / regatta.
|
||||
*/
|
||||
public class RaceFilter extends Filter {
|
||||
|
||||
|
||||
+1
-7
@@ -345,7 +345,6 @@ public class RaceListFragment extends LoggableFragment implements OnItemClickLis
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
unregisterOnAllRaces();
|
||||
registerOnAllRaces();
|
||||
for (ManagedRace race : mManagedRacesById.values()) {
|
||||
@@ -377,34 +376,29 @@ public class RaceListFragment extends LoggableFragment implements OnItemClickLis
|
||||
@Override
|
||||
public void onDrawerClosed(View drawerView) {
|
||||
super.onDrawerClosed(drawerView);
|
||||
|
||||
mUpdateList = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawerOpened(View drawerView) {
|
||||
super.onDrawerOpened(drawerView);
|
||||
|
||||
mUpdateList = true;
|
||||
}
|
||||
};
|
||||
|
||||
mDrawerLayout.post(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mDrawerToggle.syncState();
|
||||
}
|
||||
});
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
|
||||
if (mCourse != null) {
|
||||
SpannableString text = new SpannableString(course);
|
||||
StyleSpan spanBold = new StyleSpan(Typeface.BOLD);
|
||||
text.setSpan(spanBold, 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
mCourse.setText(text);
|
||||
}
|
||||
|
||||
if (mData != null) {
|
||||
mData.setText(StringHelper.on(getActivity()).getAuthor(author));
|
||||
}
|
||||
@@ -414,7 +408,6 @@ public class RaceListFragment extends LoggableFragment implements OnItemClickLis
|
||||
mRacesByGroup.clear();
|
||||
for (ManagedRace race : mManagedRacesById.values()) {
|
||||
RaceGroupSeriesFleet container = new RaceGroupSeriesFleet(race);
|
||||
|
||||
if (!mRacesByGroup.containsKey(container)) {
|
||||
mRacesByGroup.put(container, new LinkedList<ManagedRace>());
|
||||
}
|
||||
@@ -428,6 +421,7 @@ public class RaceListFragment extends LoggableFragment implements OnItemClickLis
|
||||
|
||||
// 2. Remove previous view items
|
||||
mViewItems.clear();
|
||||
|
||||
|
||||
// 3. Group active fleets from tree by series
|
||||
Map<SeriesBase, List<RaceGroupSeriesFleet>> seriesWithFleets = getFleetsGroupedBySeries(mRacesByGroup.keySet());
|
||||
|
||||
Reference in new issue
Block a user