package com.novoda.downloadmanager.lib;

import java.util.ArrayList;
import java.util.Map;

public final class CollatedDownloadInfo {
    private final ArrayList<DownloadInfo> downloadInfos;

    static CollatedDownloadInfo collateInfo(Map<Long, DownloadInfo> mDownloads, DownloadInfo info) {
        CollatedDownloadInfo collatedDownloadInfo = new CollatedDownloadInfo(new ArrayList<DownloadInfo>());
        collatedDownloadInfo.add(info);
        for (Map.Entry<Long, DownloadInfo> entry : mDownloads.entrySet()) {
            DownloadInfo otherInfo = entry.getValue();
            if (info.mId == otherInfo.mId) {
                collatedDownloadInfo.add(otherInfo);
            }
        }
        return collatedDownloadInfo;
    }

    private CollatedDownloadInfo(ArrayList<DownloadInfo> downloadInfos) {
        this.downloadInfos = downloadInfos;
    }

    public void add(DownloadInfo info) {
        downloadInfos.add(info);
    }
}

@@ -62,16 +62,39 @@
 ayList;%0A
+import java.util.List;%0A
 import j
@@ -168,21 +168,16 @@
 e final 
-Array
 List%3CDow
@@ -783,21 +783,16 @@
 oadInfo(
-Array
 List%3CDow
@@ -815,24 +815,24 @@
 oadInfos) %7B%0A
+
         this
@@ -903,32 +903,32 @@
 oadInfo info) %7B%0A
-
         download
@@ -949,11 +949,321 @@
 );%0A    %7D
+%0A%0A    public long getTotalSizeInBytes() %7B%0A        long size = 0L;%0A        int downloadCount = downloadInfos.size();%0A        for (int i = 0; i %3C downloadCount; i++) %7B%0A            DownloadInfo downloadInfo = downloadInfos.get(i);%0A            size += downloadInfo.mTotalBytes;%0A        %7D%0A        return size;%0A    %7D
 %0A%7D%0A

allow the total size of the batch to be known