Skip to content

Commit

Permalink
use the existing mListener in data source factory
Browse files Browse the repository at this point in the history
  • Loading branch information
watchinharrison committed May 20, 2020
1 parent 38e35fd commit 06c09e6
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ public class CustomHeadersOkHttpDataSourceFactory extends HttpDataSource.BaseFac
private final TransferListener mListener;
@Nullable
private final CacheControl mCacheControl;
@Nullable
private final TransferListener mBandwidthMeter;

public CustomHeadersOkHttpDataSourceFactory(@NonNull Call.Factory callFactory, @Nullable String userAgent, @Nullable Map<String, Object> requestHeaders, @Nullable TransferListener bandwidthMeter) {
public CustomHeadersOkHttpDataSourceFactory(@NonNull Call.Factory callFactory, @Nullable String userAgent, @Nullable Map<String, Object> requestHeaders, @Nullable TransferListener listener) {
super();
mCallFactory = callFactory;
mUserAgent = userAgent;
mListener = null;
mListener = listener;
mCacheControl = null;
mBandwidthMeter = bandwidthMeter;
updateRequestProperties(getDefaultRequestProperties(), requestHeaders);
}

Expand All @@ -49,8 +46,8 @@ protected void updateRequestProperties(HttpDataSource.RequestProperties requestP

protected OkHttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties defaultRequestProperties) {
OkHttpDataSource okHttpDataSource = new OkHttpDataSource(mCallFactory, mUserAgent, null, mCacheControl, defaultRequestProperties);
if (mBandwidthMeter != null) {
okHttpDataSource.addTransferListener(mBandwidthMeter);
if (mListener != null) {
okHttpDataSource.addTransferListener(mListener);
}
return okHttpDataSource;
}
Expand Down

0 comments on commit 06c09e6

Please sign in to comment.