diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java b/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java deleted file mode 100644 index cf4f31efc..000000000 --- a/app/src/main/java/com/simplemobiletools/gallery/models/Directory.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.simplemobiletools.gallery.models; - -import com.simplemobiletools.gallery.Constants; - -public class Directory implements Comparable { - private final String mPath; - private final String mThumbnail; - private final String mName; - private final long mTimestamp; - private int mMediaCnt; - private long mSize; - public static int mSorting; - - public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp, long size) { - mPath = path; - mThumbnail = thumbnail; - mName = name; - mMediaCnt = mediaCnt; - mTimestamp = timestamp; - mSize = size; - } - - public String getPath() { - return mPath; - } - - public String getThumbnail() { - return mThumbnail; - } - - public String getName() { - return mName; - } - - public int getMediaCnt() { - return mMediaCnt; - } - - public void setMediaCnt(int cnt) { - mMediaCnt = cnt; - } - - public long getTimestamp() { - return mTimestamp; - } - - public long getSize() { - return mSize; - } - - public void addSize(long bytes) { - mSize += bytes; - } - - @Override - public int compareTo(Object object) { - final Directory directory = (Directory) object; - int res; - if ((mSorting & Constants.SORT_BY_NAME) != 0) { - res = mPath.compareTo(directory.getPath()); - } else if ((mSorting & Constants.SORT_BY_DATE) != 0) { - res = (mTimestamp > directory.getTimestamp()) ? 1 : -1; - } else { - res = (mSize > directory.getSize()) ? 1 : -1; - } - - if ((mSorting & Constants.SORT_DESCENDING) != 0) { - res *= -1; - } - return res; - } - - @Override - public String toString() { - return "Directory {" + - "path=" + getPath() + - ", thumbnail=" + getThumbnail() + - ", name=" + getName() + - ", timestamp=" + getTimestamp() + - ", mediaCnt=" + getMediaCnt() + "}"; - } -} diff --git a/app/src/main/java/com/simplemobiletools/gallery/models/Directory.kt b/app/src/main/java/com/simplemobiletools/gallery/models/Directory.kt new file mode 100644 index 000000000..258bde275 --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/gallery/models/Directory.kt @@ -0,0 +1,33 @@ +package com.simplemobiletools.gallery.models + +import com.simplemobiletools.gallery.Constants + +class Directory(val path: String, val thumbnail: String, val name: String, var mediaCnt: Int, val timestamp: Long, var size: Long) : Comparable { + fun addSize(bytes: Long) { + size += bytes + } + + override fun compareTo(other: Directory): Int { + var res: Int + if (mSorting and Constants.SORT_BY_NAME != 0) { + res = path.compareTo(other.path) + } else if (mSorting and Constants.SORT_BY_DATE != 0) { + res = if (timestamp > other.timestamp) 1 else -1 + } else { + res = if (size > other.size) 1 else -1 + } + + if (mSorting and Constants.SORT_DESCENDING != 0) { + res *= -1 + } + return res + } + + override fun toString(): String { + return "Directory {path=$path, thumbnail=$thumbnail, name=$name, timestamp=$timestamp, mediaCnt=$mediaCnt}" + } + + companion object { + var mSorting: Int = 0 + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt index aeaf3e447..eb3b8bf09 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/asynctasks/GetDirectoriesAsynctask.kt @@ -77,7 +77,7 @@ class GetDirectoriesAsynctask(val context: Context, val isPickVideo: Boolean, va val dirs = ArrayList(directories.values) filterDirectories(dirs) Directory.mSorting = mConfig.directorySorting - //Collections.sort(dirs) + Collections.sort(dirs) val invalids = invalidFiles.toTypedArray() MediaScannerConnection.scanFile(context, invalids, null, null)