package com.liulishuo.filedownloader.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.liulishuo.filedownloader.util.FileDownloadUtils;

import java.util.List;

/**
 * Created by Jacksgong on 4/21/16.
 * <p/>
 * The Minimal unit for a task.
 * <p/>
 * Used for telling the FileDownloader Engine that a task was downloaded by the other ways.
 *
 * @see com.liulishuo.filedownloader.FileDownloader#setTaskCompleted(List)
 */
public class FileDownloadTaskAtom implements Parcelable {
    private String url;
    private String path;
    private long totalBytes;

    public FileDownloadTaskAtom(String url, String path, long totalBytes) {
        setUrl(url);
        setPath(path);
        setTotalBytes(totalBytes);
    }

    private int id;

    public int getId() {
        if (id != 0) {
            return id;
        }

        return id = FileDownloadUtils.generateId(getUrl(), getPath());
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public long getTotalBytes() {
        return totalBytes;
    }

    public void setTotalBytes(long totalBytes) {
        this.totalBytes = totalBytes;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.url);
        dest.writeString(this.path);
        dest.writeLong(this.totalBytes);
    }

    protected FileDownloadTaskAtom(Parcel in) {
        this.url = in.readString();
        this.path = in.readString();
        this.totalBytes = in.readLong();
    }

    public static final Parcelable.Creator<FileDownloadTaskAtom> CREATOR = new Parcelable.Creator<FileDownloadTaskAtom>() {
        @Override
        public FileDownloadTaskAtom createFromParcel(Parcel source) {
            return new FileDownloadTaskAtom(source);
        }

        @Override
        public FileDownloadTaskAtom[] newArray(int size) {
            return new FileDownloadTaskAtom[size];
        }
    };
}

@@ -1,8 +1,610 @@
+/*%0A * Copyright (c) 2015 LingoChamp Inc.%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
 package 

add license header to FileDownloadTaskAtom