Beispiel #1
0
bool Handler::postDelayed(const sp<Runnable>& runnable, uint32_t delay) {
	if (runnable != NULL) {
		const sp<Message>& message = getPostMessage(runnable);
		return sendMessageDelayed(message, delay);
	} else {
		return false;
	}
}
Beispiel #2
0
sp<Closure> Handler::postDelayed(std::function<void (void)>&& func, uint32_t delayMillis) {
    if (func) {
        const sp<Message> message = Message::obtain();
        sp<Closure> closure = new Closure(sp<Handler>(this), std::move(func));
        message->callback = closure;
        return sendMessageDelayed(message, delayMillis) ? closure : nullptr;
    } else {
        return nullptr;
    }
}