@@ -0,0 +1,1860 @@
+/*%0A * Copyright 2014 Eric Liu%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.liuguangqiang.download.core;%0A%0Aimport android.util.Log;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by Eric on 14-8-15.%0A */%0Apublic class DownloadQueue %7B%0A%0A    private final static String TAG = %22DownloadQueue%22;%0A%0A    private List%3CDownloadTask%3E queue;%0A%0A    public DownloadQueue() %7B%0A        queue = new ArrayList%3CDownloadTask%3E();%0A    %7D%0A%0A    public int size() %7B%0A        if (isEmpty())%0A            return 0;%0A        return queue.size();%0A    %7D%0A%0A    public boolean isEmpty() %7B%0A        if (queue == null)%0A            return true;%0A        return queue.isEmpty();%0A    %7D%0A%0A    public void add(DownloadTask task) %7B%0A        if (queue == null) return;%0A        queue.add(0, task);%0A    %7D%0A%0A    public void cancel(String downloadUrl) %7B%0A        Log.i(%22DownloadQueue%22, %22cancel%22);%0A%0A//        List%3CDownloadTask%3E temps=new ArrayList%3CDownloadTask%3E();%0A%0A        if (!isEmpty()) %7B%0A            for (DownloadTask task : queue) %7B%0A                if (task.getDownloadParams().getUrl().equals(downloadUrl)) %7B%0A                    task.cancel();%0A//                    temps.add(task);%0A                %7D%0A            %7D%0A        %7D%0A%0A//        queue.removeAll(temps);%0A//        temps.clear();%0A//        temps=null;%0A//        Log.i(%22DownloadQueue%22, %22size:%22+size());%0A    %7D%0A%0A%0A%7D%0A

Create DownloadQueue for saving DownloadTask.