mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-22 04:28:00 +01:00
order the directories and photos by date
This commit is contained in:
parent
8af17a8c44
commit
ef241a1c5d
3 changed files with 8 additions and 4 deletions
|
@ -13,6 +13,7 @@ import android.widget.GridView;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
@ -38,10 +39,11 @@ public class MainActivity extends AppCompatActivity implements OnItemClickListen
|
|||
}
|
||||
|
||||
private Map<String, Directory> getDirectories() {
|
||||
final Map<String, Directory> directories = new TreeMap<>();
|
||||
final Map<String, Directory> directories = new LinkedHashMap<>();
|
||||
final Uri uri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
|
||||
final String[] columns = {MediaStore.Images.Media.DATA};
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, null, null, null);
|
||||
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC";
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, null, null, order);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
|
|
|
@ -38,7 +38,8 @@ public class PhotosActivity extends AppCompatActivity implements AdapterView.OnI
|
|||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
final String[] args = new String[]{path + "%"};
|
||||
final String[] columns = {MediaStore.Images.Media.DATA};
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, where, args, null);
|
||||
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC";
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, where, args, order);
|
||||
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
final int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
|
||||
|
|
|
@ -38,7 +38,8 @@ public class ViewPagerActivity extends AppCompatActivity {
|
|||
final String where = MediaStore.Images.Media.DATA + " like ? ";
|
||||
final String[] args = new String[]{fileDir + "%"};
|
||||
final String[] columns = {MediaStore.Images.Media.DATA};
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, where, args, null);
|
||||
final String order = MediaStore.Images.Media.DATE_MODIFIED + " DESC";
|
||||
final Cursor cursor = getContentResolver().query(uri, columns, where, args, order);
|
||||
|
||||
int i = 0;
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
|
|
Loading…
Reference in a new issue