mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
[third_party] Avoid saving Robolectric shadow instances; instead, save the real framework object, and get its shadow when needed using Shadows.shadowOf(). Call Android framework methods directly on the framework object instead of its shadow whenever possible.
LSC: []
Additional details: []
Cleanup change automatically generated by javacflume/refactory
Refactoring: //third_party/java_src/robolectric/errorprone:ShadowUsageCheck
Tested:
TAP --sample for global presubmit queue
[]
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=207014379
This commit is contained in:
parent
cc2a8bb854
commit
03b04ef23c
1 changed files with 11 additions and 9 deletions
|
|
@ -61,9 +61,9 @@ public final class RobolectricUtil {
|
|||
|
||||
@Implementation
|
||||
public static void loop() {
|
||||
ShadowLooper looper = shadowOf(Looper.myLooper());
|
||||
if (looper instanceof CustomLooper) {
|
||||
((CustomLooper) looper).doLoop();
|
||||
Looper looper = Looper.myLooper();
|
||||
if (shadowOf(looper) instanceof CustomLooper) {
|
||||
((CustomLooper) shadowOf(looper)).doLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -161,9 +161,10 @@ public final class RobolectricUtil {
|
|||
@Implementation
|
||||
@Override
|
||||
public boolean enqueueMessage(Message msg, long when) {
|
||||
ShadowLooper looper = shadowOf(ShadowLooper.getLooperForThread(looperThread));
|
||||
if (looper instanceof CustomLooper && looper != ShadowLooper.getShadowMainLooper()) {
|
||||
((CustomLooper) looper).addPendingMessage(msg, when);
|
||||
Looper looper = ShadowLooper.getLooperForThread(looperThread);
|
||||
if (shadowOf(looper) instanceof CustomLooper
|
||||
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) {
|
||||
((CustomLooper) shadowOf(looper)).addPendingMessage(msg, when);
|
||||
} else {
|
||||
super.enqueueMessage(msg, when);
|
||||
}
|
||||
|
|
@ -172,9 +173,10 @@ public final class RobolectricUtil {
|
|||
|
||||
@Implementation
|
||||
public void removeMessages(Handler handler, int what, Object object) {
|
||||
ShadowLooper looper = shadowOf(ShadowLooper.getLooperForThread(looperThread));
|
||||
if (looper instanceof CustomLooper && looper != ShadowLooper.getShadowMainLooper()) {
|
||||
((CustomLooper) looper).removeMessages(handler, what, object);
|
||||
Looper looper = ShadowLooper.getLooperForThread(looperThread);
|
||||
if (shadowOf(looper) instanceof CustomLooper
|
||||
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) {
|
||||
((CustomLooper) shadowOf(looper)).removeMessages(handler, what, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue