Java Code Examples for com.google.android.exoplayer2.util.Assertions#checkNotEmpty()

The following examples show how to use com.google.android.exoplayer2.util.Assertions#checkNotEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultHttpDataSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *     predicate then a {@link InvalidContentTypeException} is thrown from {@link
 *     #open(DataSpec)}.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *     default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted as
 *     an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as HTTP
 *     headers or {@code null} if not required.
 * @deprecated Use {@link #DefaultHttpDataSource(String, int, int, boolean, RequestProperties)}
 *     and {@link #setContentTypePredicate(Predicate)}.
 */
@Deprecated
public DefaultHttpDataSource(
    String userAgent,
    @Nullable Predicate<String> contentTypePredicate,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects,
    @Nullable RequestProperties defaultRequestProperties) {
  super(/* isNetwork= */ true);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
}
 
Example 2
Source File: DefaultHttpDataSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *     predicate then a {@link HttpDataSource.InvalidContentTypeException} is thrown from {@link
 *     #open(DataSpec)}.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *     default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted as
 *     an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as HTTP
 *     headers or {@code null} if not required.
 */
public DefaultHttpDataSource(
    String userAgent,
    @Nullable Predicate<String> contentTypePredicate,
    @Nullable TransferListener listener,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects,
    @Nullable RequestProperties defaultRequestProperties) {
  super(/* isNetwork= */ true);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
  if (listener != null) {
    addTransferListener(listener);
  }
}
 
Example 3
Source File: DefaultHttpDataSource.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *     predicate then a {@link HttpDataSource.InvalidContentTypeException} is thrown from {@link
 *     #open(DataSpec)}.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *     default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted as
 *     an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as HTTP
 *     headers or {@code null} if not required.
 */
public DefaultHttpDataSource(
    String userAgent,
    @Nullable Predicate<String> contentTypePredicate,
    @Nullable TransferListener listener,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects,
    @Nullable RequestProperties defaultRequestProperties) {
  super(/* isNetwork= */ true);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
  if (listener != null) {
    addTransferListener(listener);
  }
}
 
Example 4
Source File: GSYDefaultHttpDataSource.java    From GSYVideoPlayer with Apache License 2.0 6 votes vote down vote up
/**
 * @param userAgent                   The User-Agent string that should be used.
 * @param contentTypePredicate        An optional {@link Predicate}. If a content type is rejected by the
 *                                    predicate then a {@link HttpDataSource.InvalidContentTypeException} is thrown from {@link
 *                                    #open(DataSpec)}.
 * @param connectTimeoutMillis        The connection timeout, in milliseconds. A timeout of zero is
 *                                    interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *                                    default value.
 * @param readTimeoutMillis           The read timeout, in milliseconds. A timeout of zero is interpreted as
 *                                    an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *                                    to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties    The default request properties to be sent to the server as HTTP
 *                                    headers or {@code null} if not required.
 * @deprecated Use {@link #GSYDefaultHttpDataSource(String, int, int, boolean, RequestProperties)}
 * and {@link #setContentTypePredicate(Predicate)}.
 */
@Deprecated
public GSYDefaultHttpDataSource(
        String userAgent,
        @Nullable Predicate<String> contentTypePredicate,
        int connectTimeoutMillis,
        int readTimeoutMillis,
        boolean allowCrossProtocolRedirects,
        @Nullable RequestProperties defaultRequestProperties) {
    super(/* isNetwork= */ true);
    this.userAgent = Assertions.checkNotEmpty(userAgent);
    this.contentTypePredicate = contentTypePredicate;
    this.requestProperties = new RequestProperties();
    this.connectTimeoutMillis = connectTimeoutMillis;
    this.readTimeoutMillis = readTimeoutMillis;
    this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
    this.defaultRequestProperties = defaultRequestProperties;
}
 
Example 5
Source File: DefaultHttpDataSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *     predicate then a {@link HttpDataSource.InvalidContentTypeException} is thrown from {@link
 *     #open(DataSpec)}.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *     default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted as
 *     an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as HTTP
 *     headers or {@code null} if not required.
 */
public DefaultHttpDataSource(
    String userAgent,
    @Nullable Predicate<String> contentTypePredicate,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects,
    @Nullable RequestProperties defaultRequestProperties) {
  super(/* isNetwork= */ true);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
}
 
Example 6
Source File: DefaultHttpDataSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *     predicate then a {@link HttpDataSource.InvalidContentTypeException} is thrown from {@link
 *     #open(DataSpec)}.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *     default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted as
 *     an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as HTTP
 *     headers or {@code null} if not required.
 */
public DefaultHttpDataSource(
    String userAgent,
    @Nullable Predicate<String> contentTypePredicate,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects,
    @Nullable RequestProperties defaultRequestProperties) {
  super(/* isNetwork= */ true);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
}
 
Example 7
Source File: DefaultHttpDataSourceFactory.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout that should be used when requesting remote
 *     data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in
 *     milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 */
public DefaultHttpDataSourceFactory(
    String userAgent,
    @Nullable TransferListener listener,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects) {
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.listener = listener;
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
}
 
Example 8
Source File: DefaultHttpDataSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *     default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted as
 *     an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as HTTP
 *     headers or {@code null} if not required.
 */
public DefaultHttpDataSource(
    String userAgent,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects,
    @Nullable RequestProperties defaultRequestProperties) {
  super(/* isNetwork= */ true);
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
}
 
Example 9
Source File: GSYDefaultHttpDataSource.java    From GSYVideoPlayer with Apache License 2.0 5 votes vote down vote up
/**
 * @param userAgent                   The User-Agent string that should be used.
 * @param connectTimeoutMillis        The connection timeout, in milliseconds. A timeout of zero is
 *                                    interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use the
 *                                    default value.
 * @param readTimeoutMillis           The read timeout, in milliseconds. A timeout of zero is interpreted as
 *                                    an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *                                    to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties    The default request properties to be sent to the server as HTTP
 *                                    headers or {@code null} if not required.
 */
public GSYDefaultHttpDataSource(
        String userAgent,
        int connectTimeoutMillis,
        int readTimeoutMillis,
        boolean allowCrossProtocolRedirects,
        @Nullable RequestProperties defaultRequestProperties) {
    super(/* isNetwork= */ true);
    this.userAgent = Assertions.checkNotEmpty(userAgent);
    this.requestProperties = new RequestProperties();
    this.connectTimeoutMillis = connectTimeoutMillis;
    this.readTimeoutMillis = readTimeoutMillis;
    this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
    this.defaultRequestProperties = defaultRequestProperties;
}
 
Example 10
Source File: DefaultHttpDataSourceFactory.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout that should be used when requesting remote
 *     data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in
 *     milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 */
public DefaultHttpDataSourceFactory(
    String userAgent,
    @Nullable TransferListener listener,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects) {
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.listener = listener;
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
}
 
Example 11
Source File: DefaultHttpDataSourceFactory.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout that should be used when requesting remote
 *     data, in milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param readTimeoutMillis The read timeout that should be used when requesting remote data, in
 *     milliseconds. A timeout of zero is interpreted as an infinite timeout.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 */
public DefaultHttpDataSourceFactory(
    String userAgent,
    @Nullable TransferListener listener,
    int connectTimeoutMillis,
    int readTimeoutMillis,
    boolean allowCrossProtocolRedirects) {
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.listener = listener;
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
}
 
Example 12
Source File: DefaultHttpDataSource.java    From K-Sonic with MIT License 3 votes vote down vote up
/**
 * @param userAgent The User-Agent string that should be used.
 * @param contentTypePredicate An optional {@link Predicate}. If a content type is rejected by the
 *     predicate then a {@link HttpDataSource.InvalidContentTypeException} is thrown from
 *     {@link #open(DataSpec)}.
 * @param listener An optional listener.
 * @param connectTimeoutMillis The connection timeout, in milliseconds. A timeout of zero is
 *     interpreted as an infinite timeout. Pass {@link #DEFAULT_CONNECT_TIMEOUT_MILLIS} to use
 *     the default value.
 * @param readTimeoutMillis The read timeout, in milliseconds. A timeout of zero is interpreted
 *     as an infinite timeout. Pass {@link #DEFAULT_READ_TIMEOUT_MILLIS} to use the default value.
 * @param allowCrossProtocolRedirects Whether cross-protocol redirects (i.e. redirects from HTTP
 *     to HTTPS and vice versa) are enabled.
 * @param defaultRequestProperties The default request properties to be sent to the server as
 *     HTTP headers or {@code null} if not required.
 */
public DefaultHttpDataSource(String userAgent, Predicate<String> contentTypePredicate,
    TransferListener<? super DefaultHttpDataSource> listener, int connectTimeoutMillis,
    int readTimeoutMillis, boolean allowCrossProtocolRedirects,
    RequestProperties defaultRequestProperties) {
  this.userAgent = Assertions.checkNotEmpty(userAgent);
  this.contentTypePredicate = contentTypePredicate;
  this.listener = listener;
  this.requestProperties = new RequestProperties();
  this.connectTimeoutMillis = connectTimeoutMillis;
  this.readTimeoutMillis = readTimeoutMillis;
  this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
  this.defaultRequestProperties = defaultRequestProperties;
}