/** * @param position list postition 0...n * @return a pair of a TYPE and an ID */ public Pair<Integer, Integer> getItemForPosition(int position) { int countdown = position; for (Integer bundleId : sBundlesWithTracks.keySet()) { if (countdown == 0) { return Pair.create(Constants.BREADCRUMBS_BUNDLE_ITEM_VIEW_TYPE, bundleId); } countdown--; int bundleSize = sBundlesWithTracks.get(bundleId) != null ? sBundlesWithTracks.get(bundleId).size() : 0; if (countdown < bundleSize) { Integer trackId = sBundlesWithTracks.get(bundleId).get(countdown); return Pair.create(Constants.BREADCRUMBS_TRACK_ITEM_VIEW_TYPE, trackId); } countdown -= bundleSize; } return null; }
/** * Add track to tracklist * * @param trackId * @param trackName * @param bundleId * @param trackDescription * @param difficulty * @param startTime * @param endTime * @param isPublic * @param lat * @param lng * @param totalDistance * @param totalTime * @param trackRating */ public void addTrack( int trackId, String trackName, int bundleId, String trackDescription, String difficulty, String startTime, String endTime, String isPublic, Float lat, Float lng, Float totalDistance, Integer totalTime, String trackRating) { if (BreadcrumbsAdapter.DEBUG) { Log.d( TAG, "addTrack(Integer " + trackId + ", String " + trackName + ", Integer " + bundleId + "..."); } if (sBundlesWithTracks.get(bundleId) == null) { sBundlesWithTracks.put(bundleId, new ArrayList<Integer>()); } if (!sBundlesWithTracks.get(bundleId).contains(trackId)) { sBundlesWithTracks.get(bundleId).add(trackId); sScheduledTracksLoading.remove( Pair.create(Constants.BREADCRUMBS_TRACK_ITEM_VIEW_TYPE, trackId)); } if (sTrackMappings.get(trackId) == null) { sTrackMappings.put(trackId, new HashMap<String, String>()); } putForTrack(trackId, NAME, trackName); putForTrack(trackId, ISPUBLIC, isPublic); putForTrack(trackId, STARTTIME, startTime); putForTrack(trackId, ENDTIME, endTime); putForTrack(trackId, DESCRIPTION, trackDescription); putForTrack(trackId, DIFFICULTY, difficulty); putForTrack(trackId, RATING, trackRating); putForTrack(trackId, LATITUDE, lat); putForTrack(trackId, LONGITUDE, lng); putForTrack(trackId, TOTALDISTANCE, totalDistance); putForTrack(trackId, TOTALTIME, totalTime); notifyObservers(); }