sort directories already at the query

This commit is contained in:
tibbi 2016-07-24 21:15:05 +02:00
parent 8054f51727
commit 7141563463
1 changed files with 15 additions and 1 deletions

View File

@ -193,7 +193,7 @@ public class MainActivity extends SimpleActivity
uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; uri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} }
final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_TAKEN}; final String[] columns = {MediaStore.Images.Media.DATA, MediaStore.Images.Media.DATE_TAKEN};
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC"; final String order = getSortOrder();
final Cursor cursor = getContentResolver().query(uri, columns, null, null, order); final Cursor cursor = getContentResolver().query(uri, columns, null, null, order);
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
@ -234,6 +234,20 @@ public class MainActivity extends SimpleActivity
return dirs; return dirs;
} }
// sort the files at querying too, just to get the correct thumbnail
private String getSortOrder() {
final int sorting = mConfig.getSorting();
String sortBy = MediaStore.Images.Media.DATE_TAKEN;
if ((sorting & Constants.SORT_BY_NAME) != 0) {
sortBy = MediaStore.Images.Media.DATA;
}
if ((sorting & Constants.SORT_DESCENDING) != 0) {
sortBy += " DESC";
}
return sortBy;
}
private void showSortingDialog() { private void showSortingDialog() {
new ChangeSorting(this); new ChangeSorting(this);
} }