calculate the size of directories
+ adding some initial sorting things
This commit is contained in:
parent
0c9fe0e4c3
commit
fddaea76c3
12 changed files with 66 additions and 31 deletions
|
@ -210,9 +210,10 @@ public class MainActivity extends SimpleActivity
|
||||||
final Directory directory = directories.get(fileDir);
|
final Directory directory = directories.get(fileDir);
|
||||||
final int newImageCnt = directory.getMediaCnt() + 1;
|
final int newImageCnt = directory.getMediaCnt() + 1;
|
||||||
directory.setMediaCnt(newImageCnt);
|
directory.setMediaCnt(newImageCnt);
|
||||||
|
directory.addSize(file.length());
|
||||||
} else if (!mToBeDeleted.contains(fileDir)) {
|
} else if (!mToBeDeleted.contains(fileDir)) {
|
||||||
final String dirName = Utils.getFilename(fileDir);
|
final String dirName = Utils.getFilename(fileDir);
|
||||||
directories.put(fileDir, new Directory(fileDir, path, dirName, 1, timestamp));
|
directories.put(fileDir, new Directory(fileDir, path, dirName, 1, timestamp, file.length()));
|
||||||
}
|
}
|
||||||
} while (cursor.moveToNext());
|
} while (cursor.moveToNext());
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
|
@ -1,50 +1,60 @@
|
||||||
package com.simplemobiletools.gallery.models;
|
package com.simplemobiletools.gallery.models;
|
||||||
|
|
||||||
public class Directory implements Comparable {
|
public class Directory implements Comparable {
|
||||||
private final String path;
|
private final String mPath;
|
||||||
private final String thumbnail;
|
private final String mThumbnail;
|
||||||
private final String name;
|
private final String mName;
|
||||||
private final long timestamp;
|
private final long mTimestamp;
|
||||||
private int mediaCnt;
|
private int mMediaCnt;
|
||||||
|
private long mBytes;
|
||||||
|
|
||||||
public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp) {
|
public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp, long size) {
|
||||||
this.path = path;
|
mPath = path;
|
||||||
this.thumbnail = thumbnail;
|
mThumbnail = thumbnail;
|
||||||
this.name = name;
|
mName = name;
|
||||||
this.mediaCnt = mediaCnt;
|
mMediaCnt = mediaCnt;
|
||||||
this.timestamp = timestamp;
|
mTimestamp = timestamp;
|
||||||
|
mBytes = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return path;
|
return mPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getThumbnail() {
|
public String getThumbnail() {
|
||||||
return thumbnail;
|
return mThumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMediaCnt() {
|
public int getMediaCnt() {
|
||||||
return mediaCnt;
|
return mMediaCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMediaCnt(int cnt) {
|
public void setMediaCnt(int cnt) {
|
||||||
mediaCnt = cnt;
|
mMediaCnt = cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
return timestamp;
|
return mTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSize() {
|
||||||
|
return mBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addSize(long bytes) {
|
||||||
|
mBytes += bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Object object) {
|
public int compareTo(Object object) {
|
||||||
final Directory directory = (Directory) object;
|
final Directory directory = (Directory) object;
|
||||||
if (this.timestamp < directory.getTimestamp()) {
|
if (mTimestamp < directory.getTimestamp()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (this.timestamp > directory.getTimestamp()) {
|
} else if (mTimestamp > directory.getTimestamp()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -4,26 +4,26 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class Medium implements Serializable, Comparable {
|
public class Medium implements Serializable, Comparable {
|
||||||
private static final long serialVersionUID = -6543139465975455L;
|
private static final long serialVersionUID = -6543139465975455L;
|
||||||
private final String path;
|
private final String mPath;
|
||||||
private final boolean isVideo;
|
private final boolean mIsVideo;
|
||||||
private final long timestamp;
|
private final long mTimestamp;
|
||||||
|
|
||||||
public Medium(String path, boolean isVideo, long timestamp) {
|
public Medium(String path, boolean isVideo, long timestamp) {
|
||||||
this.path = path;
|
mPath = path;
|
||||||
this.isVideo = isVideo;
|
mIsVideo = isVideo;
|
||||||
this.timestamp = timestamp;
|
mTimestamp = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return path;
|
return mPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getIsVideo() {
|
public boolean getIsVideo() {
|
||||||
return isVideo;
|
return mIsVideo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public long getTimestamp() {
|
||||||
return timestamp;
|
return mTimestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGif() {
|
public boolean isGif() {
|
||||||
|
@ -33,9 +33,9 @@ public class Medium implements Serializable, Comparable {
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Object object) {
|
public int compareTo(Object object) {
|
||||||
final Medium medium = (Medium) object;
|
final Medium medium = (Medium) object;
|
||||||
if (this.timestamp < medium.getTimestamp()) {
|
if (mTimestamp < medium.getTimestamp()) {
|
||||||
return 1;
|
return 1;
|
||||||
} else if (this.timestamp > medium.getTimestamp()) {
|
} else if (mTimestamp > medium.getTimestamp()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
BIN
app/src/main/res/mipmap-hdpi/sort.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/sort.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 205 B |
BIN
app/src/main/res/mipmap-mdpi/sort.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/sort.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 155 B |
BIN
app/src/main/res/mipmap-xhdpi/sort.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/sort.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 175 B |
BIN
app/src/main/res/mipmap-xxhdpi/sort.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/sort.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 213 B |
BIN
app/src/main/res/mipmap-xxxhdpi/sort.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/sort.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 196 B |
|
@ -20,6 +20,12 @@
|
||||||
<string name="setting_wallpaper">Impostazione sfondo</string>
|
<string name="setting_wallpaper">Impostazione sfondo</string>
|
||||||
<string name="open_camera">Apri fotocamera</string>
|
<string name="open_camera">Apri fotocamera</string>
|
||||||
<string name="unknown_error">Riscontrato un errore sconosciuto</string>
|
<string name="unknown_error">Riscontrato un errore sconosciuto</string>
|
||||||
|
<string name="sort_by">Sort by</string>
|
||||||
|
<string name="name">Name</string>
|
||||||
|
<string name="size">Size</string>
|
||||||
|
<string name="date">Date</string>
|
||||||
|
<string name="ascending">Ascending</string>
|
||||||
|
<string name="descending">Descending</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 cartella eliminata</item>
|
<item quantity="one">1 cartella eliminata</item>
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
<string name="setting_wallpaper">壁紙の設定</string>
|
<string name="setting_wallpaper">壁紙の設定</string>
|
||||||
<string name="open_camera">カメラを開く</string>
|
<string name="open_camera">カメラを開く</string>
|
||||||
<string name="unknown_error">不明なエラーが発生しました</string>
|
<string name="unknown_error">不明なエラーが発生しました</string>
|
||||||
|
<string name="sort_by">Sort by</string>
|
||||||
|
<string name="name">Name</string>
|
||||||
|
<string name="size">Size</string>
|
||||||
|
<string name="date">Date</string>
|
||||||
|
<string name="ascending">Ascending</string>
|
||||||
|
<string name="descending">Descending</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 フォルダーを削除しました</item>
|
<item quantity="one">1 フォルダーを削除しました</item>
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
<string name="setting_wallpaper">Inställningar för bakgrundsbild</string>
|
<string name="setting_wallpaper">Inställningar för bakgrundsbild</string>
|
||||||
<string name="open_camera">Starta kameran</string>
|
<string name="open_camera">Starta kameran</string>
|
||||||
<string name="unknown_error">Ett okänt fel har uppstått</string>
|
<string name="unknown_error">Ett okänt fel har uppstått</string>
|
||||||
|
<string name="sort_by">Sort by</string>
|
||||||
|
<string name="name">Name</string>
|
||||||
|
<string name="size">Size</string>
|
||||||
|
<string name="date">Date</string>
|
||||||
|
<string name="ascending">Ascending</string>
|
||||||
|
<string name="descending">Descending</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 mapp borttagen</item>
|
<item quantity="one">1 mapp borttagen</item>
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
<string name="setting_wallpaper">Setting wallpaper</string>
|
<string name="setting_wallpaper">Setting wallpaper</string>
|
||||||
<string name="open_camera">Open camera</string>
|
<string name="open_camera">Open camera</string>
|
||||||
<string name="unknown_error">An unknown error occurred</string>
|
<string name="unknown_error">An unknown error occurred</string>
|
||||||
|
<string name="sort_by">Sort by</string>
|
||||||
|
<string name="name">Name</string>
|
||||||
|
<string name="size">Size</string>
|
||||||
|
<string name="date">Date</string>
|
||||||
|
<string name="ascending">Ascending</string>
|
||||||
|
<string name="descending">Descending</string>
|
||||||
|
|
||||||
<plurals name="folders_deleted">
|
<plurals name="folders_deleted">
|
||||||
<item quantity="one">1 folder deleted</item>
|
<item quantity="one">1 folder deleted</item>
|
||||||
|
|
Loading…
Reference in a new issue