Merge pull request #4101 from osmandapp/alex_branch

Fix #3974
This commit is contained in:
Alexey 2017-07-13 14:22:50 +03:00 committed by GitHub
commit ebf5d6092c
2 changed files with 23 additions and 0 deletions

View file

@ -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();

View file

@ -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,23 @@ 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;
}
}
});
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
menu.clear();