Do not add header without notes; extract code to method
This commit is contained in:
parent
8fe6486f62
commit
5105805e06
1 changed files with 28 additions and 28 deletions
|
@ -30,7 +30,7 @@ import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.GPXUtilities.WptPt;
|
import net.osmand.plus.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings.NotesSortByMode;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.ActionBarProgressActivity;
|
import net.osmand.plus.activities.ActionBarProgressActivity;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
@ -178,39 +178,39 @@ public class NotesFragment extends OsmAndListFragment {
|
||||||
private List<Object> createItemsList() {
|
private List<Object> createItemsList() {
|
||||||
List<Recording> recs = new LinkedList<>(plugin.getAllRecordings());
|
List<Recording> recs = new LinkedList<>(plugin.getAllRecordings());
|
||||||
List<Object> res = new LinkedList<>();
|
List<Object> res = new LinkedList<>();
|
||||||
OsmandSettings settings = getMyApplication().getSettings();
|
if (!recs.isEmpty()) {
|
||||||
if (settings.NOTES_SORT_BY_MODE.get().isByDate()) {
|
NotesSortByMode sortByMode = getMyApplication().getSettings().NOTES_SORT_BY_MODE.get();
|
||||||
res.add(NotesAdapter.TYPE_DATE_HEADER);
|
if (sortByMode.isByDate()) {
|
||||||
res.addAll(sortItemsByDateDescending(recs));
|
res.add(NotesAdapter.TYPE_DATE_HEADER);
|
||||||
} else if (settings.NOTES_SORT_BY_MODE.get().isByType()) {
|
res.addAll(sortItemsByDateDescending(recs));
|
||||||
List<Recording> audios = new LinkedList<>();
|
} else if (sortByMode.isByType()) {
|
||||||
List<Recording> photos = new LinkedList<>();
|
List<Recording> audios = new LinkedList<>();
|
||||||
List<Recording> videos = new LinkedList<>();
|
List<Recording> photos = new LinkedList<>();
|
||||||
for (Recording rec : recs) {
|
List<Recording> videos = new LinkedList<>();
|
||||||
if (rec.isAudio()) {
|
for (Recording rec : recs) {
|
||||||
audios.add(rec);
|
if (rec.isAudio()) {
|
||||||
} else if (rec.isPhoto()) {
|
audios.add(rec);
|
||||||
photos.add(rec);
|
} else if (rec.isPhoto()) {
|
||||||
} else {
|
photos.add(rec);
|
||||||
videos.add(rec);
|
} else {
|
||||||
|
videos.add(rec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
addToResIfNotEmpty(res, audios, NotesAdapter.TYPE_AUDIO_HEADER);
|
||||||
if (!audios.isEmpty()) {
|
addToResIfNotEmpty(res, photos, NotesAdapter.TYPE_PHOTO_HEADER);
|
||||||
res.add(NotesAdapter.TYPE_AUDIO_HEADER);
|
addToResIfNotEmpty(res, videos, NotesAdapter.TYPE_VIDEO_HEADER);
|
||||||
res.addAll(audios);
|
|
||||||
}
|
|
||||||
if (!photos.isEmpty()) {
|
|
||||||
res.add(NotesAdapter.TYPE_PHOTO_HEADER);
|
|
||||||
res.addAll(photos);
|
|
||||||
}
|
|
||||||
if (!videos.isEmpty()) {
|
|
||||||
res.add(NotesAdapter.TYPE_VIDEO_HEADER);
|
|
||||||
res.addAll(videos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addToResIfNotEmpty(List<Object> res, List<Recording> recs, int header) {
|
||||||
|
if (!recs.isEmpty()) {
|
||||||
|
res.add(header);
|
||||||
|
res.addAll(recs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private NotesAdapterListener createAdapterListener() {
|
private NotesAdapterListener createAdapterListener() {
|
||||||
return new NotesAdapterListener() {
|
return new NotesAdapterListener() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue