calculate the size of directories

+ adding some initial sorting things
This commit is contained in:
tibbi 2016-07-24 16:34:45 +02:00
parent 0c9fe0e4c3
commit fddaea76c3
12 changed files with 66 additions and 31 deletions

View file

@ -210,9 +210,10 @@ public class MainActivity extends SimpleActivity
final Directory directory = directories.get(fileDir);
final int newImageCnt = directory.getMediaCnt() + 1;
directory.setMediaCnt(newImageCnt);
directory.addSize(file.length());
} else if (!mToBeDeleted.contains(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());
cursor.close();

View file

@ -1,50 +1,60 @@
package com.simplemobiletools.gallery.models;
public class Directory implements Comparable {
private final String path;
private final String thumbnail;
private final String name;
private final long timestamp;
private int mediaCnt;
private final String mPath;
private final String mThumbnail;
private final String mName;
private final long mTimestamp;
private int mMediaCnt;
private long mBytes;
public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp) {
this.path = path;
this.thumbnail = thumbnail;
this.name = name;
this.mediaCnt = mediaCnt;
this.timestamp = timestamp;
public Directory(String path, String thumbnail, String name, int mediaCnt, long timestamp, long size) {
mPath = path;
mThumbnail = thumbnail;
mName = name;
mMediaCnt = mediaCnt;
mTimestamp = timestamp;
mBytes = size;
}
public String getPath() {
return path;
return mPath;
}
public String getThumbnail() {
return thumbnail;
return mThumbnail;
}
public String getName() {
return name;
return mName;
}
public int getMediaCnt() {
return mediaCnt;
return mMediaCnt;
}
public void setMediaCnt(int cnt) {
mediaCnt = cnt;
mMediaCnt = cnt;
}
public long getTimestamp() {
return timestamp;
return mTimestamp;
}
public long getSize() {
return mBytes;
}
public void addSize(long bytes) {
mBytes += bytes;
}
@Override
public int compareTo(Object object) {
final Directory directory = (Directory) object;
if (this.timestamp < directory.getTimestamp()) {
if (mTimestamp < directory.getTimestamp()) {
return 1;
} else if (this.timestamp > directory.getTimestamp()) {
} else if (mTimestamp > directory.getTimestamp()) {
return -1;
}
return 0;

View file

@ -4,26 +4,26 @@ import java.io.Serializable;
public class Medium implements Serializable, Comparable {
private static final long serialVersionUID = -6543139465975455L;
private final String path;
private final boolean isVideo;
private final long timestamp;
private final String mPath;
private final boolean mIsVideo;
private final long mTimestamp;
public Medium(String path, boolean isVideo, long timestamp) {
this.path = path;
this.isVideo = isVideo;
this.timestamp = timestamp;
mPath = path;
mIsVideo = isVideo;
mTimestamp = timestamp;
}
public String getPath() {
return path;
return mPath;
}
public boolean getIsVideo() {
return isVideo;
return mIsVideo;
}
public long getTimestamp() {
return timestamp;
return mTimestamp;
}
public boolean isGif() {
@ -33,9 +33,9 @@ public class Medium implements Serializable, Comparable {
@Override
public int compareTo(Object object) {
final Medium medium = (Medium) object;
if (this.timestamp < medium.getTimestamp()) {
if (mTimestamp < medium.getTimestamp()) {
return 1;
} else if (this.timestamp > medium.getTimestamp()) {
} else if (mTimestamp > medium.getTimestamp()) {
return -1;
}
return 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 175 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

View file

@ -20,6 +20,12 @@
<string name="setting_wallpaper">Impostazione sfondo</string>
<string name="open_camera">Apri fotocamera</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">
<item quantity="one">1 cartella eliminata</item>

View file

@ -20,6 +20,12 @@
<string name="setting_wallpaper">壁紙の設定</string>
<string name="open_camera">カメラを開く</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">
<item quantity="one">1 フォルダーを削除しました</item>

View file

@ -20,6 +20,12 @@
<string name="setting_wallpaper">Inställningar för bakgrundsbild</string>
<string name="open_camera">Starta kameran</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">
<item quantity="one">1 mapp borttagen</item>

View file

@ -20,6 +20,12 @@
<string name="setting_wallpaper">Setting wallpaper</string>
<string name="open_camera">Open camera</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">
<item quantity="one">1 folder deleted</item>