Show total size when sorting on size

This commit is contained in:
M66B 2019-04-05 08:57:50 +02:00
parent 423d026cad
commit 6c0183d8ea
3 changed files with 14 additions and 2 deletions

View File

@ -517,8 +517,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ivExpander.setVisibility(View.GONE);
// Line 1
tvSize.setText(message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
tvSize.setVisibility(message.size == null || message.content ? View.GONE : View.VISIBLE);
Long size = ("size".equals(sort) ? message.totalSize : message.size);
tvSize.setText(size == null ? null : Helper.humanReadableByteCount(size, true));
tvSize.setVisibility(size == null || (message.content && !"size".equals(sort)) ? View.GONE : View.VISIBLE);
tvTime.setText(date && "time".equals(sort)
? tf.format(message.received)
: DateUtils.getRelativeTimeSpanString(context, message.received));
@ -3060,7 +3061,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
void setSort(String sort) {
if (!sort.equals(this.sort)) {
boolean update = ("size".equals(this.sort) || "size".equals(sort));
this.sort = sort;
if (update)
notifyDataSetChanged();
// loadMessages will be called
}
}

View File

@ -56,6 +56,7 @@ public interface DaoMessage {
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
", SUM(CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END) AS drafts" +
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
", SUM(message.size) AS totalSize" +
", MAX(CASE WHEN :found OR folder.unified THEN message.received ELSE 0 END) AS dummy" +
" FROM message" +
" JOIN account ON account.id = message.account" +
@ -98,6 +99,7 @@ public interface DaoMessage {
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
", SUM(CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END) AS drafts" +
", COUNT(DISTINCT CASE WHEN message.msgid IS NULL THEN message.id ELSE message.msgid END) AS visible" +
", SUM(message.size) AS totalSize" +
", MAX(CASE WHEN folder.id = :folder THEN message.received ELSE 0 END) AS dummy" +
" FROM message" +
" JOIN account ON account.id = message.account" +
@ -132,6 +134,7 @@ public interface DaoMessage {
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
", CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END AS drafts" +
", 1 AS visible" +
", message.size AS totalSize" +
" FROM message" +
" JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" +
@ -204,6 +207,7 @@ public interface DaoMessage {
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
", CASE WHEN folder.type = '" + EntityFolder.DRAFTS + "' THEN 1 ELSE 0 END AS drafts" +
", 1 AS visible" +
", message.size AS totalSize" +
" FROM message" +
" JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" +
@ -221,6 +225,7 @@ public interface DaoMessage {
", 0 AS attachments" +
", 0 AS drafts" +
", 1 AS visible" +
", message.size AS totalSize" +
" FROM message" +
" JOIN account ON account.id = message.account" +
" LEFT JOIN identity ON identity.id = message.identity" +

View File

@ -39,6 +39,7 @@ public class TupleMessageEx extends EntityMessage {
public int attachments;
public int drafts;
public int visible;
public Long totalSize;
@Ignore
public boolean duplicate;
@ -62,6 +63,7 @@ public class TupleMessageEx extends EntityMessage {
this.attachments == other.attachments &&
this.drafts == other.drafts &&
this.visible == other.visible &&
Objects.equals(this.totalSize, other.totalSize) &&
this.duplicate == other.duplicate);
}
return false;
@ -83,6 +85,7 @@ public class TupleMessageEx extends EntityMessage {
this.unflagged == other.unflagged &&
this.attachments == other.attachments &&
this.visible == other.visible &&
Objects.equals(this.totalSize, other.totalSize) &&
this.duplicate == other.duplicate);
}
return false;