summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/service/download/DownloadRequest.java
blob: 1f4e32e1b3b4af9660fe8b9b9fcc0c3eb5fff9dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
package de.danoeh.antennapod.service.download;

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

public class DownloadRequest implements Parcelable {

	private final String destination;
	private final String source;
	private final String title;
	private final long feedfileId;
	private final int feedfileType;

	protected int progressPercent;
	protected long soFar;
	protected long size;
	protected int statusMsg;

	public DownloadRequest(String destination, String source, String title,
			long feedfileId, int feedfileType) {
		if (destination == null) {
			throw new IllegalArgumentException("Destination must not be null");
		}
		if (source == null) {
			throw new IllegalArgumentException("Source must not be null");
		}
		if (title == null) {
			throw new IllegalArgumentException("Title must not be null");
		}

		this.destination = destination;
		this.source = source;
		this.title = title;
		this.feedfileId = feedfileId;
		this.feedfileType = feedfileType;
	}

	private DownloadRequest(Parcel in) {
		destination = in.readString();
		source = in.readString();
		title = in.readString();
		feedfileId = in.readLong();
		feedfileType = in.readInt();
	}

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

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(destination);
		dest.writeString(source);
		dest.writeString(title);
		dest.writeLong(feedfileId);
		dest.writeInt(feedfileType);
	}

	public static final Parcelable.Creator<DownloadRequest> CREATOR = new Parcelable.Creator<DownloadRequest>() {
		public DownloadRequest createFromParcel(Parcel in) {
			return new DownloadRequest(in);
		}

		public DownloadRequest[] newArray(int size) {
			return new DownloadRequest[size];
		}
	};

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((destination == null) ? 0 : destination.hashCode());
		result = prime * result + (int) (feedfileId ^ (feedfileId >>> 32));
		result = prime * result + feedfileType;
		result = prime * result + progressPercent;
		result = prime * result + (int) (size ^ (size >>> 32));
		result = prime * result + (int) (soFar ^ (soFar >>> 32));
		result = prime * result + ((source == null) ? 0 : source.hashCode());
		result = prime * result + statusMsg;
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DownloadRequest other = (DownloadRequest) obj;
		if (destination == null) {
			if (other.destination != null)
				return false;
		} else if (!destination.equals(other.destination))
			return false;
		if (feedfileId != other.feedfileId)
			return false;
		if (feedfileType != other.feedfileType)
			return false;
		if (progressPercent != other.progressPercent)
			return false;
		if (size != other.size)
			return false;
		if (soFar != other.soFar)
			return false;
		if (source == null) {
			if (other.source != null)
				return false;
		} else if (!source.equals(other.source))
			return false;
		if (statusMsg != other.statusMsg)
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		return true;
	}

	public String getDestination() {
		return destination;
	}

	public String getSource() {
		return source;
	}

	public String getTitle() {
		return title;
	}

	public long getFeedfileId() {
		return feedfileId;
	}

	public int getFeedfileType() {
		return feedfileType;
	}

	public int getProgressPercent() {
		return progressPercent;
	}

	public void setProgressPercent(int progressPercent) {
		this.progressPercent = progressPercent;
	}

	public long getSoFar() {
		return soFar;
	}

	public void setSoFar(long soFar) {
		this.soFar = soFar;
	}

	public long getSize() {
		return size;
	}

	public void setSize(long size) {
		this.size = size;
	}

	public int getStatusMsg() {
		return statusMsg;
	}

	public void setStatusMsg(int statusMsg) {
		this.statusMsg = statusMsg;
	}
}