summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/asynctask/DownloadStatus.java
blob: 3ec5344a0d74516e663507d0aa43a02ebd55eced (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.asynctask;

import java.util.Date;

import de.danoeh.antennapod.feed.Feed;
import de.danoeh.antennapod.feed.FeedFile;
import de.danoeh.antennapod.feed.FeedImage;
import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.storage.PodDBAdapter;

/** Contains status attributes for one download */
public class DownloadStatus {
	/**
	 * Downloaders should use this constant for the size attribute if necessary
	 * so that the listadapters etc. can react properly.
	 */
	public static final int SIZE_UNKNOWN = -1;

	public Date getCompletionDate() {
		return completionDate;
	}

	// ----------------------------------- ATTRIBUTES STORED IN DB
	/** Unique id for storing the object in database. */
	protected long id;
	/**
	 * A human-readable string which is shown to the user so that he can
	 * identify the download. Should be the title of the item/feed/media or the
	 * URL if the download has no other title.
	 */
	protected String title;
	protected int reason;
	/**
	 * A message which can be presented to the user to give more information.
	 * Should be null if Download was successful.
	 */
	protected String reasonDetailed;
	protected boolean successful;
	protected Date completionDate;
	protected FeedFile feedfile;
	/**
	 * Is used to determine the type of the feedfile even if the feedfile does
	 * not exist anymore. The value should be FEEDFILETYPE_FEED,
	 * FEEDFILETYPE_FEEDIMAGE or FEEDFILETYPE_FEEDMEDIA
	 */
	protected int feedfileType;

	// ------------------------------------ NOT STORED IN DB
	protected int progressPercent;
	protected long soFar;
	protected long size;
	protected int statusMsg;
	protected boolean done;

	public DownloadStatus(FeedFile feedfile, String title) {
		this.feedfile = feedfile;
		this.title = title;
	}

	/** Constructor for restoring Download status entries from DB. */
	public DownloadStatus(long id, String title, FeedFile feedfile, int feedfileType,
			boolean successful, int reason, Date completionDate,
			String reasonDetailed) {
		progressPercent = 100;
		soFar = 0;
		size = 0;

		this.id = id;
		this.title = title;
		this.done = true;
		this.feedfile = feedfile;
		this.reason = reason;
		this.successful = successful;
		this.completionDate = completionDate;
		this.reasonDetailed = reasonDetailed;
		this.feedfileType = feedfileType;
	}

	/** Constructor for creating new completed downloads. */
	public DownloadStatus(FeedFile feedfile, String title, int reason,
			boolean successful, String reasonDetailed) {
		this(0, title, feedfile, feedfile.getTypeAsInt(), successful, reason, new Date(), reasonDetailed);
	}

	public FeedFile getFeedFile() {
		return feedfile;
	}

	public int getProgressPercent() {
		return progressPercent;
	}

	public long getSoFar() {
		return soFar;
	}

	public long getSize() {
		return size;
	}

	public int getStatusMsg() {
		return statusMsg;
	}

	public int getReason() {
		return reason;
	}

	public boolean isSuccessful() {
		return successful;
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public boolean isDone() {
		return done;
	}

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

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

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

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

	public void setReason(int reason) {
		this.reason = reason;
	}

	public void setSuccessful(boolean successful) {
		this.successful = successful;
	}

	public void setDone(boolean done) {
		this.done = done;
	}

	public void setCompletionDate(Date completionDate) {
		this.completionDate = completionDate;
	}

	public String getReasonDetailed() {
		return reasonDetailed;
	}

	public void setReasonDetailed(String reasonDetailed) {
		this.reasonDetailed = reasonDetailed;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getFeedfileType() {
		return feedfileType;
	}

}