Removed unneeded todo's, add docs.
This commit is contained in:
parent
75586ec4e5
commit
d9e5b07054
@ -31,6 +31,11 @@ import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* Downloads and verifies (against the Apk.hash) the apk file.
|
||||
* If the file has previously been downloaded, it will make use of that
|
||||
* instead, without going to the network to download a new one.
|
||||
*/
|
||||
public class ApkDownloader implements AsyncDownloadWrapper.Listener {
|
||||
|
||||
private static final String TAG = "org.fdroid.fdroid.net.ApkDownloader";
|
||||
@ -71,7 +76,9 @@ public class ApkDownloader implements AsyncDownloadWrapper.Listener {
|
||||
localFile = new File(destDir, curApk.apkName);
|
||||
}
|
||||
|
||||
// The downloaded APK. Valid only when getStatus() has returned STATUS.DONE.
|
||||
/**
|
||||
* The downloaded APK. Valid only when getStatus() has returned STATUS.DONE.
|
||||
*/
|
||||
public File localFile() {
|
||||
return localFile;
|
||||
}
|
||||
|
@ -8,6 +8,13 @@ import org.fdroid.fdroid.ProgressListener;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Given a {@link org.fdroid.fdroid.net.Downloader}, this wrapper will conduct the download operation on a
|
||||
* separate thread. All progress/status/error/etc events will be forwarded from that thread to the thread
|
||||
* that {@link AsyncDownloadWrapper#download()} was invoked on. If you want to respond with UI feedback
|
||||
* to these events, it is important that you execute the download method of this class from the UI thread.
|
||||
* That way, all forwarded events will be handled on that thread.
|
||||
*/
|
||||
public class AsyncDownloadWrapper extends Handler {
|
||||
|
||||
private static final String TAG = "org.fdroid.fdroid.net.AsyncDownloadWrapper";
|
||||
@ -71,6 +78,11 @@ public class AsyncDownloadWrapper extends Handler {
|
||||
downloadThread.interrupt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Receives "messages" from the download thread, and passes them onto the
|
||||
* relevant {@link org.fdroid.fdroid.net.AsyncDownloadWrapper.Listener}
|
||||
* @param message
|
||||
*/
|
||||
public void handleMessage(Message message) {
|
||||
if (message.arg1 == MSG_PROGRESS) {
|
||||
Bundle data = message.getData();
|
||||
|
@ -47,15 +47,6 @@ public abstract class Downloader {
|
||||
outputStream = new FileOutputStream(outputFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads to a temporary file, which *you must delete yourself when
|
||||
* you are done*.
|
||||
* @see org.fdroid.fdroid.net.Downloader#getFile()
|
||||
*/
|
||||
public Downloader(File destFile, Context ctx) throws IOException {
|
||||
// TODO: Reimplement (is it still necessary? In what context was it being used before?)
|
||||
}
|
||||
|
||||
public Downloader(OutputStream output)
|
||||
throws MalformedURLException {
|
||||
outputStream = output;
|
||||
@ -158,8 +149,6 @@ public abstract class Downloader {
|
||||
*/
|
||||
private void throwExceptionIfInterrupted() throws InterruptedException {
|
||||
if (Thread.interrupted()) {
|
||||
// TODO: Do we need to provide more information to whoever needs it,
|
||||
// so they can, for example, remove any partially created files?
|
||||
Log.d(TAG, "Received interrupt, cancelling download");
|
||||
throw new InterruptedException();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user