android.os.Handler.obtainMessage()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(259)

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

Handler.obtainMessage介绍

暂无

代码示例

代码示例来源:origin: square/picasso

void dispatchAirplaneModeChange(boolean airplaneMode) {
 handler.sendMessage(handler.obtainMessage(AIRPLANE_MODE_CHANGE,
   airplaneMode ? AIRPLANE_MODE_ON : AIRPLANE_MODE_OFF, 0));
}

代码示例来源:origin: square/picasso

void dispatchComplete(BitmapHunter hunter) {
 handler.sendMessage(handler.obtainMessage(HUNTER_COMPLETE, hunter));
}

代码示例来源:origin: square/picasso

void dispatchDownloadFinished(long size) {
 handler.sendMessage(handler.obtainMessage(DOWNLOAD_FINISHED, size));
}

代码示例来源:origin: square/picasso

void dispatchCancel(Action action) {
 handler.sendMessage(handler.obtainMessage(REQUEST_CANCEL, action));
}

代码示例来源:origin: square/picasso

void dispatchPauseTag(Object tag) {
 handler.sendMessage(handler.obtainMessage(TAG_PAUSE, tag));
}

代码示例来源:origin: square/picasso

void dispatchResumeTag(Object tag) {
 handler.sendMessage(handler.obtainMessage(TAG_RESUME, tag));
}

代码示例来源:origin: square/picasso

void dispatchFailed(BitmapHunter hunter) {
 handler.sendMessage(handler.obtainMessage(HUNTER_DECODE_FAILED, hunter));
}

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

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

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

@Override
 public void onResourceReady(@NonNull Bitmap resource,
   @Nullable Transition<? super Bitmap> transition) {
  this.resource = resource;
  Message msg = handler.obtainMessage(FrameLoaderCallback.MSG_DELAY, this);
  handler.sendMessageAtTime(msg, targetTime);
 }
}

代码示例来源: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: square/picasso

private void processBitmap(Bitmap bitmap, int what) {
 // Never send bitmaps to the handler as they could be recycled before we process them.
 int bitmapSize = BitmapCompat.getAllocationByteCount(bitmap);
 handler.sendMessage(handler.obtainMessage(what, bitmapSize, 0));
}

代码示例来源:origin: square/picasso

/**
 * Prior to Android 5, HandlerThread always keeps a stack local reference to the last message
 * that was sent to it. This method makes sure that stack local reference never stays there
 * for too long by sending new messages to it every second.
 */
static void flushStackLocalLeaks(Looper looper) {
 Handler handler = new Handler(looper) {
  @Override public void handleMessage(Message msg) {
   sendMessageDelayed(obtainMessage(), THREAD_LEAK_CLEANING_MS);
  }
 };
 handler.sendMessageDelayed(handler.obtainMessage(), THREAD_LEAK_CLEANING_MS);
}

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

private void onManifestExpiredMessageEncountered(
   long eventTimeUs, long manifestPublishTimeMsInEmsg) {
  ManifestExpiryEventInfo manifestExpiryEventInfo =
    new ManifestExpiryEventInfo(eventTimeUs, manifestPublishTimeMsInEmsg);
  handler.sendMessage(handler.obtainMessage(EMSG_MANIFEST_EXPIRED, manifestExpiryEventInfo));
 }
}

代码示例来源: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

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: square/picasso

void dispatchRetry(BitmapHunter hunter) {
 handler.sendMessageDelayed(handler.obtainMessage(HUNTER_RETRY, hunter), RETRY_DELAY);
}

代码示例来源: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: bumptech/glide

@SuppressWarnings("unchecked")
@Before
public void setUp() {
 MockitoAnnotations.initMocks(this);
 when(handler.obtainMessage(anyInt(), isA(DelayTarget.class))).thenReturn(mock(Message.class));
 firstFrame = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
 ByteBuffer byteBuffer = ByteBuffer.allocate(10);
 when(gifDecoder.getData()).thenReturn(byteBuffer);
 requestBuilder = mock(RequestBuilder.class, new ReturnsSelfAnswer());
 loader = createGifFrameLoader(handler);
}

代码示例来源:origin: square/picasso

private void deliver(BitmapHunter hunter) {
 if (hunter.isCancelled()) {
  return;
 }
 RequestHandler.Result result = hunter.getResult();
 if (result != null) {
  Bitmap bitmap = result.getBitmap();
  if (bitmap != null) {
   bitmap.prepareToDraw();
  }
 }
 mainThreadHandler.sendMessage(mainThreadHandler.obtainMessage(HUNTER_COMPLETE, hunter));
 logDelivery(hunter);
}

相关文章