[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\ncharset = utf-8\nindent_size = 4\nindent_style = space\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[{*.yml,*.yaml}]\nindent_size = 2\n"
  },
  {
    "path": ".gitattributes",
    "content": "* text=auto eol=lf\n\n*.bat text eol=crlf\n*.jar binary"
  },
  {
    "path": ".github/dependabot.yaml",
    "content": "version: 2\n\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"daily\"\n"
  },
  {
    "path": ".github/workflows/build.yaml",
    "content": "name: build\n\non:\n  pull_request: {}\n  push:\n    branches:\n      - '**'\n    tags-ignore:\n      - '**'\n\njobs:\n  build:\n    runs-on: macos-latest\n\n    steps:\n      - uses: actions/checkout@v6\n      - uses: gradle/actions/wrapper-validation@v5\n\n      - uses: actions/setup-java@v5\n        with:\n          distribution: 'zulu'\n          java-version: 8\n\n      - run: ./gradlew build\n\n      - run: ./gradlew publish\n        if: ${{ github.ref == 'refs/heads/3.x' && github.repository == 'ReactiveX/RxAndroid' }}\n        env:\n          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}\n          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}\n"
  },
  {
    "path": ".github/workflows/manual_drop.yaml",
    "content": "name: 'Sonatype: manual close+release'\n\non:\n  workflow_dispatch:\n    inputs:\n      repository_name:\n        description: 'Name of staged repository on Sonatype'\n        type: string\n\njobs:\n  close_and_release:\n    runs-on: macos-latest\n\n    steps:\n      - uses: actions/checkout@v6\n      - uses: gradle/actions/wrapper-validation@v5\n\n      - uses: actions/setup-java@v5\n        with:\n          distribution: 'zulu'\n          java-version: 8\n\n      - run: ./gradlew closeAndReleaseRepository --repository=${{ inputs.repository_name }}\n        env:\n          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}\n          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}\n"
  },
  {
    "path": ".github/workflows/release.yaml",
    "content": "name: release\n\non:\n  push:\n    tags:\n      - '**'\n\njobs:\n  release:\n    runs-on: macos-latest\n\n    steps:\n      - uses: actions/checkout@v6\n      - uses: gradle/actions/wrapper-validation@v5\n\n      - uses: actions/setup-java@v5\n        with:\n          distribution: 'zulu'\n          java-version: 8\n\n      - run: ./gradlew publish\n        env:\n          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}\n          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}\n          ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_PRIVATE_KEY }}\n          ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}\n\n      - run: ./gradlew closeAndReleaseRepository\n        env:\n          ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USER }}\n          ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }}\n"
  },
  {
    "path": ".gitignore",
    "content": "# Gradle\n.gradle\nbuild\nreports\n\n# IntelliJ\n.idea\n\n# Android\nlocal.properties\n"
  },
  {
    "path": "CHANGES.md",
    "content": "# RxAndroid Releases #\n\n### Version 3.0.2 - November, 9 2022 ###\n\nFixed:\n- Ensure the main scheduler can be replaced in unit tests without needing Robolectric.\n\n\n### Version 3.0.1 - November, 8 2022 ###\n\nFixed:\n- `AndroidSchedulers.mainThread()` now correctly checks whether async messages are supported by the\n  current Android version. Previously it always assumed they were available (true on API 16+).\n\nChanged:\n- Update to RxJava 3.1.5. This includes a transitive dependency bump to Reactive-Streams 1.0.4 which\n  re-licenses that dependency from CC-0 to MIT-0.\n\n\n### Version 3.0.0 - February, 14 2020 ###\n\nGeneral availability of RxAndroid 3.0 for use with RxJava 3.0!\n\nThe Maven groupId has changed to `io.reactivex.rxjava3` and the package is now `io.reactivex.rxjava3.android`.\n\nThe APIs and behavior of RxAndroid 3.0.0 is otherwise exactly the same as RxAndroid 2.1.1 with one notable exception:\n\nSchedulers created via `AndroidSchedulers.from` now deliver [async messages](https://developer.android.com/reference/android/os/Handler.html#createAsync(android.os.Looper)) by default.\nThis is also true for `AndroidSchedulers.mainThread()`.\n\nFor more information about RxJava 3.0 see [its release notes](https://github.com/ReactiveX/RxJava/releases/tag/v3.0.0).\n\n---\n\nVersion 2.x can be found at https://github.com/ReactiveX/RxAndroid/blob/2.x/CHANGES.md\n\nVersion 1.x can be found at https://github.com/ReactiveX/RxAndroid/blob/1.x/CHANGES.md\n"
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing to RxJava\n\nIf you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request (on a branch other than `master` or `gh-pages`).\n\nWhen submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible.\n\n## License\n\nBy contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/ReactiveX/RxAndroid/blob/2.x/LICENSE\n\nAll files are released with the Apache 2.0 license.\n\nIf you are adding a new file it should have a header like this:\n\n```\n/**\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n```\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# RxAndroid: Reactive Extensions for Android\n\nAndroid specific bindings for [RxJava 3](http://github.com/ReactiveX/RxJava).\n\nThis module adds the minimum classes to RxJava that make writing reactive components in Android\napplications easy and hassle-free. More specifically, it provides a `Scheduler` that schedules on\nthe main thread or any given `Looper`.\n\n\n## Communication\n\nSince RxAndroid is part of the RxJava family the communication channels are similar:\n\n- Google Group: [RxJava][list]\n- Twitter: [@RxJava][twitter]\n- StackOverflow: [rx-android][so]\n- [GitHub Issues][issues]\n\n\n# Binaries\n\n```groovy\ndependencies {\n    implementation 'io.reactivex.rxjava3:rxandroid:3.0.2'\n    // Because RxAndroid releases are few and far between, it is recommended you also\n    // explicitly depend on RxJava's latest version for bug fixes and new features.\n    // (see https://github.com/ReactiveX/RxJava/releases for latest 3.x.x version)\n    implementation 'io.reactivex.rxjava3:rxjava:3.1.5'\n}\n```\n\n* RxAndroid: <a href='http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.reactivex.rxjava3%22%20a%3A%22rxandroid%22'><img src='http://img.shields.io/maven-central/v/io.reactivex.rxjava3/rxandroid.svg'></a>\n* RxJava: <a href='http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.reactivex.rxjava3%22%20a%3A%22rxjava%22'><img src='http://img.shields.io/maven-central/v/io.reactivex.rxjava3/rxjava.svg'></a>\n\nAdditional binaries and dependency information for can be found at [search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22io.reactivex.rxjava3%22%20a%3A%22rxandroid%22).\n\n<details>\n<summary>Snapshots of the development version are available in Sonatype's snapshots repository.</summary>\n<p>\n\n```groovy\nrepositories {\n    mavenCentral()\n    maven {\n        url 'https://oss.sonatype.org/content/repositories/snapshots/'\n    }\n}\n\ndependencies {\n    implementation 'io.reactivex.rxjava3:rxandroid:3.1.0-SNAPSHOT'\n}\n```\n\n</p>\n</details>\n\n\n## Build\n\nTo build:\n\n```bash\n$ git clone git@github.com:ReactiveX/RxAndroid.git\n$ cd RxAndroid/\n$ ./gradlew build\n```\n\nFurther details on building can be found on the RxJava [Getting Started][start] page of the wiki.\n\n# Sample usage\n\nA sample project which provides runnable code examples that demonstrate uses of the classes in this\nproject is available in the `sample-app/` folder.\n\n## Observing on the main thread\n\nOne of the most common operations when dealing with asynchronous tasks on Android is to observe the task's\nresult or outcome on the main thread. Using vanilla Android, this would typically be accomplished with an\n`AsyncTask`. With RxJava instead you would declare your `Observable` to be observed on the main thread:\n\n```java\nObservable.just(\"one\", \"two\", \"three\", \"four\", \"five\")\n    .subscribeOn(Schedulers.newThread())\n    .observeOn(AndroidSchedulers.mainThread())\n    .subscribe(/* an Observer */);\n```\n\nThis will execute the `Observable` on a new thread, and emit results through `onNext` on the main thread.\n\n## Observing on arbitrary loopers\n\nThe previous sample is merely a specialization of a more general concept: binding asynchronous\ncommunication to an Android message loop, or `Looper`. In order to observe an `Observable` on an arbitrary\n`Looper`, create an associated `Scheduler` by calling `AndroidSchedulers.from`:\n\n```java\nLooper backgroundLooper = // ...\nObservable.just(\"one\", \"two\", \"three\", \"four\", \"five\")\n    .observeOn(AndroidSchedulers.from(backgroundLooper))\n    .subscribe(/* an Observer */)\n```\n\nThis will execute the Observable on a new thread and emit results through `onNext` on whatever thread is\nrunning `backgroundLooper`.\n\n\n## Bugs and Feedback\n\nFor bugs, feature requests, and discussion please use [GitHub Issues][issues].\nFor general usage questions please use the [mailing list][list] or [StackOverflow][so].\n\n\n## LICENSE\n\n    Copyright 2015 The RxAndroid authors\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n        http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n\n [list]: http://groups.google.com/d/forum/rxjava\n [so]: http://stackoverflow.com/questions/tagged/rx-android\n [twitter]: http://twitter.com/RxJava\n [issues]: https://github.com/ReactiveX/RxAndroid/issues\n [start]: https://github.com/ReactiveX/RxJava/wiki/Getting-Started\n"
  },
  {
    "path": "RELEASING.md",
    "content": "Release Process\n===============\n\n 1.  Ensure `VERSION_NAME` in `gradle.properties` is set to the version you want to release.\n 2.  Add an entry in `CHANGELOG.md` with the changes for the release.\n 3.  Update `README.md` with the version about to be released. Also update the RxJava version in\n     this file to its latest.\n 4.  Update the RxJava version in `rxandroid/build.gradle` to its latest. (We tell people that we\n     won't be tracking RxJava releases, and we don't, but we do it anyway when we are releasing for\n     those who ignore the advice.)\n 5.  Commit: `git commit -am \"Prepare version X.Y.X\"`\n 6.  Tag: `git tag -a X.Y.Z -m \"Version X.Y.Z\"`\n 7.  Update `VERSION_NAME` in `gradle.properties` to the next development version. You MUST include `-SNAPSHOT` on the new version.\n 8.  Commit: `git commit -am \"Prepare next development version.\"`\n 9.  Push: `git push && git push --tags`\n 10. Paste the `CHANGELOG.md` contents for this version into a Release on GitHub along with the\n     Groovy for depending on the new version (https://github.com/ReactiveX/RxAndroid/releases).\n"
  },
  {
    "path": "build.gradle",
    "content": "buildscript {\n    repositories {\n        google()\n        mavenCentral()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:4.2.2'\n        classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0'\n    }\n}\n\nallprojects {\n    repositories {\n        google()\n        mavenCentral()\n    }\n\n    tasks.withType(Test).configureEach {\n        testLogging {\n            if (System.getenv(\"CI\") == \"true\") {\n                events = [\"failed\", \"skipped\", \"passed\"]\n            }\n            exceptionFormat \"full\"\n        }\n    }\n}\n\next {\n    minSdkVersion = 9\n    compileSdkVersion = 31\n    sourceCompatibility = JavaVersion.VERSION_1_8\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-6.9.1-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "gradle.properties",
    "content": "org.gradle.jvmargs=-Xmx2048m\n\nandroid.useAndroidX=true\nandroid.enableJetifier=false\nandroid.defaults.buildfeatures.buildconfig=false\nandroid.defaults.buildfeatures.aidl=false\nandroid.defaults.buildfeatures.renderscript=false\nandroid.defaults.buildfeatures.resvalues=false\nandroid.defaults.buildfeatures.shaders=false\n\nGROUP=io.reactivex.rxjava3\nVERSION_NAME=3.1.0-SNAPSHOT\n\nPOM_NAME=RxAndroid\nPOM_DESCRIPTION=RxAndroid\n\nPOM_URL=https://github.com/ReactiveX/RxAndroid\nPOM_SCM_URL=https://github.com/ReactiveX/RxAndroid\nPOM_SCM_CONNECTION=scm:git:https://github.com/ReactiveX/RxAndroid.git\nPOM_SCM_DEV_CONNECTION=scm:git:git@github.com:ReactiveX/RxAndroid.git\n\nPOM_LICENCE_NAME=The Apache Software License, Version 2.0\nPOM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt\nPOM_LICENCE_DIST=repo\n\nPOM_DEVELOPER_ID=reactivex\nPOM_DEVELOPER_NAME=ReactiveX\nPOM_DEVELOPER_URL=https://github.com/ReactiveX\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env sh\n\n#\n# Copyright 2015 the original author or authors.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      https://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n#\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS='\"-Xmx64m\" \"-Xms64m\"'\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn () {\n    echo \"$*\"\n}\n\ndie () {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\nnonstop=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\n  NONSTOP* )\n    nonstop=true\n    ;;\nesac\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" -a \"$nonstop\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin or MSYS, switch paths to Windows format before running java\nif [ \"$cygwin\" = \"true\" -o \"$msys\" = \"true\" ] ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=`expr $i + 1`\n    done\n    case $i in\n        0) set -- ;;\n        1) set -- \"$args0\" ;;\n        2) set -- \"$args0\" \"$args1\" ;;\n        3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Escape application args\nsave () {\n    for i do printf %s\\\\n \"$i\" | sed \"s/'/'\\\\\\\\''/g;1s/^/'/;\\$s/\\$/' \\\\\\\\/\" ; done\n    echo \" \"\n}\nAPP_ARGS=`save \"$@\"`\n\n# Collect all arguments for the java command, following the shell quoting and substitution rules\neval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS \"\\\"-Dorg.gradle.appname=$APP_BASE_NAME\\\"\" -classpath \"\\\"$CLASSPATH\\\"\" org.gradle.wrapper.GradleWrapperMain \"$APP_ARGS\"\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@rem\r\n@rem Copyright 2015 the original author or authors.\r\n@rem\r\n@rem Licensed under the Apache License, Version 2.0 (the \"License\");\r\n@rem you may not use this file except in compliance with the License.\r\n@rem You may obtain a copy of the License at\r\n@rem\r\n@rem      https://www.apache.org/licenses/LICENSE-2.0\r\n@rem\r\n@rem Unless required by applicable law or agreed to in writing, software\r\n@rem distributed under the License is distributed on an \"AS IS\" BASIS,\r\n@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r\n@rem See the License for the specific language governing permissions and\r\n@rem limitations under the License.\r\n@rem\r\n\r\n@if \"%DEBUG%\" == \"\" @echo off\r\n@rem ##########################################################################\r\n@rem\r\n@rem  Gradle startup script for Windows\r\n@rem\r\n@rem ##########################################################################\r\n\r\n@rem Set local scope for the variables with windows NT shell\r\nif \"%OS%\"==\"Windows_NT\" setlocal\r\n\r\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\r\n\r\n@rem Resolve any \".\" and \"..\" in APP_HOME to make it shorter.\r\nfor %%i in (\"%APP_HOME%\") do set APP_HOME=%%~fi\r\n\r\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\r\nset DEFAULT_JVM_OPTS=\"-Xmx64m\" \"-Xms64m\"\r\n\r\n@rem Find java.exe\r\nif defined JAVA_HOME goto findJavaFromJavaHome\r\n\r\nset JAVA_EXE=java.exe\r\n%JAVA_EXE% -version >NUL 2>&1\r\nif \"%ERRORLEVEL%\" == \"0\" goto execute\r\n\r\necho.\r\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:findJavaFromJavaHome\r\nset JAVA_HOME=%JAVA_HOME:\"=%\r\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\r\n\r\nif exist \"%JAVA_EXE%\" goto execute\r\n\r\necho.\r\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\r\necho.\r\necho Please set the JAVA_HOME variable in your environment to match the\r\necho location of your Java installation.\r\n\r\ngoto fail\r\n\r\n:execute\r\n@rem Setup the command line\r\n\r\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\r\n\r\n\r\n@rem Execute Gradle\r\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %*\r\n\r\n:end\r\n@rem End local scope for the variables with windows NT shell\r\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\r\n\r\n:fail\r\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\r\nrem the _cmd.exe /c_ return code!\r\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\r\nexit /b 1\r\n\r\n:mainEnd\r\nif \"%OS%\"==\"Windows_NT\" endlocal\r\n\r\n:omega\r\n"
  },
  {
    "path": "rxandroid/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.vanniktech.maven.publish'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n\n    compileOptions {\n        sourceCompatibility rootProject.ext.sourceCompatibility\n        targetCompatibility rootProject.ext.sourceCompatibility\n    }\n\n    testOptions {\n        unitTests.returnDefaultValues = true\n    }\n}\n\ndependencies {\n    api 'io.reactivex.rxjava3:rxjava:3.1.5'\n\n    testImplementation 'junit:junit:4.13.2'\n    testImplementation 'org.robolectric:robolectric:4.2.1'\n}\n\nsigning {\n    def signingKey = findProperty('signingKey')\n    def signingPassword = findProperty('signingPassword')\n    useInMemoryPgpKeys(signingKey, signingPassword)\n}\n"
  },
  {
    "path": "rxandroid/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  Licensed under the Apache License, Version 2.0 (the \"License\");\n  you may not use this file except in compliance with the License.\n  You may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\n  Unless required by applicable law or agreed to in writing, software\n  distributed under the License is distributed on an \"AS IS\" BASIS,\n  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  See the License for the specific language governing permissions and\n  limitations under the License.\n-->\n<manifest package=\"io.reactivex.rxjava3.android\" />\n"
  },
  {
    "path": "rxandroid/src/main/java/io/reactivex/rxjava3/android/MainThreadDisposable.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android;\n\nimport android.os.Looper;\nimport io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;\nimport io.reactivex.rxjava3.disposables.Disposable;\nimport java.util.concurrent.atomic.AtomicBoolean;\n\n/**\n * A {@linkplain Disposable disposable} which ensures its {@linkplain #onDispose()\n * dispose action} is executed on the main thread. When unsubscription occurs on a different\n * thread than the main thread, the action is posted to run on the main thread as soon as possible.\n * <p>\n * Instances of this class are useful in creating observables which interact with APIs that can\n * only be used on the main thread, such as UI objects.\n * <p>\n * A {@link #verifyMainThread() convenience method} is also provided for validating whether code\n * is being called on the main thread. Calls to this method along with instances of this class are\n * commonly used when creating custom observables using the following pattern:\n * <pre><code>\n * &#064;Override public void subscribe(Observer<? extends T> o) {\n *   MainThreadDisposable.verifyMainThread();\n *\n *   // TODO setup behavior\n *\n *    o.onSubscribe(new MainThreadDisposable() {\n *     &#064;Override protected void onDispose() {\n *       // TODO undo behavior\n *     }\n *   });\n * }\n * </code></pre>\n */\npublic abstract class MainThreadDisposable implements Disposable {\n    /**\n     * Verify that the calling thread is the Android main thread.\n     * <p>\n     * Calls to this method are usually preconditions for subscription behavior which instances of\n     * this class later undo. See the class documentation for an example.\n     *\n     * @throws IllegalStateException when called from any other thread.\n     */\n    public static void verifyMainThread() {\n        if (Looper.myLooper() != Looper.getMainLooper()) {\n            throw new IllegalStateException(\n                \"Expected to be called on the main thread but was \" + Thread.currentThread().getName());\n        }\n    }\n\n    private final AtomicBoolean unsubscribed = new AtomicBoolean();\n\n    @Override\n    public final boolean isDisposed() {\n        return unsubscribed.get();\n    }\n\n    @Override\n    public final void dispose() {\n        if (unsubscribed.compareAndSet(false, true)) {\n            if (Looper.myLooper() == Looper.getMainLooper()) {\n                onDispose();\n            } else {\n                AndroidSchedulers.mainThread().scheduleDirect(this::onDispose);\n            }\n        }\n    }\n\n    protected abstract void onDispose();\n}\n"
  },
  {
    "path": "rxandroid/src/main/java/io/reactivex/rxjava3/android/plugins/RxAndroidPlugins.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.plugins;\n\nimport java.util.concurrent.Callable;\nimport io.reactivex.rxjava3.core.Scheduler;\nimport io.reactivex.rxjava3.exceptions.Exceptions;\nimport io.reactivex.rxjava3.functions.Function;\n\n/**\n * Utility class to inject handlers to certain standard RxAndroid operations.\n */\npublic final class RxAndroidPlugins {\n\n    private static volatile Function<Callable<Scheduler>, Scheduler> onInitMainThreadHandler;\n    private static volatile Function<Scheduler, Scheduler> onMainThreadHandler;\n\n    public static void setInitMainThreadSchedulerHandler(Function<Callable<Scheduler>, Scheduler> handler) {\n        onInitMainThreadHandler = handler;\n    }\n\n    public static Scheduler initMainThreadScheduler(Callable<Scheduler> scheduler) {\n        if (scheduler == null) {\n            throw new NullPointerException(\"scheduler == null\");\n        }\n        Function<Callable<Scheduler>, Scheduler> f = onInitMainThreadHandler;\n        if (f == null) {\n            return callRequireNonNull(scheduler);\n        }\n        return applyRequireNonNull(f, scheduler);\n    }\n\n    public static void setMainThreadSchedulerHandler(Function<Scheduler, Scheduler> handler) {\n        onMainThreadHandler = handler;\n    }\n\n    public static Scheduler onMainThreadScheduler(Scheduler scheduler) {\n        if (scheduler == null) {\n            throw new NullPointerException(\"scheduler == null\");\n        }\n        Function<Scheduler, Scheduler> f = onMainThreadHandler;\n        if (f == null) {\n            return scheduler;\n        }\n        return apply(f, scheduler);\n    }\n\n    /**\n     * Returns the current hook function.\n     * @return the hook function, may be null\n     */\n    public static Function<Callable<Scheduler>, Scheduler> getInitMainThreadSchedulerHandler() {\n        return onInitMainThreadHandler;\n    }\n\n    /**\n     * Returns the current hook function.\n     * @return the hook function, may be null\n     */\n    public static Function<Scheduler, Scheduler> getOnMainThreadSchedulerHandler() {\n        return onMainThreadHandler;\n    }\n\n    /**\n     * Removes all handlers and resets the default behavior.\n     */\n    public static void reset() {\n        setInitMainThreadSchedulerHandler(null);\n        setMainThreadSchedulerHandler(null);\n    }\n\n    static Scheduler callRequireNonNull(Callable<Scheduler> s) {\n        try {\n            Scheduler scheduler = s.call();\n            if (scheduler == null) {\n                throw new NullPointerException(\"Scheduler Callable returned null\");\n            }\n            return scheduler;\n        } catch (Throwable ex) {\n            throw Exceptions.propagate(ex);\n        }\n    }\n\n    static Scheduler applyRequireNonNull(Function<Callable<Scheduler>, Scheduler> f, Callable<Scheduler> s) {\n        Scheduler scheduler = apply(f,s);\n        if (scheduler == null) {\n            throw new NullPointerException(\"Scheduler Callable returned null\");\n        }\n        return scheduler;\n    }\n\n    static <T, R> R apply(Function<T, R> f, T t) {\n        try {\n            return f.apply(t);\n        } catch (Throwable ex) {\n            throw Exceptions.propagate(ex);\n        }\n    }\n\n    private RxAndroidPlugins() {\n        throw new AssertionError(\"No instances.\");\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/main/java/io/reactivex/rxjava3/android/schedulers/AndroidSchedulers.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.schedulers;\n\nimport android.annotation.SuppressLint;\nimport android.os.Build;\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.os.Message;\nimport io.reactivex.rxjava3.android.plugins.RxAndroidPlugins;\nimport io.reactivex.rxjava3.core.Scheduler;\n\n/** Android-specific Schedulers. */\npublic final class AndroidSchedulers {\n\n    private static final class MainHolder {\n        static final Scheduler DEFAULT = internalFrom(Looper.getMainLooper(), true);\n    }\n\n    private static final Scheduler MAIN_THREAD =\n        RxAndroidPlugins.initMainThreadScheduler(() -> MainHolder.DEFAULT);\n\n    /**\n     * A {@link Scheduler} which executes actions on the Android main thread.\n     * <p>\n     * The returned scheduler will post asynchronous messages to the looper by default.\n     *\n     * @see #from(Looper, boolean)\n     */\n    public static Scheduler mainThread() {\n        return RxAndroidPlugins.onMainThreadScheduler(MAIN_THREAD);\n    }\n\n    /**\n     * A {@link Scheduler} which executes actions on {@code looper}.\n     * <p>\n     * The returned scheduler will post asynchronous messages to the looper by default.\n     *\n     * @see #from(Looper, boolean)\n     */\n    public static Scheduler from(Looper looper) {\n        return from(looper, true);\n    }\n\n    /**\n     * A {@link Scheduler} which executes actions on {@code looper}.\n     *\n     * @param async if true, the scheduler will use async messaging on API >= 16 to avoid VSYNC\n     *              locking. On API < 16 this value is ignored.\n     * @see Message#setAsynchronous(boolean)\n     */\n    public static Scheduler from(Looper looper, boolean async) {\n        if (looper == null) throw new NullPointerException(\"looper == null\");\n        return internalFrom(looper, async);\n    }\n\n    @SuppressLint(\"NewApi\") // Checking for an @hide API.\n    private static Scheduler internalFrom(Looper looper, boolean async) {\n        // Below code exists in androidx-core as well, but is left here rather than include an\n        // entire extra dependency.\n        // https://developer.android.com/reference/kotlin/androidx/core/os/MessageCompat?hl=en#setAsynchronous(android.os.Message,%20kotlin.Boolean)\n        if (Build.VERSION.SDK_INT < 16) {\n            async = false;\n        } else if (async && Build.VERSION.SDK_INT < 22) {\n            // Confirm that the method is available on this API level despite being @hide.\n            Message message = Message.obtain();\n            try {\n                message.setAsynchronous(true);\n            } catch (NoSuchMethodError e) {\n                async = false;\n            }\n            message.recycle();\n        }\n        return new HandlerScheduler(new Handler(looper), async);\n    }\n\n    private AndroidSchedulers() {\n        throw new AssertionError(\"No instances.\");\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/main/java/io/reactivex/rxjava3/android/schedulers/HandlerScheduler.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.schedulers;\n\nimport android.annotation.SuppressLint;\nimport android.os.Handler;\nimport android.os.Message;\nimport io.reactivex.rxjava3.core.Scheduler;\nimport io.reactivex.rxjava3.disposables.Disposable;\nimport io.reactivex.rxjava3.plugins.RxJavaPlugins;\nimport java.util.concurrent.TimeUnit;\n\nfinal class HandlerScheduler extends Scheduler {\n    private final Handler handler;\n    private final boolean async;\n\n    HandlerScheduler(Handler handler, boolean async) {\n        this.handler = handler;\n        this.async = async;\n    }\n\n    @Override\n    @SuppressLint(\"NewApi\") // Async will only be true when the API is available to call.\n    public Disposable scheduleDirect(Runnable run, long delay, TimeUnit unit) {\n        if (run == null) throw new NullPointerException(\"run == null\");\n        if (unit == null) throw new NullPointerException(\"unit == null\");\n\n        run = RxJavaPlugins.onSchedule(run);\n        ScheduledRunnable scheduled = new ScheduledRunnable(handler, run);\n        Message message = Message.obtain(handler, scheduled);\n        if (async) {\n            message.setAsynchronous(true);\n        }\n        handler.sendMessageDelayed(message, unit.toMillis(delay));\n        return scheduled;\n    }\n\n    @Override\n    public Worker createWorker() {\n        return new HandlerWorker(handler, async);\n    }\n\n    private static final class HandlerWorker extends Worker {\n        private final Handler handler;\n        private final boolean async;\n\n        private volatile boolean disposed;\n\n        HandlerWorker(Handler handler, boolean async) {\n            this.handler = handler;\n            this.async = async;\n        }\n\n        @Override\n        @SuppressLint(\"NewApi\") // Async will only be true when the API is available to call.\n        public Disposable schedule(Runnable run, long delay, TimeUnit unit) {\n            if (run == null) throw new NullPointerException(\"run == null\");\n            if (unit == null) throw new NullPointerException(\"unit == null\");\n\n            if (disposed) {\n                return Disposable.disposed();\n            }\n\n            run = RxJavaPlugins.onSchedule(run);\n\n            ScheduledRunnable scheduled = new ScheduledRunnable(handler, run);\n\n            Message message = Message.obtain(handler, scheduled);\n            message.obj = this; // Used as token for batch disposal of this worker's runnables.\n\n            if (async) {\n                message.setAsynchronous(true);\n            }\n\n            handler.sendMessageDelayed(message, unit.toMillis(delay));\n\n            // Re-check disposed state for removing in case we were racing a call to dispose().\n            if (disposed) {\n                handler.removeCallbacks(scheduled);\n                return Disposable.disposed();\n            }\n\n            return scheduled;\n        }\n\n        @Override\n        public void dispose() {\n            disposed = true;\n            handler.removeCallbacksAndMessages(this /* token */);\n        }\n\n        @Override\n        public boolean isDisposed() {\n            return disposed;\n        }\n    }\n\n    private static final class ScheduledRunnable implements Runnable, Disposable {\n        private final Handler handler;\n        private final Runnable delegate;\n\n        private volatile boolean disposed; // Tracked solely for isDisposed().\n\n        ScheduledRunnable(Handler handler, Runnable delegate) {\n            this.handler = handler;\n            this.delegate = delegate;\n        }\n\n        @Override\n        public void run() {\n            try {\n                delegate.run();\n            } catch (Throwable t) {\n                RxJavaPlugins.onError(t);\n            }\n        }\n\n        @Override\n        public void dispose() {\n            handler.removeCallbacks(this);\n            disposed = true;\n        }\n\n        @Override\n        public boolean isDisposed() {\n            return disposed;\n        }\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/MainThreadDisposableTest.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android;\n\nimport io.reactivex.rxjava3.disposables.Disposable;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicBoolean;\nimport java.util.concurrent.atomic.AtomicInteger;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\nimport org.robolectric.shadows.ShadowLooper;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest=Config.NONE)\npublic final class MainThreadDisposableTest {\n  @Test public void verifyDoesNotThrowOnMainThread() throws InterruptedException {\n    MainThreadDisposable.verifyMainThread();\n    // Robolectric tests run on its main thread.\n  }\n\n  @Test public void verifyThrowsOffMainThread() throws InterruptedException {\n    final CountDownLatch latch = new CountDownLatch(1);\n    new Thread(new Runnable() {\n      @Override public void run() {\n        try {\n          MainThreadDisposable.verifyMainThread();\n          fail();\n        } catch (IllegalStateException e) {\n          assertTrue(e.getMessage().startsWith(\"Expected to be called on the main thread\"));\n          latch.countDown();\n        }\n      }\n    }).start();\n\n    assertTrue(latch.await(1, SECONDS));\n  }\n\n  @Test public void onUnsubscribeRunsSyncOnMainThread() {\n    ShadowLooper.pauseMainLooper();\n\n    final AtomicBoolean called = new AtomicBoolean();\n    new MainThreadDisposable() {\n      @Override protected void onDispose() {\n        called.set(true);\n      }\n    }.dispose();\n\n    assertTrue(called.get());\n  }\n\n  @Test public void unsubscribeTwiceDoesNotRunTwice() {\n    final AtomicInteger called = new AtomicInteger(0);\n\n    Disposable disposable = new MainThreadDisposable() {\n      @Override protected void onDispose() {\n        called.incrementAndGet();\n      }\n    };\n\n    disposable.dispose();\n    disposable.dispose();\n    disposable.dispose();\n\n    assertEquals(1, called.get());\n  }\n\n  @Test public void onUnsubscribePostsOffMainThread() throws InterruptedException {\n    ShadowLooper.pauseMainLooper();\n\n    final CountDownLatch latch = new CountDownLatch(1);\n    final AtomicBoolean called = new AtomicBoolean();\n    new Thread(new Runnable() {\n      @Override public void run() {\n        new MainThreadDisposable() {\n          @Override protected void onDispose() {\n            called.set(true);\n          }\n        }.dispose();\n        latch.countDown();\n      }\n    }).start();\n\n    assertTrue(latch.await(1, SECONDS));\n    assertFalse(called.get()); // Callback has not yet run.\n\n    ShadowLooper.runMainLooperOneTask();\n    assertTrue(called.get());\n  }\n\n  @Test\n  public void disposedState() {\n    MainThreadDisposable disposable = new MainThreadDisposable() {\n      @Override protected void onDispose() {\n      }\n    };\n    assertFalse(disposable.isDisposed());\n    disposable.dispose();\n    assertTrue(disposable.isDisposed());\n  }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/plugins/RxAndroidPluginsNoRobolectricTest.java",
    "content": "package io.reactivex.rxjava3.android.plugins;\n\nimport io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;\nimport io.reactivex.rxjava3.android.testutil.EmptyScheduler;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport static org.junit.Assert.assertSame;\n\npublic final class RxAndroidPluginsNoRobolectricTest {\n    @Before @After\n    public void setUpAndTearDown() {\n        RxAndroidPlugins.reset();\n    }\n    \n    @Test public void mainThreadSchedulerCanBeReplaced() {\n        EmptyScheduler emptyScheduler = new EmptyScheduler();\n        RxAndroidPlugins.setMainThreadSchedulerHandler(scheduler -> emptyScheduler);\n        assertSame(emptyScheduler, AndroidSchedulers.mainThread());\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/plugins/RxAndroidPluginsTest.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.plugins;\n\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\n\nimport java.util.concurrent.Callable;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.rxjava3.android.testutil.EmptyScheduler;\nimport io.reactivex.rxjava3.android.plugins.RxAndroidPlugins;\nimport io.reactivex.rxjava3.core.Scheduler;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.schedulers.Schedulers;\n\nimport static junit.framework.TestCase.fail;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertNull;\nimport static org.junit.Assert.assertSame;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest=Config.NONE)\npublic final class RxAndroidPluginsTest {\n    @Before @After\n    public void setUpAndTearDown() {\n        RxAndroidPlugins.reset();\n    }\n\n    @Test\n    public void mainThreadHandlerCalled() {\n        final AtomicReference<Scheduler> schedulerRef = new AtomicReference<>();\n        final Scheduler newScheduler = new EmptyScheduler();\n        RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {\n            @Override public Scheduler apply(Scheduler scheduler) {\n                schedulerRef.set(scheduler);\n                return newScheduler;\n            }\n        });\n\n        Scheduler scheduler = new EmptyScheduler();\n        Scheduler actual = RxAndroidPlugins.onMainThreadScheduler(scheduler);\n        assertSame(newScheduler, actual);\n        assertSame(scheduler, schedulerRef.get());\n    }\n\n    @Test\n    public void resetClearsMainThreadHandler() {\n        RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {\n            @Override public Scheduler apply(Scheduler scheduler) {\n                throw new AssertionError();\n            }\n        });\n        RxAndroidPlugins.reset();\n\n        Scheduler scheduler = new EmptyScheduler();\n        Scheduler actual = RxAndroidPlugins.onMainThreadScheduler(scheduler);\n        assertSame(scheduler, actual);\n    }\n\n    @Test\n    public void initMainThreadHandlerCalled() {\n        final AtomicReference<Callable<Scheduler>> schedulerRef = new AtomicReference<>();\n        final Scheduler newScheduler = new EmptyScheduler();\n        RxAndroidPlugins\n                .setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {\n                    @Override public Scheduler apply(Callable<Scheduler> scheduler) {\n                        schedulerRef.set(scheduler);\n                        return newScheduler;\n                    }\n                });\n\n        Callable<Scheduler> scheduler = new Callable<Scheduler>() {\n            @Override public Scheduler call() throws Exception {\n                throw new AssertionError();\n            }\n        };\n        Scheduler actual = RxAndroidPlugins.initMainThreadScheduler(scheduler);\n        assertSame(newScheduler, actual);\n        assertSame(scheduler, schedulerRef.get());\n    }\n\n    @Test\n    public void resetClearsInitMainThreadHandler() throws Exception {\n        RxAndroidPlugins\n                .setInitMainThreadSchedulerHandler(new Function<Callable<Scheduler>, Scheduler>() {\n                    @Override public Scheduler apply(Callable<Scheduler> scheduler) {\n                        throw new AssertionError();\n                    }\n                });\n\n        final Scheduler scheduler = new EmptyScheduler();\n        Callable<Scheduler> schedulerCallable = new Callable<Scheduler>() {\n            @Override public Scheduler call() throws Exception {\n                return scheduler;\n            }\n        };\n\n        RxAndroidPlugins.reset();\n\n        Scheduler actual = RxAndroidPlugins.initMainThreadScheduler(schedulerCallable);\n        assertSame(schedulerCallable.call(), actual);\n    }\n\n    @Test\n    public void defaultMainThreadSchedulerIsInitializedLazily() {\n        Function<Callable<Scheduler>, Scheduler> safeOverride =\n                new Function<Callable<Scheduler>, Scheduler>() {\n            @Override public Scheduler apply(Callable<Scheduler> scheduler) {\n                return new EmptyScheduler();\n            }\n        };\n        Callable<Scheduler> unsafeDefault = new Callable<Scheduler>() {\n            @Override public Scheduler call() throws Exception {\n                throw new AssertionError();\n            }\n        };\n\n       RxAndroidPlugins.setInitMainThreadSchedulerHandler(safeOverride);\n       RxAndroidPlugins.initMainThreadScheduler(unsafeDefault);\n    }\n\n    @Test\n    public void overrideInitMainSchedulerThrowsWhenSchedulerCallableIsNull() {\n        try {\n            RxAndroidPlugins.initMainThreadScheduler(null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"scheduler == null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void overrideInitMainSchedulerThrowsWhenSchedulerCallableReturnsNull() {\n        Callable<Scheduler> nullResultCallable = new Callable<Scheduler>() {\n            @Override public Scheduler call() throws Exception {\n                return null;\n            }\n        };\n\n        try {\n            RxAndroidPlugins.initMainThreadScheduler(nullResultCallable);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"Scheduler Callable returned null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void getInitMainThreadSchedulerHandlerReturnsHandler() {\n        Function<Callable<Scheduler>, Scheduler> handler = new Function<Callable<Scheduler>, Scheduler>() {\n            @Override public Scheduler apply(Callable<Scheduler> schedulerCallable) throws Exception {\n                return Schedulers.trampoline();\n            }\n        };\n        RxAndroidPlugins.setInitMainThreadSchedulerHandler(handler);\n        assertSame(handler, RxAndroidPlugins.getInitMainThreadSchedulerHandler());\n    }\n\n    @Test\n    public void getMainThreadSchedulerHandlerReturnsHandler() {\n        Function<Scheduler, Scheduler> handler = new Function<Scheduler, Scheduler>() {\n            @Override public Scheduler apply(Scheduler scheduler) {\n                return Schedulers.trampoline();\n            }\n        };\n        RxAndroidPlugins.setMainThreadSchedulerHandler(handler);\n        assertSame(handler, RxAndroidPlugins.getOnMainThreadSchedulerHandler());\n    }\n\n    @Test\n    public void getInitMainThreadSchedulerHandlerReturnsNullIfNotSet() {\n        RxAndroidPlugins.reset();\n        assertNull(RxAndroidPlugins.getInitMainThreadSchedulerHandler());\n    }\n\n    @Test\n    public void getMainThreadSchedulerHandlerReturnsNullIfNotSet() {\n        RxAndroidPlugins.reset();\n        assertNull(RxAndroidPlugins.getOnMainThreadSchedulerHandler());\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/schedulers/AndroidSchedulersTest.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.schedulers;\n\nimport android.os.Build;\nimport android.os.Looper;\nimport android.os.Message;\n\nimport io.reactivex.rxjava3.android.plugins.RxAndroidPlugins;\nimport io.reactivex.rxjava3.android.testutil.EmptyScheduler;\nimport io.reactivex.rxjava3.core.Scheduler;\nimport io.reactivex.rxjava3.functions.Function;\n\nimport java.util.concurrent.atomic.AtomicInteger;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\nimport org.robolectric.shadows.ShadowLooper;\nimport org.robolectric.shadows.ShadowMessageQueue;\nimport org.robolectric.util.ReflectionHelpers;\n\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertNotNull;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.robolectric.Shadows.shadowOf;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest=Config.NONE)\npublic final class AndroidSchedulersTest {\n\n    @Before @After\n    public void setUpAndTearDown() {\n        RxAndroidPlugins.reset();\n    }\n\n    @Test\n    public void mainThreadCallsThroughToHook() {\n        final AtomicInteger called = new AtomicInteger();\n        final Scheduler newScheduler = new EmptyScheduler();\n        RxAndroidPlugins.setMainThreadSchedulerHandler(new Function<Scheduler, Scheduler>() {\n            @Override public Scheduler apply(Scheduler scheduler) {\n                called.getAndIncrement();\n                return newScheduler;\n            }\n        });\n\n        assertSame(newScheduler, AndroidSchedulers.mainThread());\n        assertEquals(1, called.get());\n\n        assertSame(newScheduler, AndroidSchedulers.mainThread());\n        assertEquals(2, called.get());\n    }\n\n    @Test\n    public void fromNullThrows() {\n        try {\n            AndroidSchedulers.from(null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"looper == null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void fromNullThrowsTwoArg() {\n        try {\n            AndroidSchedulers.from(null, false);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"looper == null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void fromReturnsUsableScheduler() {\n        assertNotNull(AndroidSchedulers.from(Looper.getMainLooper()));\n    }\n\n    @Test\n    public void mainThreadAsyncMessagesByDefault() {\n        ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());\n        mainLooper.pause();\n        ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());\n\n        Scheduler main = AndroidSchedulers.mainThread();\n        main.scheduleDirect(new Runnable() {\n            @Override public void run() {\n            }\n        });\n\n        Message message = mainMessageQueue.getHead();\n        assertTrue(message.isAsynchronous());\n    }\n\n    @Test\n    public void fromAsyncMessagesByDefault() {\n        ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());\n        mainLooper.pause();\n        ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());\n\n        Scheduler main = AndroidSchedulers.from(Looper.getMainLooper());\n        main.scheduleDirect(new Runnable() {\n            @Override public void run() {\n            }\n        });\n\n        Message message = mainMessageQueue.getHead();\n        assertTrue(message.isAsynchronous());\n    }\n\n    @Test\n    public void asyncIgnoredPre16() {\n        int oldValue = Build.VERSION.SDK_INT;\n        ReflectionHelpers.setStaticField(Build.VERSION.class, \"SDK_INT\", 14);\n        try {\n            ShadowLooper mainLooper = shadowOf(Looper.getMainLooper());\n            mainLooper.pause();\n            ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());\n\n            Scheduler main = AndroidSchedulers.from(Looper.getMainLooper(), true);\n            main.scheduleDirect(new Runnable() {\n                @Override public void run() {\n                }\n            });\n\n            Message message = mainMessageQueue.getHead();\n            assertFalse(message.isAsynchronous());\n        } finally {\n            ReflectionHelpers.setStaticField(Build.VERSION.class, \"SDK_INT\", oldValue);\n        }\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/schedulers/HandlerSchedulerTest.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.schedulers;\n\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.os.Message;\n\nimport io.reactivex.rxjava3.android.testutil.CountingRunnable;\nimport io.reactivex.rxjava3.core.Scheduler;\nimport io.reactivex.rxjava3.core.Scheduler.Worker;\nimport io.reactivex.rxjava3.disposables.Disposable;\nimport io.reactivex.rxjava3.functions.Consumer;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.plugins.RxJavaPlugins;\n\nimport java.util.Arrays;\nimport java.util.Collection;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.atomic.AtomicReference;\nimport org.junit.After;\nimport org.junit.Before;\nimport org.junit.Ignore;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.ParameterizedRobolectricTestRunner;\nimport org.robolectric.annotation.Config;\nimport org.robolectric.shadows.ShadowLooper;\nimport org.robolectric.shadows.ShadowMessageQueue;\n\nimport static java.util.concurrent.TimeUnit.MINUTES;\nimport static java.util.concurrent.TimeUnit.SECONDS;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertNull;\nimport static org.junit.Assert.assertSame;\nimport static org.junit.Assert.assertTrue;\nimport static org.junit.Assert.fail;\nimport static org.robolectric.Shadows.shadowOf;\nimport static org.robolectric.shadows.ShadowLooper.idleMainLooper;\nimport static org.robolectric.shadows.ShadowLooper.pauseMainLooper;\nimport static org.robolectric.shadows.ShadowLooper.runUiThreadTasks;\nimport static org.robolectric.shadows.ShadowLooper.runUiThreadTasksIncludingDelayedTasks;\nimport static org.robolectric.shadows.ShadowLooper.unPauseMainLooper;\n\n@RunWith(ParameterizedRobolectricTestRunner.class)\n@Config(manifest=Config.NONE, sdk = 16)\npublic final class HandlerSchedulerTest {\n\n    @ParameterizedRobolectricTestRunner.Parameters(name = \"async = {0}\")\n    public static Collection<Object[]> data() {\n        return Arrays.asList(new Object[][]{\n            {true},\n            {false}\n        });\n    }\n\n    private final Scheduler scheduler;\n    private final boolean async;\n\n    public HandlerSchedulerTest(boolean async) {\n        this.scheduler = new HandlerScheduler(new Handler(Looper.getMainLooper()), async);\n        this.async = async;\n    }\n\n    @Before\n    public void setUp() {\n        RxJavaPlugins.reset();\n        pauseMainLooper(); // Take manual control of looper task queue.\n    }\n\n    @After\n    public void tearDown() {\n        RxJavaPlugins.reset();\n        unPauseMainLooper();\n    }\n\n    @Test\n    public void directScheduleOncePostsImmediately() {\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.scheduleDirect(counter);\n\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n    }\n\n    @Test\n    public void directScheduleOnceWithNegativeDelayPostsImmediately() {\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.scheduleDirect(counter, -1, TimeUnit.MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n    }\n\n    @Test\n    public void directScheduleOnceUsesHook() {\n        final CountingRunnable newCounter = new CountingRunnable();\n        final AtomicReference<Runnable> runnableRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                runnableRef.set(runnable);\n                return newCounter;\n            }\n        });\n\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.scheduleDirect(counter);\n\n        // Verify our runnable was passed to the schedulers hook.\n        assertSame(counter, runnableRef.get());\n\n        runUiThreadTasks();\n        // Verify the scheduled runnable was the one returned from the hook.\n        assertEquals(1, newCounter.get());\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void directScheduleOnceDisposedDoesNotRun() {\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = scheduler.scheduleDirect(counter);\n        disposable.dispose();\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void directScheduleOnceWithDelayPostsWithDelay() {\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.scheduleDirect(counter, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n    }\n\n    @Test\n    public void directScheduleOnceWithDelayUsesHook() {\n        final CountingRunnable newCounter = new CountingRunnable();\n        final AtomicReference<Runnable> runnableRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                runnableRef.set(runnable);\n                return newCounter;\n            }\n        });\n\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.scheduleDirect(counter, 1, MINUTES);\n\n        // Verify our runnable was passed to the schedulers hook.\n        assertSame(counter, runnableRef.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        // Verify the scheduled runnable was the one returned from the hook.\n        assertEquals(1, newCounter.get());\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void directScheduleOnceWithDelayDisposedDoesNotRun() {\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = scheduler.scheduleDirect(counter, 1, MINUTES);\n\n        idleMainLooper(30, SECONDS);\n        disposable.dispose();\n\n        idleMainLooper(30, SECONDS);\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void directSchedulePeriodicallyReschedulesItself() {\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.schedulePeriodicallyDirect(counter, 1, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(3, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void directSchedulePeriodicallyUsesHookOnce() {\n        final CountingRunnable newCounter = new CountingRunnable();\n        final AtomicReference<Runnable> runnableRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                runnableRef.set(runnable);\n                return newCounter;\n            }\n        });\n\n        CountingRunnable counter = new CountingRunnable();\n        scheduler.schedulePeriodicallyDirect(counter, 1, 1, MINUTES);\n\n        // Verify our action was passed to the schedulers hook.\n        assertSame(counter, runnableRef.get());\n        runnableRef.set(null);\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        // Verify the scheduled action was the one returned from the hook.\n        assertEquals(1, newCounter.get());\n        assertEquals(0, counter.get());\n\n        // Ensure the hook was not called again when the runnable re-scheduled itself.\n        assertNull(runnableRef.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void directSchedulePeriodicallyDisposedDoesNotRun() {\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = scheduler.schedulePeriodicallyDirect(counter, 1, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        disposable.dispose();\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void directSchedulePeriodicallyDisposedDuringRunDoesNotReschedule() {\n        final AtomicReference<Disposable> disposableRef = new AtomicReference<>();\n        CountingRunnable counter = new CountingRunnable() {\n            @Override public void run() {\n                super.run();\n                if (get() == 2) {\n                    disposableRef.get().dispose();\n                }\n            }\n        };\n        Disposable disposable = scheduler.schedulePeriodicallyDirect(counter, 1, 1, MINUTES);\n        disposableRef.set(disposable);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        // Dispose will have happened here during the last run() execution.\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void directSchedulePeriodicallyThrowingDoesNotReschedule() {\n        CountingRunnable counter = new CountingRunnable() {\n            @Override public void run() {\n                super.run();\n                if (get() == 2) {\n                    throw new RuntimeException(\"Broken!\");\n                }\n            }\n        };\n        scheduler.schedulePeriodicallyDirect(counter, 1, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        // Exception will have happened here during the last run() execution.\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOncePostsImmediately() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter);\n\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOnceWithNegativeDelayPostsImmediately() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter, -1, TimeUnit.MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOnceUsesHook() {\n        final CountingRunnable newCounter = new CountingRunnable();\n        final AtomicReference<Runnable> runnableRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                runnableRef.set(runnable);\n                return newCounter;\n            }\n        });\n\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter);\n\n        // Verify our runnable was passed to the schedulers hook.\n        assertSame(counter, runnableRef.get());\n\n        runUiThreadTasks();\n        // Verify the scheduled runnable was the one returned from the hook.\n        assertEquals(1, newCounter.get());\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOnceDisposedDoesNotRun() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = worker.schedule(counter);\n        disposable.dispose();\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOnceWithDelayPostsWithDelay() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOnceWithDelayUsesHook() {\n        final CountingRunnable newCounter = new CountingRunnable();\n        final AtomicReference<Runnable> runnableRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                runnableRef.set(runnable);\n                return newCounter;\n            }\n        });\n\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter, 1, MINUTES);\n\n        // Verify our runnable was passed to the schedulers hook.\n        assertSame(counter, runnableRef.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        // Verify the scheduled runnable was the one returned from the hook.\n        assertEquals(1, newCounter.get());\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void workerScheduleOnceWithDelayDisposedDoesNotRun() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = worker.schedule(counter, 1, MINUTES);\n\n        idleMainLooper(30, SECONDS);\n        disposable.dispose();\n\n        idleMainLooper(30, SECONDS);\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void workerSchedulePeriodicallyReschedulesItself() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedulePeriodically(counter, 1, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(3, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void workerSchedulePeriodicallyUsesHookOnce() {\n        Worker worker = scheduler.createWorker();\n\n        final CountingRunnable newCounter = new CountingRunnable();\n        final AtomicReference<Runnable> runnableRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                runnableRef.set(runnable);\n                return newCounter;\n            }\n        });\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedulePeriodically(counter, 1, 1, MINUTES);\n\n        // Verify our action was passed to the schedulers hook.\n        assertSame(counter, runnableRef.get());\n        runnableRef.set(null);\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        // Verify the scheduled action was the one returned from the hook.\n        assertEquals(1, newCounter.get());\n        assertEquals(0, counter.get());\n\n        // Ensure the hook was not called again when the runnable re-scheduled itself.\n        assertNull(runnableRef.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void workerSchedulePeriodicallyDisposedDoesNotRun() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = worker.schedulePeriodically(counter, 1, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        disposable.dispose();\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void workerSchedulePeriodicallyDisposedDuringRunDoesNotReschedule() {\n        Worker worker = scheduler.createWorker();\n\n        final AtomicReference<Disposable> disposableRef = new AtomicReference<>();\n        CountingRunnable counter = new CountingRunnable() {\n            @Override public void run() {\n                super.run();\n                if (get() == 2) {\n                    disposableRef.get().dispose();\n                }\n            }\n        };\n        Disposable disposable = worker.schedulePeriodically(counter, 1, 1, MINUTES);\n        disposableRef.set(disposable);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        // Dispose will have happened here during the last run() execution.\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void workerSchedulePeriodicallyThrowingDoesNotReschedule() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable() {\n            @Override public void run() {\n                super.run();\n                if (get() == 2) {\n                    throw new RuntimeException(\"Broken!\");\n                }\n            }\n        };\n        worker.schedulePeriodically(counter, 1, 1, MINUTES);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(1, counter.get());\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n\n        // Exception will have happened here during the last run() execution.\n\n        idleMainLooper(1, MINUTES);\n        runUiThreadTasks();\n        assertEquals(2, counter.get());\n    }\n\n    @Test\n    public void workerDisposableTracksDisposedState() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        Disposable disposable = worker.schedule(counter);\n        assertFalse(disposable.isDisposed());\n\n        disposable.dispose();\n        assertTrue(disposable.isDisposed());\n    }\n\n    @Test\n    public void workerUnsubscriptionDuringSchedulingCancelsScheduledAction() {\n        final AtomicReference<Worker> workerRef = new AtomicReference<>();\n        RxJavaPlugins.setScheduleHandler(new Function<Runnable, Runnable>() {\n            @Override public Runnable apply(Runnable runnable) {\n                // Purposefully unsubscribe in an asinine point after the normal unsubscribed check.\n                workerRef.get().dispose();\n                return runnable;\n            }\n        });\n\n        Worker worker = scheduler.createWorker();\n        workerRef.set(worker);\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter);\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void workerDisposeCancelsScheduled() {\n        Worker worker = scheduler.createWorker();\n\n        CountingRunnable counter = new CountingRunnable();\n        worker.schedule(counter, 1, MINUTES);\n\n        worker.dispose();\n\n        runUiThreadTasks();\n        assertEquals(0, counter.get());\n    }\n\n    @Test\n    public void workerUnsubscriptionDoesNotAffectOtherWorkers() {\n        Worker workerA = scheduler.createWorker();\n        CountingRunnable counterA = new CountingRunnable();\n        workerA.schedule(counterA, 1, MINUTES);\n\n        Worker workerB = scheduler.createWorker();\n        CountingRunnable counterB = new CountingRunnable();\n        workerB.schedule(counterB, 1, MINUTES);\n\n        workerA.dispose();\n\n        runUiThreadTasksIncludingDelayedTasks();\n        assertEquals(0, counterA.get());\n        assertEquals(1, counterB.get());\n    }\n\n    @Test\n    public void workerTracksDisposedState() {\n        Worker worker = scheduler.createWorker();\n        assertFalse(worker.isDisposed());\n\n        worker.dispose();\n        assertTrue(worker.isDisposed());\n    }\n\n    @Test\n    public void disposedWorkerReturnsDisposedDisposables() {\n        Worker worker = scheduler.createWorker();\n        worker.dispose();\n\n        Disposable disposable = worker.schedule(new CountingRunnable());\n        assertTrue(disposable.isDisposed());\n    }\n\n    @Test\n    public void throwingActionRoutedToRxJavaPlugins() {\n        Consumer<? super Throwable> originalErrorHandler = RxJavaPlugins.getErrorHandler();\n\n        try {\n            final AtomicReference<Throwable> throwableRef = new AtomicReference<>();\n            RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {\n                @Override\n                public void accept(Throwable throwable) throws Exception {\n                    throwableRef.set(throwable);\n                }\n            });\n\n            Worker worker = scheduler.createWorker();\n\n            final NullPointerException npe = new NullPointerException();\n            Runnable action = new Runnable() {\n                @Override\n                public void run() {\n                    throw npe;\n                }\n            };\n            worker.schedule(action);\n\n            runUiThreadTasks();\n            assertSame(npe, throwableRef.get());\n        } finally {\n            RxJavaPlugins.setErrorHandler(originalErrorHandler);\n        }\n    }\n\n    @Test\n    public void directScheduleOnceInputValidation() {\n        try {\n            scheduler.scheduleDirect(null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"run == null\", e.getMessage());\n        }\n        try {\n            scheduler.scheduleDirect(null, 1, MINUTES);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"run == null\", e.getMessage());\n        }\n        try {\n            scheduler.scheduleDirect(new CountingRunnable(), 1, null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"unit == null\", e.getMessage());\n        }\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void directSchedulePeriodicallyInputValidation() {\n        try {\n            scheduler.schedulePeriodicallyDirect(null, 1, 1, MINUTES);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"run == null\", e.getMessage());\n        }\n        try {\n            scheduler.schedulePeriodicallyDirect(new CountingRunnable(), 1, -1, MINUTES);\n            fail();\n        } catch (IllegalArgumentException e) {\n            assertEquals(\"period < 0: -1\", e.getMessage());\n        }\n        try {\n            scheduler.schedulePeriodicallyDirect(new CountingRunnable(), 1, 1, null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"unit == null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void workerScheduleOnceInputValidation() {\n        Worker worker = scheduler.createWorker();\n        try {\n            worker.schedule(null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"run == null\", e.getMessage());\n        }\n        try {\n            worker.schedule(null, 1, MINUTES);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"run == null\", e.getMessage());\n        }\n        try {\n            worker.schedule(new CountingRunnable(), 1, null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"unit == null\", e.getMessage());\n        }\n    }\n\n    @Test @Ignore(\"Implementation delegated to default RxJava implementation\")\n    public void workerSchedulePeriodicallyInputValidation() {\n        Worker worker = scheduler.createWorker();\n        try {\n            worker.schedulePeriodically(null, 1, 1, MINUTES);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"run == null\", e.getMessage());\n        }\n        try {\n            worker.schedulePeriodically(new CountingRunnable(), 1, -1, MINUTES);\n            fail();\n        } catch (IllegalArgumentException e) {\n            assertEquals(\"period < 0: -1\", e.getMessage());\n        }\n        try {\n            worker.schedulePeriodically(new CountingRunnable(), 1, 1, null);\n            fail();\n        } catch (NullPointerException e) {\n            assertEquals(\"unit == null\", e.getMessage());\n        }\n    }\n\n    @Test\n    public void directScheduleSetAsync() {\n        ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());\n\n        scheduler.scheduleDirect(new Runnable() {\n            @Override public void run() {\n            }\n        });\n\n        Message message = mainMessageQueue.getHead();\n        assertEquals(async, message.isAsynchronous());\n    }\n\n    @Test\n    public void workerScheduleSetAsync() {\n        ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());\n\n        Worker worker = scheduler.createWorker();\n        worker.schedule(new Runnable() {\n            @Override public void run() {\n            }\n        });\n\n        Message message = mainMessageQueue.getHead();\n        assertEquals(async, message.isAsynchronous());\n    }\n\n    @Test\n    public void workerSchedulePeriodicallySetAsync() {\n        ShadowMessageQueue mainMessageQueue = shadowOf(Looper.getMainLooper().getQueue());\n\n        Worker worker = scheduler.createWorker();\n        worker.schedulePeriodically(new Runnable() {\n            @Override public void run() {\n            }\n        }, 1, 1, MINUTES);\n\n        Message message = mainMessageQueue.getHead();\n        assertEquals(async, message.isAsynchronous());\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/testutil/CountingRunnable.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.testutil;\n\nimport java.util.concurrent.atomic.AtomicInteger;\n\npublic class CountingRunnable extends AtomicInteger implements Runnable {\n    @Override\n    public void run() {\n        getAndIncrement();\n    }\n}\n"
  },
  {
    "path": "rxandroid/src/test/java/io/reactivex/rxjava3/android/testutil/EmptyScheduler.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.testutil;\n\nimport io.reactivex.rxjava3.core.Scheduler;\n\npublic final class EmptyScheduler extends Scheduler {\n    @Override\n    public Worker createWorker() {\n        throw new UnsupportedOperationException();\n    }\n}\n"
  },
  {
    "path": "sample-app/build.gradle",
    "content": "apply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion 15\n        targetSdkVersion 31\n        versionCode 1\n        versionName '1.0'\n    }\n\n    lintOptions {\n        lintConfig file('lint.xml')\n    }\n\n    compileOptions {\n        sourceCompatibility rootProject.ext.sourceCompatibility\n        targetCompatibility rootProject.ext.sourceCompatibility\n    }\n}\n\ndependencies {\n    implementation project(':rxandroid')\n}\n"
  },
  {
    "path": "sample-app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n    package=\"io.reactivex.rxjava3.android.samples\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:tools=\"http://schemas.android.com/tools\">\n\n    <application\n        android:allowBackup=\"true\"\n        android:fullBackupContent=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/AppTheme\"\n        tools:ignore=\"UnusedAttribute,GoogleAppIndexingWarning\">\n\n        <activity\n            android:name=\".MainActivity\"\n            android:label=\"@string/app_name\"\n            android:exported=\"true\">\n\n            <intent-filter>\n                <category android:name=\"android.intent.category.LAUNCHER\"/>\n                <category android:name=\"android.intent.category.DEFAULT\"/>\n\n                <action android:name=\"android.intent.action.MAIN\"/>\n            </intent-filter>\n        </activity>\n\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "sample-app/src/main/java/io/reactivex/rxjava3/android/samples/MainActivity.java",
    "content": "/*\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage io.reactivex.rxjava3.android.samples;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.os.SystemClock;\nimport android.util.Log;\nimport android.view.View;\nimport io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.core.ObservableSource;\nimport io.reactivex.rxjava3.disposables.CompositeDisposable;\nimport io.reactivex.rxjava3.functions.Supplier;\nimport io.reactivex.rxjava3.observers.DisposableObserver;\nimport io.reactivex.rxjava3.schedulers.Schedulers;\n\npublic class MainActivity extends Activity {\n    private static final String TAG = \"RxAndroidSamples\";\n\n    private final CompositeDisposable disposables = new CompositeDisposable();\n\n    @Override protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.main_activity);\n        findViewById(R.id.button_run_scheduler).setOnClickListener(new View.OnClickListener() {\n            @Override public void onClick(View v) {\n                onRunSchedulerExampleButtonClicked();\n            }\n        });\n    }\n\n    @Override protected void onDestroy() {\n        super.onDestroy();\n        disposables.clear();\n    }\n\n    void onRunSchedulerExampleButtonClicked() {\n        disposables.add(sampleObservable()\n            // Run on a background thread\n            .subscribeOn(Schedulers.io())\n            // Be notified on the main thread\n            .observeOn(AndroidSchedulers.mainThread())\n            .subscribeWith(new DisposableObserver<String>() {\n                @Override public void onComplete() {\n                    Log.d(TAG, \"onComplete()\");\n                }\n\n                @Override public void onError(Throwable e) {\n                    Log.e(TAG, \"onError()\", e);\n                }\n\n                @Override public void onNext(String string) {\n                    Log.d(TAG, \"onNext(\" + string + \")\");\n                }\n            }));\n    }\n\n    static Observable<String> sampleObservable() {\n        return Observable.defer(new Supplier<ObservableSource<? extends String>>() {\n            @Override public ObservableSource<? extends String> get() throws Throwable {\n                // Do some long running operation\n                SystemClock.sleep(5000);\n                return Observable.just(\"one\", \"two\", \"three\", \"four\", \"five\");\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "sample-app/src/main/res/layout/main_activity.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    android:paddingBottom=\"@dimen/activity_vertical_margin\"\n    android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n    android:paddingRight=\"@dimen/activity_horizontal_margin\"\n    android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n    <Button\n        android:id=\"@+id/button_run_scheduler\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/button_run_scheduler\"/>\n\n</LinearLayout>\n"
  },
  {
    "path": "sample-app/src/main/res/values/dimens.xml",
    "content": "<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n\n    </resources>\n"
  },
  {
    "path": "sample-app/src/main/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">RxJava Android Samples</string>\n    <string name=\"button_run_scheduler\">Run Schedulers Example</string>\n\n</resources>\n"
  },
  {
    "path": "sample-app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n    <style name=\"AppTheme\" parent=\"android:Theme.Holo.Light\">\n        <item name=\"android:textViewStyle\">@style/TextViewStyle</item>\n\n    </style>\n\n    <style name=\"TextViewStyle\" parent=\"android:Widget.TextView\">\n        <item name=\"android:textAppearance\">@android:style/TextAppearance.DeviceDefault.Large</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "sample-app/src/main/res/values-w820dp/dimens.xml",
    "content": "<resources>\n    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n         (such as screen margins) for screens with more than 820dp of available width. This\n         would include 7\" and 10\" devices in landscape (~960dp and ~1280dp respectively). -->\n    <dimen name=\"activity_horizontal_margin\">64dp</dimen>\n</resources>\n"
  },
  {
    "path": "settings.gradle",
    "content": "rootProject.name='rxandroid-root'\n\ninclude ':rxandroid'\ninclude ':sample-app'"
  }
]