Moved DownloadStatus class into separate file
This commit is contained in:
parent
51a5902fd9
commit
c41a61752f
@ -11,6 +11,8 @@ import de.podfetcher.feed.Feed;
|
|||||||
import de.podfetcher.storage.DownloadRequester;
|
import de.podfetcher.storage.DownloadRequester;
|
||||||
import de.podfetcher.util.URLChecker;
|
import de.podfetcher.util.URLChecker;
|
||||||
import de.podfetcher.service.DownloadObserver;
|
import de.podfetcher.service.DownloadObserver;
|
||||||
|
import de.podfetcher.service.DownloadStatus;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.SherlockActivity;
|
import com.actionbarsherlock.app.SherlockActivity;
|
||||||
import com.actionbarsherlock.view.Menu;
|
import com.actionbarsherlock.view.Menu;
|
||||||
import com.actionbarsherlock.view.MenuInflater;
|
import com.actionbarsherlock.view.MenuInflater;
|
||||||
@ -83,8 +85,8 @@ public class AddFeedActivity extends SherlockActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(DownloadObserver.DownloadStatus... values) {
|
protected void onProgressUpdate(DownloadStatus... values) {
|
||||||
DownloadObserver.DownloadStatus progr = values[0];
|
DownloadStatus progr = values[0];
|
||||||
progDialog.setMessage(getContext().getString(progr.getStatusMsg())
|
progDialog.setMessage(getContext().getString(progr.getStatusMsg())
|
||||||
+ " (" + progr.getProgressPercent() + "%)");
|
+ " (" + progr.getProgressPercent() + "%)");
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package de.podfetcher.activity;
|
|||||||
import de.podfetcher.storage.DownloadRequester;
|
import de.podfetcher.storage.DownloadRequester;
|
||||||
import de.podfetcher.adapter.DownloadlistAdapter;
|
import de.podfetcher.adapter.DownloadlistAdapter;
|
||||||
import de.podfetcher.service.DownloadObserver;
|
import de.podfetcher.service.DownloadObserver;
|
||||||
|
import de.podfetcher.service.DownloadStatus;
|
||||||
import de.podfetcher.feed.FeedMedia;
|
import de.podfetcher.feed.FeedMedia;
|
||||||
import de.podfetcher.feed.FeedFile;
|
import de.podfetcher.feed.FeedFile;
|
||||||
import com.actionbarsherlock.app.SherlockListActivity;
|
import com.actionbarsherlock.app.SherlockListActivity;
|
||||||
@ -36,7 +37,7 @@ public class DownloadActivity extends SherlockListActivity {
|
|||||||
|
|
||||||
private final DownloadObserver observer = new DownloadObserver(this) {
|
private final DownloadObserver observer = new DownloadObserver(this) {
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(DownloadObserver.DownloadStatus... values) {
|
protected void onProgressUpdate(DownloadStatus... values) {
|
||||||
if (dla != null) {
|
if (dla != null) {
|
||||||
dla.notifyDataSetChanged();
|
dla.notifyDataSetChanged();
|
||||||
} else {
|
} else {
|
||||||
|
@ -22,6 +22,7 @@ import de.podfetcher.feed.FeedMedia;
|
|||||||
import de.podfetcher.fragment.FeedItemlistFragment;
|
import de.podfetcher.fragment.FeedItemlistFragment;
|
||||||
import de.podfetcher.fragment.FeedlistFragment;
|
import de.podfetcher.fragment.FeedlistFragment;
|
||||||
import de.podfetcher.service.DownloadObserver;
|
import de.podfetcher.service.DownloadObserver;
|
||||||
|
import de.podfetcher.service.DownloadStatus;
|
||||||
import de.podfetcher.service.PlaybackService;
|
import de.podfetcher.service.PlaybackService;
|
||||||
import de.podfetcher.storage.DownloadRequester;
|
import de.podfetcher.storage.DownloadRequester;
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ public class ItemviewActivity extends SherlockActivity {
|
|||||||
final DownloadObserver downloadObserver = new DownloadObserver(this) {
|
final DownloadObserver downloadObserver = new DownloadObserver(this) {
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(
|
protected void onProgressUpdate(
|
||||||
DownloadObserver.DownloadStatus... values) {
|
DownloadStatus... values) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,10 +14,11 @@ import de.podfetcher.feed.FeedFile;
|
|||||||
import de.podfetcher.feed.FeedImage;
|
import de.podfetcher.feed.FeedImage;
|
||||||
import de.podfetcher.feed.FeedMedia;
|
import de.podfetcher.feed.FeedMedia;
|
||||||
import de.podfetcher.service.DownloadObserver;
|
import de.podfetcher.service.DownloadObserver;
|
||||||
|
import de.podfetcher.service.DownloadStatus;
|
||||||
|
|
||||||
public class DownloadlistAdapter extends ArrayAdapter<DownloadObserver.DownloadStatus> {
|
public class DownloadlistAdapter extends ArrayAdapter<DownloadStatus> {
|
||||||
public DownloadlistAdapter(Context context,
|
public DownloadlistAdapter(Context context,
|
||||||
int textViewResourceId, DownloadObserver.DownloadStatus[] objects) {
|
int textViewResourceId, DownloadStatus[] objects) {
|
||||||
super(context, textViewResourceId, objects);
|
super(context, textViewResourceId, objects);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ public class DownloadlistAdapter extends ArrayAdapter<DownloadObserver.DownloadS
|
|||||||
@Override
|
@Override
|
||||||
public View getView(int position, View convertView, ViewGroup parent) {
|
public View getView(int position, View convertView, ViewGroup parent) {
|
||||||
Holder holder;
|
Holder holder;
|
||||||
DownloadObserver.DownloadStatus status = getItem(position);
|
DownloadStatus status = getItem(position);
|
||||||
FeedFile feedFile = status.getFeedFile();
|
FeedFile feedFile = status.getFeedFile();
|
||||||
// Inflate layout
|
// Inflate layout
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
|
@ -11,7 +11,7 @@ import java.util.concurrent.Callable;
|
|||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
/** Observes the status of a specific Download */
|
/** Observes the status of a specific Download */
|
||||||
public class DownloadObserver extends AsyncTask<FeedFile, DownloadObserver.DownloadStatus, Boolean> {
|
public class DownloadObserver extends AsyncTask<FeedFile, DownloadStatus, Boolean> {
|
||||||
private static final String TAG = "DownloadObserver";
|
private static final String TAG = "DownloadObserver";
|
||||||
|
|
||||||
/** Types of downloads to observe. */
|
/** Types of downloads to observe. */
|
||||||
@ -79,8 +79,9 @@ public class DownloadObserver extends AsyncTask<FeedFile, DownloadObserver.Downl
|
|||||||
case DownloadManager.STATUS_FAILED:
|
case DownloadManager.STATUS_FAILED:
|
||||||
status.statusMsg = R.string.download_failed;
|
status.statusMsg = R.string.download_failed;
|
||||||
requester.notifyDownloadService(context);
|
requester.notifyDownloadService(context);
|
||||||
status.successful = Boolean.valueOf(false);
|
status.successful = false;
|
||||||
status.done = true;
|
status.done = true;
|
||||||
|
status.reason = getDownloadStatus(cursor, DownloadManager.COLUMN_REASON);
|
||||||
case DownloadManager.STATUS_PENDING:
|
case DownloadManager.STATUS_PENDING:
|
||||||
status.statusMsg = R.string.download_pending;
|
status.statusMsg = R.string.download_pending;
|
||||||
break;
|
break;
|
||||||
@ -151,48 +152,5 @@ public class DownloadObserver extends AsyncTask<FeedFile, DownloadObserver.Downl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Contains status attributes for one download*/
|
|
||||||
public class DownloadStatus {
|
|
||||||
|
|
||||||
protected FeedFile feedfile;
|
|
||||||
protected int progressPercent;
|
|
||||||
protected long soFar;
|
|
||||||
protected long size;
|
|
||||||
protected int statusMsg;
|
|
||||||
protected int reason;
|
|
||||||
protected boolean successful;
|
|
||||||
protected boolean done;
|
|
||||||
|
|
||||||
public DownloadStatus(FeedFile feedfile) {
|
|
||||||
this.feedfile = feedfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
48
src/de/podfetcher/service/DownloadStatus.java
Normal file
48
src/de/podfetcher/service/DownloadStatus.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package de.podfetcher.service;
|
||||||
|
|
||||||
|
import de.podfetcher.feed.FeedFile;
|
||||||
|
|
||||||
|
/** Contains status attributes for one download*/
|
||||||
|
public class DownloadStatus {
|
||||||
|
|
||||||
|
protected FeedFile feedfile;
|
||||||
|
protected int progressPercent;
|
||||||
|
protected long soFar;
|
||||||
|
protected long size;
|
||||||
|
protected int statusMsg;
|
||||||
|
protected int reason;
|
||||||
|
protected boolean successful;
|
||||||
|
protected boolean done;
|
||||||
|
|
||||||
|
public DownloadStatus(FeedFile feedfile) {
|
||||||
|
this.feedfile = feedfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user