mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 10:09:42 +00:00
catch the case where for what is probably a race condition due to asynchronous race loading and filter UI application a view item cannot be found
Change-Id: I994b0ef297bfcc7cae8428792289ec6ba55940cd
This commit is contained in:
1 parent
7c01549a9f
commit
c3080caad1
1 file changed
+19
-4
+19
-4
@@ -44,6 +44,7 @@ import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -314,7 +315,14 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
|
||||
@Override
|
||||
public int compare(RaceListDataTypeRace lhs, RaceListDataTypeRace rhs) {
|
||||
return c.compare(lhs.getRace(), rhs.getRace());
|
||||
final int result;
|
||||
if (lhs != null && rhs != null) {
|
||||
result = c.compare(lhs.getRace(), rhs.getRace());
|
||||
} else {
|
||||
Log.e(TAG, "Internal error; found null for NavDrawer item while sorting");
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
for (final RaceListDataTypeRace raceItem : raceItems) {
|
||||
@@ -334,7 +342,12 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
raceItemsInSeries = new ArrayList<>();
|
||||
raceItemsByHeader.put(seriesHeader, raceItemsInSeries);
|
||||
}
|
||||
raceItemsInSeries.add(viewItemsRaces.get(race));
|
||||
final RaceListDataTypeRace viewItemForRace = viewItemsRaces.get(race);
|
||||
if (viewItemForRace != null) {
|
||||
raceItemsInSeries.add(viewItemForRace);
|
||||
} else {
|
||||
Log.w(TAG, "A view item for race "+race+" provided by the filter could not be found");
|
||||
}
|
||||
}
|
||||
return raceItemsByHeader;
|
||||
}
|
||||
@@ -525,7 +538,9 @@ public class ManagedRaceListAdapter extends ArrayAdapter<RaceListDataType> imple
|
||||
}
|
||||
|
||||
public void onRacesChanged() {
|
||||
createViewItemsForRacesAndSeries();
|
||||
getFilter().refreshRegattaStructures();
|
||||
synchronized (mLockObject) {
|
||||
createViewItemsForRacesAndSeries();
|
||||
getFilter().refreshRegattaStructures();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user