Generate download clients using a builder class
This change allows to define a proper interface for the download client and keep its implementation completely separate. It also allows to create clients without starting the download right away, which could be useful when defining callbacks that require a reference to the client. Note that this change also drops the unused methods of DownloadClient.
This commit is contained in:
@@ -40,6 +40,7 @@ import org.json.JSONException;
|
|||||||
import org.lineageos.updater.controller.UpdaterController;
|
import org.lineageos.updater.controller.UpdaterController;
|
||||||
import org.lineageos.updater.controller.UpdaterControllerInt;
|
import org.lineageos.updater.controller.UpdaterControllerInt;
|
||||||
import org.lineageos.updater.controller.UpdaterService;
|
import org.lineageos.updater.controller.UpdaterService;
|
||||||
|
import org.lineageos.updater.download.DownloadClient;
|
||||||
import org.lineageos.updater.misc.Constants;
|
import org.lineageos.updater.misc.Constants;
|
||||||
import org.lineageos.updater.misc.LegacySupport;
|
import org.lineageos.updater.misc.LegacySupport;
|
||||||
import org.lineageos.updater.misc.Utils;
|
import org.lineageos.updater.misc.Utils;
|
||||||
@@ -264,8 +265,12 @@ public class UpdatesActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final DownloadClient downloadClient =
|
final DownloadClient downloadClient = new DownloadClient.Builder()
|
||||||
DownloadClient.downloadFile(url, jsonFileTmp, callback);
|
.setUrl(url)
|
||||||
|
.setDestination(jsonFileTmp)
|
||||||
|
.setDownloadCallback(callback)
|
||||||
|
.build();
|
||||||
|
|
||||||
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
progressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
@@ -274,6 +279,7 @@ public class UpdatesActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
progressDialog.show();
|
progressDialog.show();
|
||||||
|
downloadClient.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showSnackBar(int stringId, int duration) {
|
private void showSnackBar(int stringId, int duration) {
|
||||||
|
@@ -28,6 +28,7 @@ import android.support.v7.app.NotificationCompat;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
import org.lineageos.updater.download.DownloadClient;
|
||||||
import org.lineageos.updater.misc.Constants;
|
import org.lineageos.updater.misc.Constants;
|
||||||
import org.lineageos.updater.misc.Utils;
|
import org.lineageos.updater.misc.Utils;
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
|
|||||||
final File json = Utils.getCachedUpdateList(context);
|
final File json = Utils.getCachedUpdateList(context);
|
||||||
final File jsonNew = new File(json.getAbsolutePath() + ".tmp");
|
final File jsonNew = new File(json.getAbsolutePath() + ".tmp");
|
||||||
String url = Utils.getServerURL(context);
|
String url = Utils.getServerURL(context);
|
||||||
DownloadClient.downloadFile(url, jsonNew, new DownloadClient.DownloadCallback() {
|
DownloadClient.DownloadCallback callback = new DownloadClient.DownloadCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(boolean cancelled) {
|
public void onFailure(boolean cancelled) {
|
||||||
Log.e(TAG, "Could not download updates list, scheduling new check");
|
Log.e(TAG, "Could not download updates list, scheduling new check");
|
||||||
@@ -91,7 +92,14 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
|
|||||||
scheduleUpdatesCheck(context);
|
scheduleUpdatesCheck(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
DownloadClient downloadClient = new DownloadClient.Builder()
|
||||||
|
.setUrl(url)
|
||||||
|
.setDestination(jsonNew)
|
||||||
|
.setDownloadCallback(callback)
|
||||||
|
.build();
|
||||||
|
downloadClient.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,10 +23,10 @@ import android.os.SystemClock;
|
|||||||
import android.support.v4.content.LocalBroadcastManager;
|
import android.support.v4.content.LocalBroadcastManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.lineageos.updater.DownloadClient;
|
|
||||||
import org.lineageos.updater.UpdateDownload;
|
import org.lineageos.updater.UpdateDownload;
|
||||||
import org.lineageos.updater.UpdateStatus;
|
import org.lineageos.updater.UpdateStatus;
|
||||||
import org.lineageos.updater.UpdatesDbHelper;
|
import org.lineageos.updater.UpdatesDbHelper;
|
||||||
|
import org.lineageos.updater.download.DownloadClient;
|
||||||
import org.lineageos.updater.misc.Utils;
|
import org.lineageos.updater.misc.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -345,11 +345,13 @@ public class UpdaterController implements UpdaterControllerInt {
|
|||||||
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
UpdateDownload update = mDownloads.get(downloadId).mUpdate;
|
||||||
File destination = new File(mDownloadRoot, update.getName());
|
File destination = new File(mDownloadRoot, update.getName());
|
||||||
update.setFile(destination);
|
update.setFile(destination);
|
||||||
DownloadClient downloadClient =
|
DownloadClient downloadClient = new DownloadClient.Builder()
|
||||||
DownloadClient.downloadFile(update.getDownloadUrl(),
|
.setUrl(update.getDownloadUrl())
|
||||||
update.getFile(),
|
.setDestination(update.getFile())
|
||||||
getDownloadCallback(downloadId),
|
.setDownloadCallback(getDownloadCallback(downloadId))
|
||||||
getProgressListener(downloadId));
|
.setProgressListener(getProgressListener(downloadId))
|
||||||
|
.build();
|
||||||
|
downloadClient.start();
|
||||||
addDownloadClient(mDownloads.get(downloadId), downloadClient);
|
addDownloadClient(mDownloads.get(downloadId), downloadClient);
|
||||||
update.setStatus(UpdateStatus.STARTING);
|
update.setStatus(UpdateStatus.STARTING);
|
||||||
notifyUpdateChange(downloadId);
|
notifyUpdateChange(downloadId);
|
||||||
@@ -371,11 +373,13 @@ public class UpdaterController implements UpdaterControllerInt {
|
|||||||
verifyUpdateAsync(downloadId);
|
verifyUpdateAsync(downloadId);
|
||||||
notifyUpdateChange(downloadId);
|
notifyUpdateChange(downloadId);
|
||||||
} else {
|
} else {
|
||||||
DownloadClient downloadClient =
|
DownloadClient downloadClient = new DownloadClient.Builder()
|
||||||
DownloadClient.downloadFileResume(update.getDownloadUrl(),
|
.setUrl(update.getDownloadUrl())
|
||||||
update.getFile(),
|
.setDestination(update.getFile())
|
||||||
getDownloadCallback(downloadId),
|
.setDownloadCallback(getDownloadCallback(downloadId))
|
||||||
getProgressListener(downloadId));
|
.setProgressListener(getProgressListener(downloadId))
|
||||||
|
.build();
|
||||||
|
downloadClient.resume();
|
||||||
addDownloadClient(mDownloads.get(downloadId), downloadClient);
|
addDownloadClient(mDownloads.get(downloadId), downloadClient);
|
||||||
update.setStatus(UpdateStatus.STARTING);
|
update.setStatus(UpdateStatus.STARTING);
|
||||||
notifyUpdateChange(downloadId);
|
notifyUpdateChange(downloadId);
|
||||||
|
85
src/org/lineageos/updater/download/DownloadClient.java
Normal file
85
src/org/lineageos/updater/download/DownloadClient.java
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 The LineageOS Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.lineageos.updater.download;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface DownloadClient {
|
||||||
|
|
||||||
|
interface DownloadCallback {
|
||||||
|
void onResponse(int statusCode, String url, Headers headers);
|
||||||
|
|
||||||
|
void onSuccess(String body);
|
||||||
|
|
||||||
|
void onFailure(boolean cancelled);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProgressListener {
|
||||||
|
void update(long bytesRead, long contentLength, long speed, long eta, boolean done);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Headers {
|
||||||
|
String get(String name);
|
||||||
|
|
||||||
|
Map<String, List<String>> getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
void start();
|
||||||
|
|
||||||
|
void resume();
|
||||||
|
|
||||||
|
void cancel();
|
||||||
|
|
||||||
|
final class Builder {
|
||||||
|
private String mUrl;
|
||||||
|
private File mDestination;
|
||||||
|
private DownloadClient.DownloadCallback mCallback;
|
||||||
|
private DownloadClient.ProgressListener mProgressListener;
|
||||||
|
|
||||||
|
public DownloadClient build() {
|
||||||
|
if (mUrl == null) {
|
||||||
|
throw new IllegalStateException("No download URL defined");
|
||||||
|
} else if (mDestination == null) {
|
||||||
|
throw new IllegalStateException("No download destination defined");
|
||||||
|
} else if (mCallback == null) {
|
||||||
|
throw new IllegalStateException("No download callback defined");
|
||||||
|
}
|
||||||
|
return new OkHttpDownloadClient(mUrl, mDestination, mProgressListener, mCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setUrl(String url) {
|
||||||
|
mUrl = url;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDestination(File destination) {
|
||||||
|
mDestination = destination;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setDownloadCallback(DownloadClient.DownloadCallback downloadCallback) {
|
||||||
|
mCallback = downloadCallback;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setProgressListener(DownloadClient.ProgressListener progressListener) {
|
||||||
|
mProgressListener = progressListener;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.lineageos.updater;
|
package org.lineageos.updater.download;
|
||||||
|
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -22,12 +22,12 @@ import com.android.okhttp.Callback;
|
|||||||
import com.android.okhttp.Interceptor;
|
import com.android.okhttp.Interceptor;
|
||||||
import com.android.okhttp.MediaType;
|
import com.android.okhttp.MediaType;
|
||||||
import com.android.okhttp.OkHttpClient;
|
import com.android.okhttp.OkHttpClient;
|
||||||
|
import com.android.okhttp.Request;
|
||||||
import com.android.okhttp.Response;
|
import com.android.okhttp.Response;
|
||||||
import com.android.okhttp.ResponseBody;
|
import com.android.okhttp.ResponseBody;
|
||||||
import com.android.okhttp.Request;
|
import com.android.okhttp.okio.Buffer;
|
||||||
import com.android.okhttp.okio.BufferedSink;
|
import com.android.okhttp.okio.BufferedSink;
|
||||||
import com.android.okhttp.okio.BufferedSource;
|
import com.android.okhttp.okio.BufferedSource;
|
||||||
import com.android.okhttp.okio.Buffer;
|
|
||||||
import com.android.okhttp.okio.ForwardingSource;
|
import com.android.okhttp.okio.ForwardingSource;
|
||||||
import com.android.okhttp.okio.Okio;
|
import com.android.okhttp.okio.Okio;
|
||||||
import com.android.okhttp.okio.Source;
|
import com.android.okhttp.okio.Source;
|
||||||
@@ -37,71 +37,78 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class DownloadClient {
|
class OkHttpDownloadClient implements DownloadClient {
|
||||||
|
|
||||||
private static final String TAG = "DownloadClient";
|
private static final String TAG = "DownloadClient";
|
||||||
|
|
||||||
private final Object DOWNLOAD_TAG = new Object();
|
private final Object DOWNLOAD_TAG = new Object();
|
||||||
|
|
||||||
|
private final OkHttpClient mClient = new OkHttpClient();
|
||||||
|
|
||||||
|
private final String mUrl;
|
||||||
|
private final File mDestination;
|
||||||
|
private final DownloadClient.ProgressListener mProgressListener;
|
||||||
|
private final DownloadClient.DownloadCallback mCallback;
|
||||||
|
private long mResumeOffset = 0;
|
||||||
|
|
||||||
|
private boolean mDownloading = false;
|
||||||
private boolean mCancelled = false;
|
private boolean mCancelled = false;
|
||||||
|
|
||||||
public interface DownloadCallback {
|
public class Headers implements DownloadClient.Headers {
|
||||||
void onResponse(int statusCode, String url, Headers headers);
|
|
||||||
void onSuccess(String body);
|
|
||||||
void onFailure(boolean cancelled);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ProgressListener {
|
|
||||||
void update(long bytesRead, long contentLength, long speed, long eta, boolean done);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Headers {
|
|
||||||
private com.android.okhttp.Headers mHeaders;
|
private com.android.okhttp.Headers mHeaders;
|
||||||
|
|
||||||
private Headers(com.android.okhttp.Headers headers) {
|
private Headers(com.android.okhttp.Headers headers) {
|
||||||
mHeaders = headers;
|
mHeaders = headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String get(String name) {
|
public String get(String name) {
|
||||||
return mHeaders.get(name);
|
return mHeaders.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Map<String, List<String>> getAll() {
|
public Map<String, List<String>> getAll() {
|
||||||
return mHeaders.toMultimap();
|
return mHeaders.toMultimap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final OkHttpClient mClient = new OkHttpClient();
|
OkHttpDownloadClient(String url, File destination,
|
||||||
|
DownloadClient.ProgressListener progressListener,
|
||||||
private long mResumeOffset = 0;
|
DownloadClient.DownloadCallback callback) {
|
||||||
|
mUrl = url;
|
||||||
private DownloadClient() { }
|
mDestination = destination;
|
||||||
|
mProgressListener = progressListener;
|
||||||
public static void download(String url, DownloadCallback callback) {
|
mCallback = callback;
|
||||||
DownloadClient downloadClient = new DownloadClient();
|
|
||||||
downloadClient.downloadInternal(url, callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DownloadClient downloadFile(String url, File destination,
|
@Override
|
||||||
DownloadCallback callback, ProgressListener progressListener) {
|
public void start() {
|
||||||
DownloadClient downloadClient = new DownloadClient();
|
if (mDownloading) {
|
||||||
downloadClient.downloadFileInternal(url, destination, callback, progressListener);
|
Log.e(TAG, "Already downloading");
|
||||||
return downloadClient;
|
return;
|
||||||
|
}
|
||||||
|
mCancelled = false;
|
||||||
|
mDownloading = true;
|
||||||
|
downloadFileInternal(mCallback, mProgressListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DownloadClient downloadFile(String url, File destination,
|
@Override
|
||||||
DownloadCallback callback) {
|
public void resume() {
|
||||||
return downloadFile(url, destination, callback, null);
|
if (mDownloading) {
|
||||||
}
|
Log.e(TAG, "Already downloading");
|
||||||
|
return;
|
||||||
public static DownloadClient downloadFileResume(String url, File destination,
|
}
|
||||||
DownloadCallback callback, ProgressListener progressListener) {
|
mCancelled = false;
|
||||||
DownloadClient downloadClient = new DownloadClient();
|
mDownloading = true;
|
||||||
downloadClient.downloadFileResumeInternal(url, destination, callback, progressListener);
|
downloadFileResumeInternal(mCallback, mProgressListener);
|
||||||
return downloadClient;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
|
if (!mDownloading) {
|
||||||
|
Log.e(TAG, "Not downloading");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mDownloading = false;
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -111,57 +118,33 @@ public class DownloadClient {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadInternal(String url, final DownloadCallback callback) {
|
private void downloadFileInternal(final DownloadClient.DownloadCallback callback,
|
||||||
|
final DownloadClient.ProgressListener progressListener) {
|
||||||
final Request request = new Request.Builder()
|
final Request request = new Request.Builder()
|
||||||
.url(url)
|
.url(mUrl)
|
||||||
.build();
|
|
||||||
|
|
||||||
mClient.newCall(request).enqueue(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(Request request, IOException e) {
|
|
||||||
Log.d(TAG, "Download failed, cancelled=" + mCancelled, e);
|
|
||||||
callback.onFailure(mCancelled);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(Response response) {
|
|
||||||
try {
|
|
||||||
callback.onResponse(response.code(), response.request().urlString(),
|
|
||||||
new Headers(response.headers()));
|
|
||||||
callback.onSuccess(response.body().string());
|
|
||||||
} catch (IOException e) {
|
|
||||||
onFailure(request, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void downloadFileInternal(String url, final File destination,
|
|
||||||
final DownloadCallback callback, final ProgressListener progressListener) {
|
|
||||||
final Request request = new Request.Builder()
|
|
||||||
.url(url)
|
|
||||||
.tag(DOWNLOAD_TAG)
|
.tag(DOWNLOAD_TAG)
|
||||||
.build();
|
.build();
|
||||||
downloadFileInternalCommon(request, destination, callback, progressListener);
|
downloadFileInternalCommon(request, callback, progressListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFileResumeInternal(String url, final File destination,
|
private void downloadFileResumeInternal(final DownloadClient.DownloadCallback callback,
|
||||||
final DownloadCallback callback, final ProgressListener progressListener) {
|
final DownloadClient.ProgressListener progressListener) {
|
||||||
final Request.Builder requestBuilder = new Request.Builder()
|
final Request.Builder requestBuilder = new Request.Builder()
|
||||||
.url(url)
|
.url(mUrl)
|
||||||
.tag(DOWNLOAD_TAG);
|
.tag(DOWNLOAD_TAG);
|
||||||
long offset = destination.length();
|
long offset = mDestination.length();
|
||||||
requestBuilder.addHeader("Range", "bytes=" + offset + "-");
|
requestBuilder.addHeader("Range", "bytes=" + offset + "-");
|
||||||
final Request request = requestBuilder.build();
|
final Request request = requestBuilder.build();
|
||||||
downloadFileInternalCommon(request, destination, callback, progressListener);
|
downloadFileInternalCommon(request, callback, progressListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSuccessful(int statusCode) {
|
private boolean isSuccessful(int statusCode) {
|
||||||
return (statusCode / 100) == 2;
|
return (statusCode / 100) == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void downloadFileInternalCommon(final Request request, final File destination,
|
private void downloadFileInternalCommon(final Request request,
|
||||||
final DownloadCallback callback, final ProgressListener progressListener) {
|
final DownloadClient.DownloadCallback callback,
|
||||||
|
final DownloadClient.ProgressListener progressListener) {
|
||||||
|
|
||||||
mClient.networkInterceptors().add(new Interceptor() {
|
mClient.networkInterceptors().add(new Interceptor() {
|
||||||
@Override
|
@Override
|
||||||
@@ -190,7 +173,7 @@ public class DownloadClient {
|
|||||||
final ResponseBody body = response.body();
|
final ResponseBody body = response.body();
|
||||||
final boolean resume = response.code() == 206;
|
final boolean resume = response.code() == 206;
|
||||||
if (resume) {
|
if (resume) {
|
||||||
mResumeOffset = destination.length();
|
mResumeOffset = mDestination.length();
|
||||||
Log.d(TAG, "The server fulfilled the partial content request");
|
Log.d(TAG, "The server fulfilled the partial content request");
|
||||||
} else if (!isSuccessful(response.code())) {
|
} else if (!isSuccessful(response.code())) {
|
||||||
Log.e(TAG, "The server replied with code " + response.code());
|
Log.e(TAG, "The server replied with code " + response.code());
|
||||||
@@ -206,7 +189,7 @@ public class DownloadClient {
|
|||||||
callback.onResponse(response.code(), response.request().urlString(),
|
callback.onResponse(response.code(), response.request().urlString(),
|
||||||
new Headers(response.headers()));
|
new Headers(response.headers()));
|
||||||
try (BufferedSink sink = Okio.buffer(resume ?
|
try (BufferedSink sink = Okio.buffer(resume ?
|
||||||
Okio.appendingSink(destination) : Okio.sink(destination))) {
|
Okio.appendingSink(mDestination) : Okio.sink(mDestination))) {
|
||||||
sink.writeAll(body.source());
|
sink.writeAll(body.source());
|
||||||
Log.d(TAG, "Download complete");
|
Log.d(TAG, "Download complete");
|
||||||
sink.flush();
|
sink.flush();
|
||||||
@@ -227,10 +210,11 @@ public class DownloadClient {
|
|||||||
private class ProgressResponseBody extends ResponseBody {
|
private class ProgressResponseBody extends ResponseBody {
|
||||||
|
|
||||||
private final ResponseBody mResponseBody;
|
private final ResponseBody mResponseBody;
|
||||||
private final ProgressListener mProgressListener;
|
private final DownloadClient.ProgressListener mProgressListener;
|
||||||
private BufferedSource mBufferedSource;
|
private BufferedSource mBufferedSource;
|
||||||
|
|
||||||
ProgressResponseBody(ResponseBody responseBody, ProgressListener progressListener) {
|
ProgressResponseBody(ResponseBody responseBody,
|
||||||
|
DownloadClient.ProgressListener progressListener) {
|
||||||
mResponseBody = responseBody;
|
mResponseBody = responseBody;
|
||||||
mProgressListener = progressListener;
|
mProgressListener = progressListener;
|
||||||
}
|
}
|
Reference in New Issue
Block a user