Fix #3974
This commit is contained in:
parent
763aac1615
commit
b47c7aeee4
2 changed files with 24 additions and 0 deletions
|
@ -243,6 +243,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
return file;
|
||||
}
|
||||
|
||||
public long getLastModified() {
|
||||
return file.lastModified();
|
||||
}
|
||||
|
||||
public boolean setName(String name) {
|
||||
File directory = file.getParentFile();
|
||||
|
|
|
@ -51,6 +51,8 @@ import org.apache.commons.logging.Log;
|
|||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -128,6 +130,7 @@ public class NotesFragment extends OsmAndListFragment {
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
items = new ArrayList<>(plugin.getAllRecordings());
|
||||
sortItemsDescending();
|
||||
ListView listView = getListView();
|
||||
if (items.size() > 0 && footerView == null) {
|
||||
//listView.addHeaderView(getActivity().getLayoutInflater().inflate(R.layout.list_shadow_header, null, false));
|
||||
|
@ -140,6 +143,24 @@ public class NotesFragment extends OsmAndListFragment {
|
|||
listView.setAdapter(listAdapter);
|
||||
}
|
||||
|
||||
private void sortItemsDescending() {
|
||||
Collections.sort(items, new Comparator<Recording>() {
|
||||
@Override
|
||||
public int compare(Recording first, Recording second) {
|
||||
long firstTime = first.getLastModified();
|
||||
long secondTime = second.getLastModified();
|
||||
if (firstTime > secondTime) {
|
||||
return 1;
|
||||
} else if (firstTime == secondTime) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
});
|
||||
Collections.reverse(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
menu.clear();
|
||||
|
|
Loading…
Reference in a new issue