androidx.annotation.GuardedBy Java Examples

The following examples show how to use androidx.annotation.GuardedBy. 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: ConcatenatingMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@GuardedBy("this")
private void removePublicMediaSources(
    int fromIndex,
    int toIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_REMOVE, new MessageData<>(fromIndex, toIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example #2
Source File: ConcatenatingMediaSource.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
@GuardedBy("this")
private void movePublicMediaSource(
    int currentIndex,
    int newIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  mediaSourcesPublic.add(newIndex, mediaSourcesPublic.remove(currentIndex));
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_MOVE, new MessageData<>(currentIndex, newIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example #3
Source File: ConcatenatingMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@GuardedBy("this")
private void removePublicMediaSources(
    int fromIndex,
    int toIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_REMOVE, new MessageData<>(fromIndex, toIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example #4
Source File: ConcatenatingMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@GuardedBy("this")
private void movePublicMediaSource(
    int currentIndex,
    int newIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  mediaSourcesPublic.add(newIndex, mediaSourcesPublic.remove(currentIndex));
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_MOVE, new MessageData<>(currentIndex, newIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example #5
Source File: ConcatenatingMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@GuardedBy("this")
private void removePublicMediaSources(
    int fromIndex,
    int toIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  Util.removeRange(mediaSourcesPublic, fromIndex, toIndex);
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_REMOVE, new MessageData<>(fromIndex, toIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example #6
Source File: ConcatenatingMediaSource.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@GuardedBy("this")
private void movePublicMediaSource(
    int currentIndex,
    int newIndex,
    @Nullable Handler handler,
    @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  mediaSourcesPublic.add(newIndex, mediaSourcesPublic.remove(currentIndex));
  if (playbackThreadHandler != null) {
    HandlerAndRunnable callbackAction = createOnCompletionAction(handler, onCompletionAction);
    playbackThreadHandler
        .obtainMessage(MSG_MOVE, new MessageData<>(currentIndex, newIndex, callbackAction))
        .sendToTarget();
  } else if (onCompletionAction != null && handler != null) {
    handler.post(onCompletionAction);
  }
}
 
Example #7
Source File: ConcatenatingMediaSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@GuardedBy("this")
private void setPublicShuffleOrder(
    ShuffleOrder shuffleOrder, @Nullable Handler handler, @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  if (playbackThreadHandler != null) {
    int size = getSize();
    if (shuffleOrder.getLength() != size) {
      shuffleOrder =
          shuffleOrder
              .cloneAndClear()
              .cloneAndInsert(/* insertionIndex= */ 0, /* insertionCount= */ size);
    }
    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);
    }
  }
}
 
Example #8
Source File: ConcatenatingMediaSource.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@GuardedBy("this")
@Nullable
private HandlerAndRunnable createOnCompletionAction(
    @Nullable Handler handler, @Nullable Runnable runnable) {
  if (handler == null || runnable == null) {
    return null;
  }
  HandlerAndRunnable handlerAndRunnable = new HandlerAndRunnable(handler, runnable);
  pendingOnCompletionActions.add(handlerAndRunnable);
  return handlerAndRunnable;
}
 
Example #9
Source File: ConcatenatingMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@GuardedBy("this")
private void setPublicShuffleOrder(
    ShuffleOrder shuffleOrder, @Nullable Handler handler, @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  if (playbackThreadHandler != null) {
    int size = getSize();
    if (shuffleOrder.getLength() != size) {
      shuffleOrder =
          shuffleOrder
              .cloneAndClear()
              .cloneAndInsert(/* insertionIndex= */ 0, /* insertionCount= */ size);
    }
    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);
    }
  }
}
 
Example #10
Source File: ConcatenatingMediaSource.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@GuardedBy("this")
@Nullable
private HandlerAndRunnable createOnCompletionAction(
    @Nullable Handler handler, @Nullable Runnable runnable) {
  if (handler == null || runnable == null) {
    return null;
  }
  HandlerAndRunnable handlerAndRunnable = new HandlerAndRunnable(handler, runnable);
  pendingOnCompletionActions.add(handlerAndRunnable);
  return handlerAndRunnable;
}
 
Example #11
Source File: ConcatenatingMediaSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@GuardedBy("this")
private void setPublicShuffleOrder(
    ShuffleOrder shuffleOrder, @Nullable Handler handler, @Nullable Runnable onCompletionAction) {
  Assertions.checkArgument((handler == null) == (onCompletionAction == null));
  Handler playbackThreadHandler = this.playbackThreadHandler;
  if (playbackThreadHandler != null) {
    int size = getSize();
    if (shuffleOrder.getLength() != size) {
      shuffleOrder =
          shuffleOrder
              .cloneAndClear()
              .cloneAndInsert(/* insertionIndex= */ 0, /* insertionCount= */ size);
    }
    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);
    }
  }
}
 
Example #12
Source File: ConcatenatingMediaSource.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@GuardedBy("this")
@Nullable
private HandlerAndRunnable createOnCompletionAction(
    @Nullable Handler handler, @Nullable Runnable runnable) {
  if (handler == null || runnable == null) {
    return null;
  }
  HandlerAndRunnable handlerAndRunnable = new HandlerAndRunnable(handler, runnable);
  pendingOnCompletionActions.add(handlerAndRunnable);
  return handlerAndRunnable;
}