sort media before displaying
This commit is contained in:
parent
b47e13c4b5
commit
c2aea6b5fb
|
@ -30,6 +30,7 @@ import com.simplemobiletools.gallery.models.Medium;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -148,6 +149,8 @@ public class MediaActivity extends AppCompatActivity
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(myMedia);
|
||||
|
||||
final String[] invalids = invalidFiles.toArray(new String[invalidFiles.size()]);
|
||||
MediaScannerConnection.scanFile(getApplicationContext(), invalids, null, null);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simplemobiletools.gallery.models;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Medium implements Serializable {
|
||||
public class Medium implements Serializable, Comparable {
|
||||
private static final long serialVersionUID = -6543139465975455L;
|
||||
private final String path;
|
||||
private final boolean isVideo;
|
||||
|
@ -26,6 +26,17 @@ public class Medium implements Serializable {
|
|||
return timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Object object) {
|
||||
Medium medium = (Medium) object;
|
||||
if (this.timestamp < medium.getTimestamp()) {
|
||||
return 1;
|
||||
} else if (this.timestamp > medium.getTimestamp()) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Medium {" +
|
||||
|
|
Loading…
Reference in New Issue