Skip to content

Commit

Permalink
Merge pull request #595 from ReactiveX/jw/fix-non-robolectric/2022-11-09
Browse files Browse the repository at this point in the history
Skip null check when creating main scheduler
  • Loading branch information
JakeWharton committed Nov 9, 2022
2 parents 22638e1 + 44db927 commit 2100cf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions rxandroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ android {
sourceCompatibility rootProject.ext.sourceCompatibility
targetCompatibility rootProject.ext.sourceCompatibility
}

testOptions {
unitTests.returnDefaultValues = true
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
public final class AndroidSchedulers {

private static final class MainHolder {
static final Scheduler DEFAULT
= from(Looper.getMainLooper());
static final Scheduler DEFAULT = internalFrom(Looper.getMainLooper(), true);
}

private static final Scheduler MAIN_THREAD =
Expand Down Expand Up @@ -61,10 +60,13 @@ public static Scheduler from(Looper looper) {
* locking. On API < 16 this value is ignored.
* @see Message#setAsynchronous(boolean)
*/
@SuppressLint("NewApi") // Checking for an @hide API.
public static Scheduler from(Looper looper, boolean async) {
if (looper == null) throw new NullPointerException("looper == null");
return internalFrom(looper, async);
}

@SuppressLint("NewApi") // Checking for an @hide API.
private static Scheduler internalFrom(Looper looper, boolean async) {
// Below code exists in androidx-core as well, but is left here rather than include an
// entire extra dependency.
// https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat?hl=en#setAsynchronous(android.os.Message,%20kotlin.Boolean)
Expand Down

0 comments on commit 2100cf9

Please sign in to comment.