本文整理了Java中android.os.Handler.sendMessage()
方法的一些代码示例,展示了Handler.sendMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.sendMessage()
方法的具体详情如下:
包路径:android.os.Handler
类名称:Handler
方法名:sendMessage
暂无
代码示例来源: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 dispatchSubmit(Action action) {
handler.sendMessage(handler.obtainMessage(REQUEST_SUBMIT, action));
}
代码示例来源:origin: square/picasso
void dispatchNetworkStateChange(NetworkInfo info) {
handler.sendMessage(handler.obtainMessage(NETWORK_STATE_CHANGE, info));
}
代码示例来源: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: Curzibn/Luban
@Override
public void run() {
try {
mHandler.sendMessage(mHandler.obtainMessage(MSG_COMPRESS_START));
File result = compress(context, path);
mHandler.sendMessage(mHandler.obtainMessage(MSG_COMPRESS_SUCCESS, result));
} catch (IOException e) {
mHandler.sendMessage(mHandler.obtainMessage(MSG_COMPRESS_ERROR, e));
}
}
});
代码示例来源:origin: navasmdc/MaterialDesignLibrary
@Override
public void run() {
try {
Thread.sleep(mTimer);
} catch (InterruptedException e) {
e.printStackTrace();
}
handler.sendMessage(new Message());
}
});
代码示例来源:origin: navasmdc/MaterialDesignLibrary
@Override
public void run() {
for(int i = 0; i <= 100; i++){
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
handler.sendMessage(new Message());
}
}
});
代码示例来源:origin: navasmdc/MaterialDesignLibrary
@Override
public void run() {
try {
Thread.sleep(4000);
for(int i = 0; i <= 100; i++){
Thread.sleep(100);
handler2.sendMessage(new Message());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
});
代码示例来源: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: google/ExoPlayer
private void onManifestExpiredMessageEncountered(
long eventTimeUs, long manifestPublishTimeMsInEmsg) {
ManifestExpiryEventInfo manifestExpiryEventInfo =
new ManifestExpiryEventInfo(eventTimeUs, manifestPublishTimeMsInEmsg);
handler.sendMessage(handler.obtainMessage(EMSG_MANIFEST_EXPIRED, manifestExpiryEventInfo));
}
}
代码示例来源:origin: orhanobut/logger
@Override public void log(int level, @Nullable String tag, @NonNull String message) {
checkNotNull(message);
// do nothing on the calling thread, simply pass the tag/msg to the background thread
handler.sendMessage(handler.obtainMessage(level, message));
}
代码示例来源:origin: greenrobot/greenDAO
private void handleOperationCompleted(AsyncOperation operation) {
operation.setCompleted();
AsyncOperationListener listenerToCall = listener;
if (listenerToCall != null) {
listenerToCall.onAsyncOperationCompleted(operation);
}
if (listenerMainThread != null) {
if (handlerMainThread == null) {
handlerMainThread = new Handler(Looper.getMainLooper(), this);
}
Message msg = handlerMainThread.obtainMessage(1, operation);
handlerMainThread.sendMessage(msg);
}
synchronized (this) {
countOperationsCompleted++;
if (countOperationsCompleted == countOperationsEnqueued) {
notifyAll();
}
}
}
代码示例来源: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);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldCallProvidedHandlerCallback() {
Handler handler = new Handler(callback);
handler.sendMessage(new Message());
assertTrue(hasHandlerCallbackHandledMessage);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void testHasMessagesWithWhatAndObject() {
ShadowLooper.pauseMainLooper();
Object testObject = new Object();
Handler handler = new Handler();
Message message = handler.obtainMessage(123, testObject);
assertFalse(handler.hasMessages(123, testObject));
handler.sendMessage(message);
assertTrue(handler.hasMessages(123, testObject));
}
内容来源于网络,如有侵权,请联系作者删除!