mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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
|
@Implementation
|
||||||
public static void loop() {
|
public static void loop() {
|
||||||
ShadowLooper looper = shadowOf(Looper.myLooper());
|
Looper looper = Looper.myLooper();
|
||||||
if (looper instanceof CustomLooper) {
|
if (shadowOf(looper) instanceof CustomLooper) {
|
||||||
((CustomLooper) looper).doLoop();
|
((CustomLooper) shadowOf(looper)).doLoop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,9 +161,10 @@ public final class RobolectricUtil {
|
||||||
@Implementation
|
@Implementation
|
||||||
@Override
|
@Override
|
||||||
public boolean enqueueMessage(Message msg, long when) {
|
public boolean enqueueMessage(Message msg, long when) {
|
||||||
ShadowLooper looper = shadowOf(ShadowLooper.getLooperForThread(looperThread));
|
Looper looper = ShadowLooper.getLooperForThread(looperThread);
|
||||||
if (looper instanceof CustomLooper && looper != ShadowLooper.getShadowMainLooper()) {
|
if (shadowOf(looper) instanceof CustomLooper
|
||||||
((CustomLooper) looper).addPendingMessage(msg, when);
|
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) {
|
||||||
|
((CustomLooper) shadowOf(looper)).addPendingMessage(msg, when);
|
||||||
} else {
|
} else {
|
||||||
super.enqueueMessage(msg, when);
|
super.enqueueMessage(msg, when);
|
||||||
}
|
}
|
||||||
|
|
@ -172,9 +173,10 @@ public final class RobolectricUtil {
|
||||||
|
|
||||||
@Implementation
|
@Implementation
|
||||||
public void removeMessages(Handler handler, int what, Object object) {
|
public void removeMessages(Handler handler, int what, Object object) {
|
||||||
ShadowLooper looper = shadowOf(ShadowLooper.getLooperForThread(looperThread));
|
Looper looper = ShadowLooper.getLooperForThread(looperThread);
|
||||||
if (looper instanceof CustomLooper && looper != ShadowLooper.getShadowMainLooper()) {
|
if (shadowOf(looper) instanceof CustomLooper
|
||||||
((CustomLooper) looper).removeMessages(handler, what, object);
|
&& shadowOf(looper) != ShadowLooper.getShadowMainLooper()) {
|
||||||
|
((CustomLooper) shadowOf(looper)).removeMessages(handler, what, object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue