android.os.Message.sendToTarget()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(543)

本文整理了Java中android.os.Message.sendToTarget()方法的一些代码示例,展示了Message.sendToTarget()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.sendToTarget()方法的具体详情如下:
包路径:android.os.Message
类名称:Message
方法名:sendToTarget

Message.sendToTarget介绍

暂无

代码示例

代码示例来源:origin: google/ExoPlayer

@Override
public void sendMessage(PlayerMessage message) {
 handler.obtainMessage(0, message).sendToTarget();
}

代码示例来源:origin: bumptech/glide

@Override
public void onResourceReady(@NonNull Z resource, @Nullable Transition<? super Z> transition) {
 HANDLER.obtainMessage(MESSAGE_CLEAR, this).sendToTarget();
}

代码示例来源:origin: bumptech/glide

synchronized void recycle(Resource<?> resource) {
 if (isRecycling) {
  // If a resource has sub-resources, releasing a sub resource can cause it's parent to be
  // synchronously evicted which leads to a recycle loop when the parent releases it's children.
  // Posting breaks this loop.
  handler.obtainMessage(ResourceRecyclerCallback.RECYCLE_RESOURCE, resource).sendToTarget();
 } else {
  isRecycling = true;
  resource.recycle();
  isRecycling = false;
 }
}

代码示例来源:origin: google/ExoPlayer

private void invokeRenderer(Metadata metadata) {
 if (outputHandler != null) {
  outputHandler.obtainMessage(MSG_INVOKE_RENDERER, metadata).sendToTarget();
 } else {
  invokeRendererInternal(metadata);
 }
}

代码示例来源:origin: google/ExoPlayer

private void updateOutput(List<Cue> cues) {
 if (outputHandler != null) {
  outputHandler.obtainMessage(MSG_UPDATE_OUTPUT, cues).sendToTarget();
 } else {
  invokeUpdateOutputInternal(cues);
 }
}

代码示例来源:origin: google/ExoPlayer

public void prepare(MediaSource mediaSource, boolean resetPosition, boolean resetState) {
 handler
   .obtainMessage(MSG_PREPARE, resetPosition ? 1 : 0, resetState ? 1 : 0, mediaSource)
   .sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
 handler
   .obtainMessage(MSG_PLAYBACK_PARAMETERS_CHANGED_INTERNAL, playbackParameters)
   .sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

private void scheduleListenerNotification(@Nullable Runnable actionOnCompletion) {
 if (!listenerNotificationScheduled) {
  Assertions.checkNotNull(playbackThreadHandler)
    .obtainMessage(MSG_NOTIFY_LISTENER)
    .sendToTarget();
  listenerNotificationScheduled = true;
 }
 if (actionOnCompletion != null) {
  pendingOnCompletionActions.add(actionOnCompletion);
 }
}

代码示例来源:origin: google/ExoPlayer

@Override
public void onPrepared(MediaPeriod source) {
 handler.obtainMessage(MSG_PERIOD_PREPARED, source).sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

@Override
public void onContinueLoadingRequested(MediaPeriod source) {
 handler.obtainMessage(MSG_SOURCE_CONTINUE_LOADING_REQUESTED, source).sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

private void handlePlaybackParameters(PlaybackParameters playbackParameters)
  throws ExoPlaybackException {
 eventHandler.obtainMessage(MSG_PLAYBACK_PARAMETERS_CHANGED, playbackParameters).sendToTarget();
 updateTrackSelectionPlaybackSpeed(playbackParameters.speed);
 for (Renderer renderer : renderers) {
  if (renderer != null) {
   renderer.setOperatingRate(playbackParameters.speed);
  }
 }
}

代码示例来源:origin: google/ExoPlayer

@Override
public void sendMessage(PlayerMessage message) {
 handler.obtainMessage(0, message).sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

@Override
public void onSourceInfoRefreshed(MediaSource source, Timeline timeline, Object manifest) {
 handler.obtainMessage(MSG_REFRESH_SOURCE_INFO,
   new MediaSourceRefreshInfo(source, timeline, manifest)).sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

public void seekTo(Timeline timeline, int windowIndex, long positionUs) {
 handler.obtainMessage(MSG_SEEK_TO, new SeekPosition(timeline, windowIndex, positionUs))
   .sendToTarget();
}

代码示例来源:origin: google/ExoPlayer

@Override
public synchronized void sendMessage(PlayerMessage message) {
 if (released) {
  Log.w(TAG, "Ignoring messages sent after release.");
  message.markAsProcessed(/* isDelivered= */ false);
  return;
 }
 handler.obtainMessage(MSG_SEND_MESSAGE, message).sendToTarget();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSendToTarget() throws Exception {
 ShadowLooper.pauseMainLooper();
 Handler h = new Handler();
 Message.obtain(h, 123).sendToTarget();
 assertThat(h.hasMessages(123)).isTrue();
}

代码示例来源:origin: google/ExoPlayer

private void sendMessageToTarget(PlayerMessage message) throws ExoPlaybackException {
 if (message.getHandler().getLooper() == handler.getLooper()) {
  deliverMessage(message);
  if (playbackInfo.playbackState == Player.STATE_READY
    || playbackInfo.playbackState == Player.STATE_BUFFERING) {
   // The message may have caused something to change that now requires us to do work.
   handler.sendEmptyMessage(MSG_DO_SOME_WORK);
  }
 } else {
  handler.obtainMessage(MSG_SEND_MESSAGE_TO_TARGET_THREAD, message).sendToTarget();
 }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void testSendToTarget() {
 ShadowLooper.pauseMainLooper();
 Object testObject = new Object();
 Handler handler = new Handler();
 Message message = handler.obtainMessage(123, testObject);
 assertThat(handler).isEqualTo(message.getTarget());
 message.sendToTarget();
 assertTrue(handler.hasMessages(123, testObject));
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = LOLLIPOP)
public void testIsInUse() {
 ShadowLooper.pauseMainLooper();
 Handler h = new Handler();
 Message msg = Message.obtain(h, 123);
 ShadowMessage sMsg = shadowOf(msg);
 assertThat(sMsg.isInUse()).isFalse();
 msg.sendToTarget();
 assertThat(sMsg.isInUse()).isTrue();
}

代码示例来源:origin: robolectric/robolectric

private void recycle_shouldRemoveMessageFromScheduler() {
 ShadowLooper.pauseMainLooper();
 Handler h = new Handler();
 Message msg = Message.obtain(h, 234);
 msg.sendToTarget();
 Scheduler scheduler = Robolectric.getForegroundThreadScheduler();
 assertThat(scheduler.size()).named("before recycle").isEqualTo(1);
 shadowOf(msg).recycleUnchecked();
 assertThat(scheduler.size()).named("after recycle").isEqualTo(0);
}

相关文章