void dispatchAirplaneModeChange(boolean airplaneMode) { handler.sendMessage(handler.obtainMessage(AIRPLANE_MODE_CHANGE, airplaneMode ? AIRPLANE_MODE_ON : AIRPLANE_MODE_OFF, 0)); }
void dispatchComplete(BitmapHunter hunter) { handler.sendMessage(handler.obtainMessage(HUNTER_COMPLETE, hunter)); }
void dispatchDownloadFinished(long size) { handler.sendMessage(handler.obtainMessage(DOWNLOAD_FINISHED, size)); }
void dispatchCancel(Action action) { handler.sendMessage(handler.obtainMessage(REQUEST_CANCEL, action)); }
void dispatchPauseTag(Object tag) { handler.sendMessage(handler.obtainMessage(TAG_PAUSE, tag)); }
void dispatchResumeTag(Object tag) { handler.sendMessage(handler.obtainMessage(TAG_RESUME, tag)); }
void dispatchFailed(BitmapHunter hunter) { handler.sendMessage(handler.obtainMessage(HUNTER_DECODE_FAILED, hunter)); }
@Override public void onResourceReady(@NonNull Z resource, @Nullable Transition<? super Z> transition) { HANDLER.obtainMessage(MESSAGE_CLEAR, this).sendToTarget(); }
@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); } }
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; } }
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)); }
/** * 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); }
private void onManifestExpiredMessageEncountered( long eventTimeUs, long manifestPublishTimeMsInEmsg) { ManifestExpiryEventInfo manifestExpiryEventInfo = new ManifestExpiryEventInfo(eventTimeUs, manifestPublishTimeMsInEmsg); handler.sendMessage(handler.obtainMessage(EMSG_MANIFEST_EXPIRED, manifestExpiryEventInfo)); } }
private void invokeRenderer(Metadata metadata) { if (outputHandler != null) { outputHandler.obtainMessage(MSG_INVOKE_RENDERER, metadata).sendToTarget(); } else { invokeRendererInternal(metadata); } }
private void updateOutput(List<Cue> cues) { if (outputHandler != null) { outputHandler.obtainMessage(MSG_UPDATE_OUTPUT, cues).sendToTarget(); } else { invokeUpdateOutputInternal(cues); } }
private void scheduleListenerNotification(@Nullable Runnable actionOnCompletion) { if (!listenerNotificationScheduled) { Assertions.checkNotNull(playbackThreadHandler) .obtainMessage(MSG_NOTIFY_LISTENER) .sendToTarget(); listenerNotificationScheduled = true; } if (actionOnCompletion != null) { pendingOnCompletionActions.add(actionOnCompletion); } }
void dispatchRetry(BitmapHunter hunter) { handler.sendMessageDelayed(handler.obtainMessage(HUNTER_RETRY, hunter), RETRY_DELAY); }
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); } } }
@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); }
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); }