Merge pull request #4510 from osmandapp/audio_video_notes_sorting
Fix #4493
This commit is contained in:
commit
998d0ef846
1 changed files with 20 additions and 0 deletions
|
@ -20,6 +20,8 @@ import net.osmand.plus.dashboard.DashboardOnMap;
|
|||
import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -80,6 +82,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
|||
return;
|
||||
} else {
|
||||
mainView.setVisibility(View.VISIBLE);
|
||||
sortItemsDescending(notes);
|
||||
}
|
||||
|
||||
LinearLayout notesLayout = (LinearLayout) mainView.findViewById(R.id.items);
|
||||
|
@ -115,6 +118,23 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
|||
}
|
||||
}
|
||||
|
||||
private void sortItemsDescending(List<AudioVideoNotesPlugin.Recording> items) {
|
||||
Collections.sort(items, new Comparator<AudioVideoNotesPlugin.Recording>() {
|
||||
@Override
|
||||
public int compare(AudioVideoNotesPlugin.Recording first, AudioVideoNotesPlugin.Recording second) {
|
||||
long firstTime = first.getLastModified();
|
||||
long secondTime = second.getLastModified();
|
||||
if (firstTime < secondTime) {
|
||||
return 1;
|
||||
} else if (firstTime == secondTime) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Drawable getNoteView(final AudioVideoNotesPlugin.Recording recording, View view,
|
||||
final OsmandApplication ctx) {
|
||||
String name = recording.getName(ctx, true);
|
||||
|
|
Loading…
Reference in a new issue