mirror of
https://github.com/samsonjs/media.git
synced 2026-03-30 10:15:48 +00:00
Add missing removeCallbacksAndMessages to RobolectricUtil.
The Util class already handles removeMessages calls but so far ignored calls to removeCallbacksAndMessages. PiperOrigin-RevId: 232312458
This commit is contained in:
parent
a5d64463c7
commit
cd536a73b1
1 changed files with 12 additions and 1 deletions
|
|
@ -37,6 +37,7 @@ import org.robolectric.shadows.ShadowMessageQueue;
|
|||
public final class RobolectricUtil {
|
||||
|
||||
private static final AtomicLong sequenceNumberGenerator = new AtomicLong(0);
|
||||
private static final int ANY_MESSAGE = Integer.MIN_VALUE;
|
||||
|
||||
private RobolectricUtil() {}
|
||||
|
||||
|
|
@ -110,7 +111,8 @@ public final class RobolectricUtil {
|
|||
boolean isRemoved = false;
|
||||
for (RemovedMessage removedMessage : removedMessages) {
|
||||
if (removedMessage.handler == target
|
||||
&& removedMessage.what == pendingMessage.message.what
|
||||
&& (removedMessage.what == ANY_MESSAGE
|
||||
|| removedMessage.what == pendingMessage.message.what)
|
||||
&& (removedMessage.object == null
|
||||
|| removedMessage.object == pendingMessage.message.obj)
|
||||
&& pendingMessage.sequenceNumber < removedMessage.sequenceNumber) {
|
||||
|
|
@ -179,6 +181,15 @@ public final class RobolectricUtil {
|
|||
((CustomLooper) shadowOf(looper)).removeMessages(handler, what, object);
|
||||
}
|
||||
}
|
||||
|
||||
@Implementation
|
||||
public void removeCallbacksAndMessages(Handler handler, Object object) {
|
||||
Looper looper = ShadowLooper.getLooperForThread(looperThread);
|
||||
if (shadowOf(looper) instanceof CustomLooper
|
||||
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) {
|
||||
((CustomLooper) shadowOf(looper)).removeMessages(handler, ANY_MESSAGE, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final class PendingMessage implements Comparable<PendingMessage> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue