Search in sources :

Example 81 with Nullable

use of androidx.annotation.Nullable in project ExoPlayer by google.

the class ConcatenatingMediaSource method setPublicShuffleOrder.

@GuardedBy("this")
private void setPublicShuffleOrder(ShuffleOrder shuffleOrder, @Nullable Handler handler, @Nullable Runnable onCompletionAction) {
    Assertions.checkArgument((handler == null) == (onCompletionAction == null));
    @Nullable Handler playbackThreadHandler = this.playbackThreadHandler;
    if (playbackThreadHandler != null) {
        int size = getSize();
        if (shuffleOrder.getLength() != size) {
            shuffleOrder = shuffleOrder.cloneAndClear().cloneAndInsert(/* insertionIndex= */
            0, /* insertionCount= */
            size);
        }
        @Nullable HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
        playbackThreadHandler.obtainMessage(MSG_SET_SHUFFLE_ORDER, new MessageData<>(/* index= */
        0, shuffleOrder, callbackAction)).sendToTarget();
    } else {
        this.shuffleOrder = shuffleOrder.getLength() > 0 ? shuffleOrder.cloneAndClear() : shuffleOrder;
        if (onCompletionAction != null && handler != null) {
            handler.post(onCompletionAction);
        }
    }
}
Also used : Handler(android.os.Handler) Nullable(androidx.annotation.Nullable) GuardedBy(androidx.annotation.GuardedBy)

Example 82 with Nullable

use of androidx.annotation.Nullable in project ExoPlayer by google.

the class ConcatenatingMediaSource method createPeriod.

@Override
public MediaPeriod createPeriod(MediaPeriodId id, Allocator allocator, long startPositionUs) {
    Object mediaSourceHolderUid = getMediaSourceHolderUid(id.periodUid);
    MediaPeriodId childMediaPeriodId = id.copyWithPeriodUid(getChildPeriodUid(id.periodUid));
    @Nullable MediaSourceHolder holder = mediaSourceByUid.get(mediaSourceHolderUid);
    if (holder == null) {
        // Stale event. The media source has already been removed.
        holder = new MediaSourceHolder(new FakeMediaSource(), useLazyPreparation);
        holder.isRemoved = true;
        prepareChildSource(holder, holder.mediaSource);
    }
    enableMediaSource(holder);
    holder.activeMediaPeriodIds.add(childMediaPeriodId);
    MediaPeriod mediaPeriod = holder.mediaSource.createPeriod(childMediaPeriodId, allocator, startPositionUs);
    mediaSourceByMediaPeriod.put(mediaPeriod, holder);
    disableUnusedMediaSources();
    return mediaPeriod;
}
Also used : MediaSourceHolder(com.google.android.exoplayer2.source.ConcatenatingMediaSource.MediaSourceHolder) Nullable(androidx.annotation.Nullable)

Example 83 with Nullable

use of androidx.annotation.Nullable in project ExoPlayer by google.

the class DefaultMediaSourceFactory method maybeWrapWithAdsMediaSource.

private MediaSource maybeWrapWithAdsMediaSource(MediaItem mediaItem, MediaSource mediaSource) {
    checkNotNull(mediaItem.localConfiguration);
    @Nullable MediaItem.AdsConfiguration adsConfiguration = mediaItem.localConfiguration.adsConfiguration;
    if (adsConfiguration == null) {
        return mediaSource;
    }
    @Nullable AdsLoader.Provider adsLoaderProvider = this.adsLoaderProvider;
    @Nullable AdViewProvider adViewProvider = this.adViewProvider;
    if (adsLoaderProvider == null || adViewProvider == null) {
        Log.w(TAG, "Playing media without ads. Configure ad support by calling setAdsLoaderProvider and" + " setAdViewProvider.");
        return mediaSource;
    }
    @Nullable AdsLoader adsLoader = adsLoaderProvider.getAdsLoader(adsConfiguration);
    if (adsLoader == null) {
        Log.w(TAG, "Playing media without ads, as no AdsLoader was provided.");
        return mediaSource;
    }
    return new AdsMediaSource(mediaSource, new DataSpec(adsConfiguration.adTagUri), /* adsId= */
    adsConfiguration.adsId != null ? adsConfiguration.adsId : ImmutableList.of(mediaItem.mediaId, mediaItem.localConfiguration.uri, adsConfiguration.adTagUri), /* adMediaSourceFactory= */
    this, adsLoader, adViewProvider);
}
Also used : MediaItem(com.google.android.exoplayer2.MediaItem) AdViewProvider(com.google.android.exoplayer2.ui.AdViewProvider) AdsMediaSource(com.google.android.exoplayer2.source.ads.AdsMediaSource) DataSpec(com.google.android.exoplayer2.upstream.DataSpec) Nullable(androidx.annotation.Nullable) AdsLoader(com.google.android.exoplayer2.source.ads.AdsLoader)

Example 84 with Nullable

use of androidx.annotation.Nullable in project ExoPlayer by google.

the class Requirements method getNotMetNetworkRequirements.

@RequirementFlags
private int getNotMetNetworkRequirements(Context context) {
    if (!isNetworkRequired()) {
        return 0;
    }
    ConnectivityManager connectivityManager = (ConnectivityManager) Assertions.checkNotNull(context.getSystemService(Context.CONNECTIVITY_SERVICE));
    @Nullable NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
    if (networkInfo == null || !networkInfo.isConnected() || !isInternetConnectivityValidated(connectivityManager)) {
        return requirements & (NETWORK | NETWORK_UNMETERED);
    }
    if (isUnmeteredNetworkRequired() && connectivityManager.isActiveNetworkMetered()) {
        return NETWORK_UNMETERED;
    }
    return 0;
}
Also used : NetworkInfo(android.net.NetworkInfo) ConnectivityManager(android.net.ConnectivityManager) Nullable(androidx.annotation.Nullable)

Example 85 with Nullable

use of androidx.annotation.Nullable in project ExoPlayer by google.

the class Requirements method isDeviceCharging.

private boolean isDeviceCharging(Context context) {
    @Nullable Intent batteryStatus = context.registerReceiver(/* receiver= */
    null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    if (batteryStatus == null) {
        return false;
    }
    int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
    return status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
}
Also used : IntentFilter(android.content.IntentFilter) Intent(android.content.Intent) Nullable(androidx.annotation.Nullable)

Aggregations

Nullable (androidx.annotation.Nullable)1124 View (android.view.View)188 Bundle (android.os.Bundle)111 IOException (java.io.IOException)99 NonNull (androidx.annotation.NonNull)96 ArrayList (java.util.ArrayList)95 Context (android.content.Context)93 TextView (android.widget.TextView)92 Cursor (android.database.Cursor)71 SuppressLint (android.annotation.SuppressLint)69 Uri (android.net.Uri)66 RecyclerView (androidx.recyclerview.widget.RecyclerView)59 List (java.util.List)58 ViewGroup (android.view.ViewGroup)56 Test (org.junit.Test)55 Intent (android.content.Intent)53 Recipient (org.thoughtcrime.securesms.recipients.Recipient)52 R (org.thoughtcrime.securesms.R)46 LayoutInflater (android.view.LayoutInflater)45 ImageView (android.widget.ImageView)43