[
  {
    "path": ".gitignore",
    "content": "# Built application files\n*.apk\n*.ap_\n\n# Files for the Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Generated files\nbin/\ngen/\n\n# Gradle files\n.gradle/\nbuild/\n/*/build/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Proguard folder generated by Eclipse\nproguard/\n\n# Log Files\n*.log\n\n# IntelliJ\n.idea/\n*.iml\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: android\n\nandroid:\n  components:\n    - tools\n    - platform-tools\n    - build-tools-28.0.3\n    - android-28\n    - extra-android-m2repository\n\njdk: oraclejdk8\n\nnotifications:\n  email: false\n\nsudo: false\n\ncache:\n  directories:\n    - $HOME/.gradle\n\nscript: ./gradlew build test\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "# Changelog\n\n## 4.0.2 (2020-11-05)\n\n- [#332](https://github.com/trello/RxLifecycle/pull/332): Namespace Kotlin module names\n\n## 4.0.1 (2020-10-29)\n\n- [#330](https://github.com/trello/RxLifecycle/pull/330): Corrected package name in rxlifecycle-android-lifecycle-kotlin\n\n## 4.0.0 (2020-05-23)\n\nThis major revision was made to support RxJava 3. RxLifecycle 4.0 lives in a new namespace and\npackage names so that it can work side-by-side with previous versions of RxLifecycle.\n\n- [#317](https://github.com/trello/RxLifecycle/pull/317): Upgrade to RxJava 3\n- [#319](https://github.com/trello/RxLifecycle/pull/319): Updated namespace to com.trello.rxlifecycle4\n\n## 3.1.0 (2019-09-21)\n\n- [#290](https://github.com/trello/RxLifecycle/pull/290): Fixed up some missing rxlifecycle3 conversions\n- [#308](https://github.com/trello/RxLifecycle/pull/308): Support LayoutId constructors for AppCompatActivity and (AndroidX)Fragment\n\n## 3.0.0 (2018-10-25)\n\n- [#285](https://github.com/trello/RxLifecycle/pull/285): Updated base package to com.trello.rxlifecycle3\n- [#284](https://github.com/trello/RxLifecycle/pull/284): Deprecate rxlifecycle-navi\n- [#283](https://github.com/trello/RxLifecycle/pull/283): Upgraded to AndroidX\n\n## 2.2.2 (2018-07-29)\n\n- [#275](https://github.com/trello/RxLifecycle/pull/275): Updated dependencies\n\nNormally simply updating dependencies wouldn't justify a new release, except that there are some R8 issues with\nRxLifecycle (due to it being compiled with Android lifecycle 1.0.0 instead of 1.1.0).\n\n## 2.2.1 (2017-11-15)\n\n- [#248](https://github.com/trello/RxLifecycle/pull/248): Remove generic type declaration for Completable bindings\n\n- [#249](https://github.com/trello/RxLifecycle/pull/249): Updated to release version of Android architecture components\n\n## 2.2.0 (2017-09-06)\n\n- [#239](https://github.com/trello/RxLifecycle/pull/239): Added support for support preference fragments\n\n  These can be found in the new rxlifecycle-components-preference artifact.\n\n## 2.1.0 (2017-05-27)\n\n- [#216](https://github.com/trello/RxLifecycle/pull/216): Added support for Android Architecture Components\n\n  These can be found in the new rxlifecycle-android-lifecycle and rxlifecycle-android-kotlin artifacts.\n\n- [#219](https://github.com/trello/RxLifecycle/pull/219): Fix potential build issues by making JSR305 compileOnly\n\n## 2.0.1 (2016-11-23)\n\n- [#183](https://github.com/trello/RxLifecycle/pull/183): Fix usage of null in navi module\n\n## 2.0 (2016-11-21)\n\nThis major revision was made to support RxJava 2. RxLifecycle 2.0 lives in a new namespace and package\nnames so that it can work side-by-side with RxLifecycle 1.0 (while transitioning).\n\nThe biggest change is that `LifecycleTransformer` now works for *all* RxJava types:\n`Observable`, `Flowable`, `Single`, `Maybe` and `Completable`. Unlike before, there's\nno extra steps you have to take to make it work with types other than `Observable`.\n\n- [#167](https://github.com/trello/RxLifecycle/pull/167): Upgrade to RxJava 2\n- [#169](https://github.com/trello/RxLifecycle/pull/169): Move to com.trello.rxlifecycle2\n- [#170](https://github.com/trello/RxLifecycle/pull/170): Added Maybe support\n- [#172](https://github.com/trello/RxLifecycle/pull/172): Added Flowable support\n\n## 1.0 (2016-11-03)\n\nFirst and (hopefully) final release of 1.x branch!\n\nThis release marks the start of maintenance mode for RxJava 1 support. Future work will be devoted to supporting\nRxJava 2. Important bugs may be squashed but new features will have to be extraordinarily compelling in order\nto be added.\n\n- [#162](https://github.com/trello/RxLifecycle/pull/162): Made all components abstract\n- [#157](https://github.com/trello/RxLifecycle/pull/157): Added RxPreferenceFragment\n\n## 0.8.0 (2016-09-19)\n\n- [#152](https://github.com/trello/RxLifecycle/pull/152): Support RxJava 1.2.0.\n\n  This change is not backwards compatible with RxJava 1.1.x, so if you want to continue\n  receiving updates for RxLifecycle you will eventually need to upgrade to RxJava 1.2.x.\n\n## 0.7.0 (2016-08-24)\n\nThere are a couple major breaking changes in this release, so read carefully.\n\n- [#143](https://github.com/trello/RxLifecycle/pull/143): Split Android parts of rxlifecycle into rxlifecycle-android\n\n  Now the `rxlifecycle` dependency is a pure Java core. To use RxLifecycle with Android, you should also include\n  `rxlifecycle-android` as well now.\n\n  `RxLifecycle` methods that are for Android (`bindActivity()`, `bindFragment()` and `bindView()`) are now in\n  `RxLifecycleAndroid` (found in the `rxlifecycle-android` artifact).\n\n   Deprecated methods in `RxLifecycle` were removed as well.\n\n- [#138](https://github.com/trello/RxLifecycle/pull/138) / [#139](https://github.com/trello/RxLifecycle/pull/139):\nReplace `ActivityLifecycleProvider` and `FragmentLifecycleProvider` with `LifecycleProvider<T>`.\n\n  This means that you need to replace `ActivityLifecycleProvider` with `LifecycleProvider<ActivityEvent>` and\n  `FragmentLifecycleProvider` with `LifecycleProvider<FragmentEvent>`.\n\nOther changes:\n\n- [#140](https://github.com/trello/RxLifecycle/pull/140): Fixed type inference for LifecycleTransformer.forSingle()\n- [#135](https://github.com/trello/RxLifecycle/pull/135): Add Kotlin extensions for Singles and Completables\n\n## 0.6.1 (2016-05-11)\n\n- [#118](https://github.com/trello/RxLifecycle/pull/118): Use `LifecycleTransformer` in the provider interfaces\n\n## 0.6.0 (2016-05-06)\n\n- Added `LifecycleTransformer`, which provides `Single` and `Completable` support.\n- [#111](https://github.com/trello/RxLifecycle/pull/111): Added component support for `AppCompatDialogFragment`\n- [#107](https://github.com/trello/RxLifecycle/pull/107): Fixed navi component package\n\n## 0.5.0 (2016-02-27)\n\nThere are a few methods which have been **deprecated** and will be removed in a future release. Each one has a drop-in\nreplacement (and currently calling the deprecated version just routes to the new one):\n\n* `bindUntilActivityEvent()` and `bindUntilFragmentEvent()` -> `bindUntilEvent()`\n* `bindView()` -> `bind()`\n\nThe other changes mostly involve opening up the API for more customization:\n\n* [#78](https://github.com/trello/RxLifecycle/pull/78): Added rxlifecycle-kotlin (adds some extensions)\n* [#79](https://github.com/trello/RxLifecycle/pull/79): Made bindUntilEvent() public, deprecated more specific calls\n* [#82](https://github.com/trello/RxLifecycle/pull/82): Opened up bind() methods for public consumption\n* [#83](https://github.com/trello/RxLifecycle/pull/83), [#85](https://github.com/trello/RxLifecycle/pull/85): Added\nannotations for better lint checking\n* [#88](https://github.com/trello/RxLifecycle/pull/88): Use `.equals()` instead of == for event comparison (for\ncustom event support with the newly opened-up `bind()`)\n* [#89](https://github.com/trello/RxLifecycle/pull/89): Make OutsideLifecycleException public (for anyone who wants\nto write their own `bind()` implementations)\n\n## 0.4.0 (2015-12-10)\n\n* [#62](https://github.com/trello/RxLifecycle/pull/62), [#67](https://github.com/trello/RxLifecycle/pull/67): Added\n[Navi](https://github.com/trello/navi/)-based implementation of providers.\n* [#61](https://github.com/trello/RxLifecycle/pull/61): Moved `ActivityLifecycleProvider` and\n`FragmentLifecycleProvider` into the core library so that multiple implementations can share them easily. The package\n name changed so you may need to re-import them in your code.\n* [#60](https://github.com/trello/RxLifecycle/pull/60): Reverted generic parameters back to `Transformer<T, T>`\n\n## 0.3.1 (2015-11-27)\n\n* [#46](https://github.com/trello/RxLifecycle/pull/46): Updated generic parameters of `Transformer<T, T>` to support Kotlin type inference.\n\n## 0.3.0\n\n* [#12](https://github.com/trello/RxLifecycle/pull/12): Added `RxLifecycle.bindView()`. This allows binding a\n`Subscription` until a `View` detaches itself from the window.\n* [#30](https://github.com/trello/RxLifecycle/pull/30): Calling `bindActivity()` or `bindFragment()` outside of the\nlifecycle causes the sequence to immediately complete (instead of throwing an error).\n* [#31](https://github.com/trello/RxLifecycle/pull/31): Passing nulls to RxLifecycle now always immediately throws an\nexception.\n\n## 0.2.0\n\n* [#14](https://github.com/trello/RxLifecycle/pull/14): Use takeUntil internally (instead of a faulty custom operator)\n\n    While this fixes some intractable problems that could occur with the old system, it also includes a major behavior\n    change: when the bind decides to stop subscribing, it calls `onCompleted` (whereas before it would just\n    unsubscribe).\n\n    When upgrading, you should check that your usages of `onCompleted` (either in `subscribe()`, `doOnCompleted()`,\n    or `doOnTerminate()`) can handle the sequence ending due to the lifecycle bind.\n\n    If you still need the old behavior in some spots, you should handle the `Subscription` yourself manually (and call\n    `unsubscribe()` when appropriate).\n\n* [#16](https://github.com/trello/RxLifecycle/pull/16): Lowered minSdkVersion to 14\n\n## 0.1.0\n\nInitial independent release (split from RxAndroid 0.25.0)\n\n* Added support for AppCompatActivity via `RxAppCompatActivity`\n* Components (e.g. `RxActivity`) now support `bindUntilEvent()` and `bindToLifecycle()`, which avoids having to deal with the lifecycle `Observable` directly.\n\n### Differences from RxAndroid 0.25\n\n* Renamed `LifecycleObservable` to `RxLifecycle`\n* Switched from wrapping `Observables` to using `Transformer` + `compose()` (which allows for chaining)\n* Split `LifecycleEvent` into two parts - `ActivityEvent` and `FragmentEvent`, in order to prevent easy mixups that could occur before\n* Split `bindUntilLifecycleEvent()` into `bindUntilFragmentEvent()` and `bindUntilActivityEvent()`\n* Renamed `bindFragmentLifecycle()` to `bindFragment()`\n* Renamed `bindActivityLifecycle()` to `bindActivity()`"
  },
  {
    "path": "LICENSE",
    "content": "                                 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   Copyright {yyyy} {name of copyright owner}\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"
  },
  {
    "path": "README.md",
    "content": "# RxLifecycle\n\nThis library allows one to automatically complete sequences based on a second lifecycle stream.\n\nThis capability is useful in Android, where incomplete subscriptions can cause memory leaks.\n\n## Usage\n\nYou must start with an `Observable<T>` representing a lifecycle stream. Then you use `RxLifecycle` to bind\na sequence to that lifecycle.\n\nYou can bind when the lifecycle emits anything:\n\n```java\nmyObservable\n    .compose(RxLifecycle.bind(lifecycle))\n    .subscribe();\n```\n\nOr you can bind to when a specific lifecyle event occurs:\n\n```java\nmyObservable\n    .compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.DESTROY))\n    .subscribe();\n```\n\nAlternatively, you can let RxLifecycle determine the appropriate time to end the sequence:\n\n```java\nmyObservable\n    .compose(RxLifecycleAndroid.bindActivity(lifecycle))\n    .subscribe();\n```\n\nIt assumes you want to end the sequence in the opposing lifecycle event - e.g., if subscribing during `START`, it will\nterminate on `STOP`. If you subscribe after `PAUSE`, it will terminate at the next destruction event (e.g.,\n`PAUSE` will terminate in `STOP`).\n\n## Providers\n\nWhere do lifecycles come from? Generally, they are provided by an appropriate `LifecycleProvider<T>`. But where are\nthose implemented?\n\nYou have a few options for that:\n\n1. Use rxlifecycle-components and subclass the provided `RxActivity`, `RxFragment`, etc. classes.\n1. Use [Android's lifecycle](https://developer.android.com/topic/libraries/architecture/lifecycle.html) + rxlifecycle-android-lifecycle to generate providers.\n1. Write the implementation yourself.\n\nIf you use rxlifecycle-components, just extend the appropriate class, then use the built-in `bindToLifecycle()` (or `bindUntilEvent()`) methods:\n\n```java\npublic class MyActivity extends RxActivity {\n    @Override\n    public void onResume() {\n        super.onResume();\n        myObservable\n            .compose(bindToLifecycle())\n            .subscribe();\n    }\n}\n```\n\nIf you use rxlifecycle-android-lifecycle, then you just pass your `LifecycleOwner` to `AndroidLifecycle` to generate a provider:\n\n```java\npublic class MyActivity extends LifecycleActivity {\n    private final LifecycleProvider<Lifecycle.Event> provider\n        = AndroidLifecycle.createLifecycleProvider(this);\n\n    @Override\n    public void onResume() {\n        super.onResume();\n        myObservable\n            .compose(provider.bindToLifecycle())\n            .subscribe();\n    }\n}\n```\n\n## Unsubscription\n\nRxLifecycle does not actually unsubscribe the sequence. Instead it terminates the sequence. The way in which\nit does so varies based on the type:\n\n- `Observable`, `Flowable` and `Maybe` - emits `onCompleted()`\n- `Single` and `Completable` - emits `onError(CancellationException)`\n\nIf a sequence requires the `Subscription.unsubscribe()` behavior, then it is suggested that you manually handle\nthe `Subscription` yourself and call `unsubscribe()` when appropriate.\n\n## Kotlin\n\nThe rxlifecycle-kotlin module provides built-in extensions to the base RxJava types:\n\n```kotlin\nmyObservable\n    .bindToLifecycle(myView)\n    .subscribe { }\n\nmyObservable\n    .bindUntilEvent(myRxActivity, STOP)\n    .subscribe { }\n```\n\nThere is an additional rxlifecycle-android-lifecycle-kotlin module to provider extensions to work\nwith `LifecycleOwner`'s.\n\n```kotlin\n\nmyObservable\n    .bindUntilEvent(myLifecycleActivity, ON_STOP)\n    .subscribe { }\n```\n\n## Installation\n\n```gradle\nimplementation 'com.trello.rxlifecycle4:rxlifecycle:4.0.2'\n\n// If you want to bind to Android-specific lifecycles\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-android:4.0.2'\n\n// If you want pre-written Activities and Fragments you can subclass as providers\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-components:4.0.2'\n\n// If you want pre-written support preference Fragments you can subclass as providers\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-components-preference:4.0.2'\n\n// If you want to use Android Lifecycle for providers\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle:4.0.2'\n\n// If you want to use Kotlin syntax\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-kotlin:4.0.2'\n\n// If you want to use Kotlin syntax with Android Lifecycle\nimplementation 'com.trello.rxlifecycle4:rxlifecycle-android-lifecycle-kotlin:4.0.2'\n```\n\n## License\n\n    Copyright (C) 2016 Trello\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": "build.gradle",
    "content": "buildscript {\n    ext {\n        //version here to share between build script and projects\n        verKotlin = '1.3.72'\n    }\n    repositories {\n        google()\n        jcenter()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:3.6.3'\n        classpath \"org.jetbrains.kotlin:kotlin-gradle-plugin:$verKotlin\"\n        classpath \"org.jetbrains.kotlin:kotlin-android-extensions:$verKotlin\"\n        classpath 'com.github.ben-manes:gradle-versions-plugin:0.28.0'\n        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'\n    }\n}\n\nsubprojects {\n    group = GROUP\n    version = VERSION_NAME\n}\n\napply plugin: 'com.github.ben-manes.versions'\n\next {\n    minSdkVersion = 14\n    compileSdkVersion = 28\n    targetSdkVersion = compileSdkVersion\n\n    sourceCompatibilityVersion = JavaVersion.VERSION_1_7\n    targetCompatibilityVersion = JavaVersion.VERSION_1_7\n\n    // Define all dependencies in the base project, to unify & make it easy to update\n    rxJava = 'io.reactivex.rxjava3:rxjava:3.0.4'\n    rxAndroid = 'io.reactivex.rxjava3:rxandroid:3.0.0'\n    navi = 'com.trello.navi2:navi:2.1.0'\n    lifecycle = 'androidx.lifecycle:lifecycle-runtime:2.2.0'\n    lifecycleProcessor = 'androidx.lifecycle:lifecycle-compiler:2.2.0'\n    lifecycleExtensions = 'androidx.lifecycle:lifecycle-extensions:2.2.0'\n    kotlinStdlib = \"org.jetbrains.kotlin:kotlin-stdlib:$verKotlin\"\n    appCompat = 'androidx.appcompat:appcompat:1.1.0'\n    preferenceCompat = 'androidx.preference:preference:1.1.1'\n    supportAnnotations = 'androidx.annotation:annotation:1.1.0'\n    jsr305Annotations = 'com.google.code.findbugs:jsr305:3.0.2'\n    junit = 'junit:junit:4.13'\n    robolectric = 'org.robolectric:robolectric:3.8'\n}\n"
  },
  {
    "path": "gradle/artifacts.gradle",
    "content": "if (project.plugins.hasPlugin('com.android.library')) {\n    android.libraryVariants.all { variant ->\n        Task javadocTask = task(\"generate${variant.name.capitalize()}Javadoc\", type: Javadoc) {\n            group = 'artifact'\n            description \"Generates Javadoc for $variant.name\"\n\n            // Source files from the variant\n            source = variant.javaCompiler.source\n\n            // Classpath from the variant + android.jar\n            String androidJar = \"${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar\"\n            classpath = variant.javaCompiler.classpath + files(androidJar)\n\n            // The Android online reference doesn't include package-list, so we have to use the local one\n            String packageListRef = \"${android.sdkDirectory}/docs/reference/\"\n            options.linksOffline 'http://d.android.com/reference/', packageListRef\n\n            // Additional links for any RxJava references\n            options.links 'http://reactivex.io/RxJava/javadoc/'\n\n            // Exclude generated files\n            exclude '**/BuildConfig.java'\n            exclude '**/R.java'\n\n            // Output to a unique javadoc folder per variant\n            destinationDir = new File(project.docsDir, \"javadoc-$variant.name\")\n        }\n\n        // For official releasese, don't prefix the name so the artifact is published correctly\n        // (Can't seem to modify it for publishing, for whatever reason...)\n        String classifierPrefix = (variant.name == 'release') ? '' : \"$variant.name-\"\n\n        Task javadocJarTask = task(\"generate${variant.name.capitalize()}JavadocJar\", type: Jar, dependsOn: javadocTask) {\n            group = 'artifact'\n            description = \"Generates Javadoc jar for $variant.name\"\n\n            classifier = \"${classifierPrefix}javadoc\"\n            from javadocTask.destinationDir\n        }\n\n        Task sourcesJarTask = task(\"generate${variant.name.capitalize()}SourcesJar\", type: Jar) {\n            group = 'artifact'\n            description = \"Generates sources jar for $variant.name\"\n\n            classifier = \"${classifierPrefix}sources\"\n            from variant.javaCompiler.source\n        }\n\n        if (variant.name == 'release') {\n            // There's a lot of \"magic\" around the archives configuration; easier \n            // just to embrace it rather than try to configure around it\n            artifacts {\n                archives javadocJarTask, sourcesJarTask\n            }\n        }\n        else {\n            // Create a configuration we can publish from for each variant\n            String configurationName = \"archives${variant.name.capitalize()}\"\n            configurations.create(configurationName)\n            artifacts.add configurationName, javadocJarTask\n            artifacts.add configurationName, sourcesJarTask\n        }\n    }\n}"
  },
  {
    "path": "gradle/gradle-mvn-push.gradle",
    "content": "/*\n * Copyright 2013 Chris Banes\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\napply plugin: 'maven'\napply plugin: 'signing'\n\ndef isReleaseBuild() {\n    return VERSION_NAME.contains(\"SNAPSHOT\") == false\n}\n\ndef getRepositoryUsername() {\n    return hasProperty('SONATYPE_NEXUS_USERNAME') ? SONATYPE_NEXUS_USERNAME : \"\"\n}\n\ndef getRepositoryPassword() {\n    return hasProperty('SONATYPE_NEXUS_PASSWORD') ? SONATYPE_NEXUS_PASSWORD : \"\"\n}\n\nafterEvaluate { project ->\n    uploadArchives {\n        repositories {\n            mavenDeployer {\n                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }\n\n                pom.groupId = GROUP\n                pom.artifactId = POM_ARTIFACT_ID\n                pom.version = VERSION_NAME\n\n                repository(url: \"https://oss.sonatype.org/service/local/staging/deploy/maven2/\") {\n                    authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())\n                }\n                snapshotRepository(url: \"https://oss.sonatype.org/content/repositories/snapshots/\") {\n                    authentication(userName: getRepositoryUsername(), password: getRepositoryPassword())\n                }\n\n                pom.project {\n                    name POM_NAME\n                    packaging POM_PACKAGING\n                    description POM_DESCRIPTION\n                    url POM_URL\n\n                    scm {\n                        url POM_SCM_URL\n                        connection POM_SCM_CONNECTION\n                        developerConnection POM_SCM_DEV_CONNECTION\n                    }\n\n                    licenses {\n                        license {\n                            name POM_LICENCE_NAME\n                            url POM_LICENCE_URL\n                            distribution POM_LICENCE_DIST\n                        }\n                    }\n\n                    developers {\n                        developer {\n                            id POM_DEVELOPER_ID\n                            name POM_DEVELOPER_NAME\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    signing {\n        required { isReleaseBuild() && gradle.taskGraph.hasTask(\"uploadArchives\") }\n        sign configurations.archives\n    }\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-6.4.1-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "gradle.properties",
    "content": "GROUP=com.trello.rxlifecycle4\nVERSION_NAME=4.0.2-SNAPSHOT\n\nPOM_URL=https://github.com/trello/RxLifecycle\nPOM_SCM_URL=https://github.com/trello/RxLifecycle\nPOM_SCM_CONNECTION=scm:git:https://github.com/trello/RxLifecycle.git\nPOM_SCM_DEV_CONNECTION=scm:git:git@github.com:trello/RxLifecycle.git\n\nPOM_LICENCE_NAME=The Apache Software License, Version 2.0\nPOM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt\nPOM_LICENCE_DIST=repo\n\nPOM_DEVELOPER_ID=dlew\nPOM_DEVELOPER_NAME=Dan Lew\n\nandroid.useAndroidX=true"
  },
  {
    "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 init\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 init\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:init\r\n@rem Get command-line arguments, handling Windows variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\n\r\n:win9xME_args\r\n@rem Slurp the command line arguments.\r\nset CMD_LINE_ARGS=\r\nset _SKIP=2\r\n\r\n:win9xME_args_slurp\r\nif \"x%~1\" == \"x\" goto execute\r\n\r\nset CMD_LINE_ARGS=%*\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 %CMD_LINE_ARGS%\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": "rxlifecycle/build.gradle",
    "content": "apply plugin: 'java'\n\nsourceCompatibility = rootProject.ext.sourceCompatibilityVersion\ntargetCompatibility = rootProject.ext.targetCompatibilityVersion\n\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    compile rootProject.ext.rxJava\n    compileOnly rootProject.ext.jsr305Annotations\n\n    testImplementation rootProject.ext.junit\n}\n\n// Add sources/javadoc artifacts\ntask sourcesJar(type: Jar, dependsOn:classes) {\n    classifier = 'sources'\n    from sourceSets.main.allSource\n}\n\ntask javadocJar(type: Jar, dependsOn:javadoc) {\n    classifier = 'javadoc'\n    from javadoc.destinationDir\n}\n\nartifacts {\n    archives sourcesJar\n    archives javadocJar\n}\n\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\"\n"
  },
  {
    "path": "rxlifecycle/gradle.properties",
    "content": "POM_NAME=RxLifecycle\nPOM_DESCRIPTION=RxLifecycle\nPOM_ARTIFACT_ID=rxlifecycle\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle/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  http://www.apache.org/licenses/LICENSE-2.0\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=\"com.trello.rxlifecycle4\" />"
  },
  {
    "path": "rxlifecycle/src/main/java/com/trello/rxlifecycle4/Functions.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport java.util.concurrent.CancellationException;\n\nimport io.reactivex.rxjava3.core.Completable;\nimport io.reactivex.rxjava3.exceptions.Exceptions;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.functions.Predicate;\n\nfinal class Functions {\n\n    static final Function<Throwable, Boolean> RESUME_FUNCTION = new Function<Throwable, Boolean>() {\n        @Override\n        public Boolean apply(Throwable throwable) throws Exception {\n            if (throwable instanceof OutsideLifecycleException) {\n                return true;\n            }\n\n            //noinspection ThrowableResultOfMethodCallIgnored\n            Exceptions.propagate(throwable);\n            return false;\n        }\n    };\n\n    static final Predicate<Boolean> SHOULD_COMPLETE = new Predicate<Boolean>() {\n        @Override\n        public boolean test(Boolean shouldComplete) throws Exception {\n            return shouldComplete;\n        }\n    };\n\n    static final Function<Object, Completable> CANCEL_COMPLETABLE = new Function<Object, Completable>() {\n        @Override\n        public Completable apply(Object ignore) throws Exception {\n            return Completable.error(new CancellationException());\n        }\n    };\n\n    private Functions() {\n        throw new AssertionError(\"No instances!\");\n    }\n}\n"
  },
  {
    "path": "rxlifecycle/src/main/java/com/trello/rxlifecycle4/LifecycleProvider.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport javax.annotation.CheckReturnValue;\nimport javax.annotation.Nonnull;\n\nimport io.reactivex.rxjava3.core.Observable;\n\n/**\n * Common base interface for activity and fragment lifecycle providers.\n *\n * Useful if you are writing utilities on top of rxlifecycle-components\n * or implementing your own component not supported by this library.\n */\npublic interface LifecycleProvider<E> {\n    /**\n     * @return a sequence of lifecycle events\n     */\n    @Nonnull\n    @CheckReturnValue\n    Observable<E> lifecycle();\n\n    /**\n     * Binds a source until a specific event occurs.\n     *\n     * @param event the event that triggers unsubscription\n     * @return a reusable {@link LifecycleTransformer} which unsubscribes when the event triggers.\n     */\n    @Nonnull\n    @CheckReturnValue\n    <T> LifecycleTransformer<T> bindUntilEvent(@Nonnull E event);\n\n    /**\n     * Binds a source until the next reasonable event occurs.\n     *\n     * @return a reusable {@link LifecycleTransformer} which unsubscribes at the correct time.\n     */\n    @Nonnull\n    @CheckReturnValue\n    <T> LifecycleTransformer<T> bindToLifecycle();\n}\n"
  },
  {
    "path": "rxlifecycle/src/main/java/com/trello/rxlifecycle4/LifecycleTransformer.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.reactivestreams.Publisher;\n\nimport javax.annotation.ParametersAreNonnullByDefault;\n\nimport io.reactivex.rxjava3.core.BackpressureStrategy;\nimport io.reactivex.rxjava3.core.Completable;\nimport io.reactivex.rxjava3.core.CompletableSource;\nimport io.reactivex.rxjava3.core.CompletableTransformer;\nimport io.reactivex.rxjava3.core.Flowable;\nimport io.reactivex.rxjava3.core.FlowableTransformer;\nimport io.reactivex.rxjava3.core.Maybe;\nimport io.reactivex.rxjava3.core.MaybeSource;\nimport io.reactivex.rxjava3.core.MaybeTransformer;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.core.ObservableSource;\nimport io.reactivex.rxjava3.core.ObservableTransformer;\nimport io.reactivex.rxjava3.core.Single;\nimport io.reactivex.rxjava3.core.SingleSource;\nimport io.reactivex.rxjava3.core.SingleTransformer;\n\nimport static com.trello.rxlifecycle4.internal.Preconditions.checkNotNull;\n\n/**\n * Transformer that continues a subscription until a second Observable emits an event.\n */\n@ParametersAreNonnullByDefault\npublic final class LifecycleTransformer<T> implements ObservableTransformer<T, T>,\n                                                      FlowableTransformer<T, T>,\n                                                      SingleTransformer<T, T>,\n                                                      MaybeTransformer<T, T>,\n                                                      CompletableTransformer\n{\n    final Observable<?> observable;\n\n    LifecycleTransformer(Observable<?> observable) {\n        checkNotNull(observable, \"observable == null\");\n        this.observable = observable;\n    }\n\n    @Override\n    public ObservableSource<T> apply(Observable<T> upstream) {\n        return upstream.takeUntil(observable);\n    }\n\n    @Override\n    public Publisher<T> apply(Flowable<T> upstream) {\n        return upstream.takeUntil(observable.toFlowable(BackpressureStrategy.LATEST));\n    }\n\n    @Override\n    public SingleSource<T> apply(Single<T> upstream) {\n        return upstream.takeUntil(observable.firstOrError());\n    }\n\n    @Override\n    public MaybeSource<T> apply(Maybe<T> upstream) {\n        return upstream.takeUntil(observable.firstElement());\n    }\n\n    @Override\n    public CompletableSource apply(Completable upstream) {\n        return Completable.ambArray(upstream, observable.flatMapCompletable(Functions.CANCEL_COMPLETABLE));\n    }\n\n    @Override\n    public boolean equals(Object o) {\n        if (this == o) { return true; }\n        if (o == null || getClass() != o.getClass()) { return false; }\n\n        LifecycleTransformer<?> that = (LifecycleTransformer<?>) o;\n\n        return observable.equals(that.observable);\n    }\n\n    @Override\n    public int hashCode() {\n        return observable.hashCode();\n    }\n\n    @Override\n    public String toString() {\n        return \"LifecycleTransformer{\" +\n            \"observable=\" + observable +\n            '}';\n    }\n}\n"
  },
  {
    "path": "rxlifecycle/src/main/java/com/trello/rxlifecycle4/OutsideLifecycleException.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport javax.annotation.Nullable;\n\n/**\n * This is an exception that can be thrown to indicate that the caller has attempted to bind to a lifecycle outside\n * of its allowable window.\n */\npublic class OutsideLifecycleException extends IllegalStateException {\n\n    public OutsideLifecycleException(@Nullable String detailMessage) {\n        super(detailMessage);\n    }\n}\n"
  },
  {
    "path": "rxlifecycle/src/main/java/com/trello/rxlifecycle4/RxLifecycle.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport javax.annotation.CheckReturnValue;\nimport javax.annotation.Nonnull;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.functions.BiFunction;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.functions.Predicate;\n\nimport static com.trello.rxlifecycle4.internal.Preconditions.checkNotNull;\n\npublic class RxLifecycle {\n\n    private RxLifecycle() {\n        throw new AssertionError(\"No instances\");\n    }\n\n    /**\n     * Binds the given source to a lifecycle.\n     * <p>\n     * When the lifecycle event occurs, the source will cease to emit any notifications.\n     *\n     * @param lifecycle the lifecycle sequence\n     * @param event the event which should conclude notifications from the source\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source at the specified event\n     */\n    @Nonnull\n    @CheckReturnValue\n    public static <T, R> LifecycleTransformer<T> bindUntilEvent(@Nonnull final Observable<R> lifecycle,\n                                                                @Nonnull final R event) {\n        checkNotNull(lifecycle, \"lifecycle == null\");\n        checkNotNull(event, \"event == null\");\n        return bind(takeUntilEvent(lifecycle, event));\n    }\n\n    private static <R> Observable<R> takeUntilEvent(final Observable<R> lifecycle, final R event) {\n        return lifecycle.filter(new Predicate<R>() {\n            @Override\n            public boolean test(R lifecycleEvent) throws Exception {\n                return lifecycleEvent.equals(event);\n            }\n        });\n    }\n\n    /**\n     * Binds the given source to a lifecycle.\n     * <p>\n     * This helper automatically determines (based on the lifecycle sequence itself) when the source\n     * should stop emitting items. Note that for this method, it assumes <em>any</em> event\n     * emitted by the given lifecycle indicates that the lifecycle is over.\n     *\n     * @param lifecycle the lifecycle sequence\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source whenever the lifecycle emits\n     */\n    @Nonnull\n    @CheckReturnValue\n    public static <T, R> LifecycleTransformer<T> bind(@Nonnull final Observable<R> lifecycle) {\n        return new LifecycleTransformer<>(lifecycle);\n    }\n\n    /**\n     * Binds the given source to a lifecycle.\n     * <p>\n     * This method determines (based on the lifecycle sequence itself) when the source\n     * should stop emitting items. It uses the provided correspondingEvents function to determine\n     * when to unsubscribe.\n     * <p>\n     * Note that this is an advanced usage of the library and should generally be used only if you\n     * really know what you're doing with a given lifecycle.\n     *\n     * @param lifecycle the lifecycle sequence\n     * @param correspondingEvents a function which tells the source when to unsubscribe\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source during the Fragment lifecycle\n     */\n    @Nonnull\n    @CheckReturnValue\n    public static <T, R> LifecycleTransformer<T> bind(@Nonnull Observable<R> lifecycle,\n                                                      @Nonnull final Function<R, R> correspondingEvents) {\n        checkNotNull(lifecycle, \"lifecycle == null\");\n        checkNotNull(correspondingEvents, \"correspondingEvents == null\");\n        return bind(takeUntilCorrespondingEvent(lifecycle.share(), correspondingEvents));\n    }\n\n    private static <R> Observable<Boolean> takeUntilCorrespondingEvent(final Observable<R> lifecycle,\n                                                                       final Function<R, R> correspondingEvents) {\n        return Observable.combineLatest(\n            lifecycle.take(1).map(correspondingEvents),\n            lifecycle.skip(1),\n            new BiFunction<R, R, Boolean>() {\n                @Override\n                public Boolean apply(R bindUntilEvent, R lifecycleEvent) throws Exception {\n                    return lifecycleEvent.equals(bindUntilEvent);\n                }\n            })\n            .onErrorReturn(Functions.RESUME_FUNCTION)\n            .filter(Functions.SHOULD_COMPLETE);\n    }\n}\n"
  },
  {
    "path": "rxlifecycle/src/main/java/com/trello/rxlifecycle4/internal/Preconditions.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 */\n\npackage com.trello.rxlifecycle4.internal;\n\npublic final class Preconditions {\n    public static <T> T checkNotNull(T value, String message) {\n        if (value == null) {\n            throw new NullPointerException(message);\n        }\n        return value;\n    }\n\n    private Preconditions() {\n        throw new AssertionError(\"No instances.\");\n    }\n}\n"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/OutsideLifecycleExceptionTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.exceptions.CompositeException;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.functions.Predicate;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class OutsideLifecycleExceptionTest {\n\n    @Test\n    public void eventOutOfLifecycle() {\n        PublishSubject<String> stream = PublishSubject.create();\n        PublishSubject<String> lifecycle = PublishSubject.create();\n\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        // Event is out of lifecycle, but this just results in completing the stream\n        lifecycle.onNext(\"destroy\");\n        stream.onNext(\"1\");\n\n        testObserver.assertNoValues();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void eventThrowsBadException() {\n        PublishSubject<String> stream = PublishSubject.create();\n        PublishSubject<String> lifecycle = PublishSubject.create();\n\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        // We get an error from the function for this lifecycle event\n        lifecycle.onNext(\"ick\");\n        stream.onNext(\"1\");\n\n        testObserver.assertNoValues();\n\n        // We only want to check for our IllegalArgumentException, but may have\n        // to wade through a CompositeException to get at it.\n        testObserver.assertError(new Predicate<Throwable>() {\n            @Override\n            public boolean test(Throwable throwable) throws Exception {\n                if (throwable instanceof CompositeException) {\n                    CompositeException ce = (CompositeException) throwable;\n                    for (Throwable t : ce.getExceptions()) {\n                        if (t instanceof IllegalArgumentException) {\n                            return true;\n                        }\n                    }\n                }\n\n                return false;\n            }\n        });\n    }\n\n    private static final Function<String, String> CORRESPONDING_EVENTS = new Function<String, String>() {\n        @Override\n        public String apply(String s) throws Exception {\n            if (s.equals(\"destroy\")) {\n                throw new OutsideLifecycleException(\"\");\n            }\n\n            throw new IllegalArgumentException(\"Cannot handle: \" + s);\n        }\n    };\n}\n"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/RxLifecycleTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class RxLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        // Simulate an actual lifecycle (hot Observable that does not end)\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testBindLifecycle() {\n        BehaviorSubject<Object> lifecycle = BehaviorSubject.create();\n        TestObserver<Object> testObserver = observable.compose(RxLifecycle.bind(lifecycle)).test();\n        testObserver.assertNotComplete();\n        lifecycle.onNext(new Object());\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void testBindLifecycleOtherObject() {\n        // Ensures it works with other types as well, and not just \"Object\"\n        BehaviorSubject<String> lifecycle = BehaviorSubject.create();\n        TestObserver<Object> testObserver = observable.compose(RxLifecycle.bind(lifecycle)).test();\n        testObserver.assertNotComplete();\n        lifecycle.onNext(\"\");\n        testObserver.assertComplete();\n    }\n\n    // Null checks\n\n    @Test(expected=NullPointerException.class)\n    public void testBindThrowsOnNullLifecycle() {\n        //noinspection ResourceType\n        RxLifecycle.bind((Observable) null);\n    }\n\n    @Test(expected = NullPointerException.class)\n    public void testBindUntilThrowsOnNullLifecycle() {\n        //noinspection ResourceType\n        RxLifecycle.bindUntilEvent(null, new Object());\n    }\n\n    @Test(expected = NullPointerException.class)\n    public void testBindUntilThrowsOnNullEvent() {\n        BehaviorSubject<Object> lifecycle = BehaviorSubject.create();\n        //noinspection ResourceType\n        RxLifecycle.bindUntilEvent(lifecycle, null);\n    }\n}\n"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilCorrespondingEventTransformerCompletableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.concurrent.CancellationException;\n\nimport io.reactivex.rxjava3.core.Completable;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilCorrespondingEventTransformerCompletableTest {\n\n    PublishSubject<Object> subject;\n    Completable completable;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        subject =  PublishSubject.create();\n        completable = Completable.fromObservable(subject);\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        subject.onComplete();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneStartEvent() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        subject.onComplete();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void twoOpenEvents() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        lifecycle.onNext(\"start\");\n        subject.onComplete();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void openAndCloseEvent() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        lifecycle.onNext(\"destroy\");\n        subject.onComplete();\n        testObserver.assertError(CancellationException.class);\n    }\n\n    private static final Function<String, String> CORRESPONDING_EVENTS = new Function<String, String>() {\n        @Override\n        public String apply(String s) throws Exception {\n            if (s.equals(\"create\")) {\n                return \"destroy\";\n            }\n\n            throw new IllegalArgumentException(\"Cannot handle: \" + s);\n        }\n    };\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilCorrespondingEventTransformerFlowableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.processors.PublishProcessor;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\nimport io.reactivex.rxjava3.subscribers.TestSubscriber;\n\npublic class UntilCorrespondingEventTransformerFlowableTest {\n\n    PublishProcessor<String> stream;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishProcessor.create();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertNotComplete();\n    }\n\n    @Test\n    public void oneStartEvent() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertNotComplete();\n    }\n\n    @Test\n    public void twoOpenEvents() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"start\");\n        stream.onNext(\"2\");\n\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertNotComplete();\n    }\n\n    @Test\n    public void openAndCloseEvent() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"destroy\");\n        stream.onNext(\"2\");\n\n        testSubscriber.assertValues(\"1\");\n        testSubscriber.assertComplete();\n    }\n\n    private static final Function<String, String> CORRESPONDING_EVENTS = new Function<String, String>() {\n        @Override\n        public String apply(String s) throws Exception {\n            if (s.equals(\"create\")) {\n                return \"destroy\";\n            }\n\n            throw new IllegalArgumentException(\"Cannot handle: \" + s);\n        }\n    };\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilCorrespondingEventTransformerMaybeTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.core.Maybe;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilCorrespondingEventTransformerMaybeTest {\n\n    PublishSubject<String> subject;\n    Maybe<String> maybe;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        subject =  PublishSubject.create();\n        maybe = subject.firstElement();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        subject.onNext(\"1\");\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneStartEvent() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        subject.onNext(\"1\");\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void twoOpenEvents() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        lifecycle.onNext(\"start\");\n        subject.onNext(\"1\");\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void openAndCloseEvent() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        lifecycle.onNext(\"destroy\");\n        subject.onNext(\"1\");\n        testObserver.assertNoValues();\n        testObserver.assertComplete();\n    }\n\n    private static final Function<String, String> CORRESPONDING_EVENTS = new Function<String, String>() {\n        @Override\n        public String apply(String s) throws Exception {\n            if (s.equals(\"create\")) {\n                return \"destroy\";\n            }\n\n            throw new IllegalArgumentException(\"Cannot handle: \" + s);\n        }\n    };\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilCorrespondingEventTransformerObservableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilCorrespondingEventTransformerObservableTest {\n\n    PublishSubject<String> stream;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishSubject.create();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertNotComplete();\n    }\n\n    @Test\n    public void oneStartEvent() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertNotComplete();\n    }\n\n    @Test\n    public void twoOpenEvents() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"start\");\n        stream.onNext(\"2\");\n\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertNotComplete();\n    }\n\n    @Test\n    public void openAndCloseEvent() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"destroy\");\n        stream.onNext(\"2\");\n\n        testObserver.assertValues(\"1\");\n        testObserver.assertComplete();\n    }\n\n    private static final Function<String, String> CORRESPONDING_EVENTS = new Function<String, String>() {\n        @Override\n        public String apply(String s) throws Exception {\n            if (s.equals(\"create\")) {\n                return \"destroy\";\n            }\n\n            throw new IllegalArgumentException(\"Cannot handle: \" + s);\n        }\n    };\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilCorrespondingEventTransformerSingleTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.concurrent.CancellationException;\nimport java.util.concurrent.TimeUnit;\n\nimport io.reactivex.rxjava3.core.Single;\nimport io.reactivex.rxjava3.functions.Function;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.schedulers.TestScheduler;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilCorrespondingEventTransformerSingleTest {\n\n    PublishSubject<String> lifecycle;\n    TestScheduler testScheduler; // Since Single is not backpressure aware, use this to simulate it taking time\n\n    @Before\n    public void setup() {\n        lifecycle = PublishSubject.create();\n        testScheduler = new TestScheduler();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        testObserver.assertNoValues();\n\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneStartEvent() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        testObserver.assertNoValues();\n\n        lifecycle.onNext(\"create\");\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void twoOpenEvents() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        testObserver.assertNoValues();\n\n        lifecycle.onNext(\"create\");\n        lifecycle.onNext(\"start\");\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void openAndCloseEvent() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bind(lifecycle, CORRESPONDING_EVENTS))\n            .test();\n\n        lifecycle.onNext(\"create\");\n        testObserver.assertNoErrors();\n\n        lifecycle.onNext(\"destroy\");\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n        testObserver.assertNoValues();\n        testObserver.assertError(CancellationException.class);\n    }\n\n    private static final Function<String, String> CORRESPONDING_EVENTS = new Function<String, String>() {\n        @Override\n        public String apply(String s) throws Exception {\n            if (s.equals(\"create\")) {\n                return \"destroy\";\n            }\n\n            throw new IllegalArgumentException(\"Cannot handle: \" + s);\n        }\n    };\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilEventTransformerCompletableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.concurrent.CancellationException;\n\nimport io.reactivex.rxjava3.core.Completable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilEventTransformerCompletableTest {\n\n    PublishSubject<Object> subject;\n    Completable completable;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        subject =  PublishSubject.create();\n        completable = Completable.fromObservable(subject);\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        subject.onComplete();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneWrongEvent() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        lifecycle.onNext(\"keep going\");\n        subject.onComplete();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void twoEvents() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        lifecycle.onNext(\"keep going\");\n        lifecycle.onNext(\"stop\");\n        subject.onComplete();\n        testObserver.assertError(CancellationException.class);\n    }\n\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilEventTransformerFlowableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.processors.PublishProcessor;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\nimport io.reactivex.rxjava3.subscribers.TestSubscriber;\n\npublic class UntilEventTransformerFlowableTest {\n\n    PublishProcessor<String> stream;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishProcessor.create();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertNotComplete();\n    }\n\n    @Test\n    public void oneWrongEvent() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"keep going\");\n        stream.onNext(\"2\");\n\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertNotComplete();\n    }\n\n    @Test\n    public void twoEvents() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"keep going\");\n        stream.onNext(\"2\");\n        lifecycle.onNext(\"stop\");\n        stream.onNext(\"3\");\n\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertComplete();\n    }\n\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilEventTransformerMaybeTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.core.Maybe;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilEventTransformerMaybeTest {\n\n    PublishSubject<String> subject;\n    Maybe<String> maybe;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        subject =  PublishSubject.create();\n        maybe = subject.firstElement();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        subject.onNext(\"1\");\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneWrongEvent() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        lifecycle.onNext(\"keep going\");\n        subject.onNext(\"1\");\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void twoEvents() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        lifecycle.onNext(\"keep going\");\n        lifecycle.onNext(\"stop\");\n\n        subject.onNext(\"1\");\n        testObserver.assertNoValues();\n        testObserver.assertComplete();\n    }\n\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilEventTransformerObservableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilEventTransformerObservableTest {\n\n    PublishSubject<String> stream;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishSubject.create();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertNotComplete();\n    }\n\n    @Test\n    public void oneWrongEvent() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"keep going\");\n        stream.onNext(\"2\");\n\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertNotComplete();\n    }\n\n    @Test\n    public void twoEvents() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"keep going\");\n        stream.onNext(\"2\");\n        lifecycle.onNext(\"stop\");\n        stream.onNext(\"3\");\n\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertComplete();\n    }\n\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilEventTransformerSingleTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.concurrent.CancellationException;\nimport java.util.concurrent.TimeUnit;\n\nimport io.reactivex.rxjava3.core.Single;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.schedulers.TestScheduler;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilEventTransformerSingleTest {\n\n    PublishSubject<String> lifecycle;\n    TestScheduler testScheduler; // Since Single is not backpressure aware, use this to simulate it taking time\n\n    @Before\n    public void setup() {\n        lifecycle = PublishSubject.create();\n        testScheduler = new TestScheduler();\n    }\n\n    @Test\n    public void noEvents() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        testObserver.assertNoValues();\n\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneWrongEvent() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        testObserver.assertNoValues();\n\n        lifecycle.onNext(\"keep going\");\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void twoEvents() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bindUntilEvent(lifecycle, \"stop\"))\n            .test();\n\n        lifecycle.onNext(\"keep going\");\n        testObserver.assertNoErrors();\n\n        lifecycle.onNext(\"stop\");\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n\n        testObserver.assertNoValues();\n        testObserver.assertError(CancellationException.class);\n    }\n\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilLifecycleTransformerCompletableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.concurrent.CancellationException;\n\nimport io.reactivex.rxjava3.core.Completable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilLifecycleTransformerCompletableTest {\n\n    PublishSubject<Object> subject;\n    Completable completable;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        subject = PublishSubject.create();\n        completable = Completable.fromObservable(subject);\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvent() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bind(lifecycle))\n            .test();\n\n        subject.onComplete();\n\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneEvent() {\n        TestObserver<Void> testObserver = completable\n            .compose(RxLifecycle.bind(lifecycle))\n            .test();\n\n        lifecycle.onNext(\"stop\");\n        subject.onComplete();\n\n        testObserver.assertError(CancellationException.class);\n    }\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilLifecycleTransformerFlowableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.processors.PublishProcessor;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\nimport io.reactivex.rxjava3.subscribers.TestSubscriber;\n\npublic class UntilLifecycleTransformerFlowableTest {\n\n    PublishProcessor<String> stream;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishProcessor.create();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvent() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n        testSubscriber.assertValues(\"1\", \"2\");\n        testSubscriber.assertNotComplete();\n    }\n\n    @Test\n    public void oneEvent() {\n        TestSubscriber<String> testSubscriber = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"stop\");\n        stream.onNext(\"2\");\n\n        testSubscriber.assertValues(\"1\");\n        testSubscriber.assertComplete();\n    }\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilLifecycleTransformerMaybeTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.core.Maybe;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilLifecycleTransformerMaybeTest {\n\n    PublishSubject<String> stream;\n    Maybe maybe;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishSubject.create();\n        maybe = stream.firstElement();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvent() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        stream.onNext(\"1\");\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneEvent() {\n        TestObserver<String> testObserver = maybe\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        lifecycle.onNext(\"stop\");\n        stream.onNext(\"1\");\n\n        testObserver.assertNoValues();\n        testObserver.assertComplete();\n    }\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilLifecycleTransformerObservableTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilLifecycleTransformerObservableTest {\n\n    PublishSubject<String> stream;\n    PublishSubject<String> lifecycle;\n\n    @Before\n    public void setup() {\n        stream = PublishSubject.create();\n        lifecycle = PublishSubject.create();\n    }\n\n    @Test\n    public void noEvent() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        stream.onNext(\"1\");\n        stream.onNext(\"2\");\n        testObserver.assertValues(\"1\", \"2\");\n        testObserver.assertNotComplete();\n    }\n\n    @Test\n    public void oneEvent() {\n        TestObserver<String> testObserver = stream\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        stream.onNext(\"1\");\n        lifecycle.onNext(\"stop\");\n        stream.onNext(\"2\");\n\n        testObserver.assertValues(\"1\");\n        testObserver.assertComplete();\n    }\n}"
  },
  {
    "path": "rxlifecycle/src/test/java/com/trello/rxlifecycle4/UntilLifecycleTransformerSingleTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport org.junit.Before;\nimport org.junit.Test;\n\nimport java.util.concurrent.CancellationException;\nimport java.util.concurrent.TimeUnit;\n\nimport io.reactivex.rxjava3.core.Single;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.schedulers.TestScheduler;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\npublic class UntilLifecycleTransformerSingleTest {\n\n    PublishSubject<String> lifecycle;\n    TestScheduler testScheduler; // Since Single is not backpressure aware, use this to simulate it taking time\n\n    @Before\n    public void setup() {\n        lifecycle = PublishSubject.create();\n        testScheduler = new TestScheduler();\n    }\n\n    @Test\n    public void noEvent() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        testObserver.assertNoValues();\n\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n        testObserver.assertValue(\"1\");\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void oneEvent() {\n        TestObserver<String> testObserver = Single.just(\"1\")\n            .delay(1, TimeUnit.MILLISECONDS, testScheduler)\n            .compose(RxLifecycle.<String, String>bind(lifecycle))\n            .test();\n\n        testObserver.assertNoValues();\n        testObserver.assertNoErrors();\n\n        lifecycle.onNext(\"stop\");\n        testScheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);\n\n        testObserver.assertNoValues();\n        testObserver.assertError(CancellationException.class);\n    }\n}"
  },
  {
    "path": "rxlifecycle-android/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    api project(':rxlifecycle')\n\n    implementation rootProject.ext.rxAndroid\n    implementation rootProject.ext.supportAnnotations\n\n    testImplementation rootProject.ext.junit\n    testImplementation rootProject.ext.robolectric\n}\n\napply from: \"$rootDir/gradle/artifacts.gradle\"\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\"\n"
  },
  {
    "path": "rxlifecycle-android/gradle.properties",
    "content": "POM_NAME=RxLifecycle-Android\nPOM_DESCRIPTION=RxLifecycle-Android\nPOM_ARTIFACT_ID=rxlifecycle-android\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle-android/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  http://www.apache.org/licenses/LICENSE-2.0\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=\"com.trello.rxlifecycle4.android\" />"
  },
  {
    "path": "rxlifecycle-android/src/main/java/com/trello/rxlifecycle4/android/ActivityEvent.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 */\n\npackage com.trello.rxlifecycle4.android;\n\n/**\n * Lifecycle events that can be emitted by Activities.\n */\npublic enum ActivityEvent {\n\n    CREATE,\n    START,\n    RESUME,\n    PAUSE,\n    STOP,\n    DESTROY\n\n}\n"
  },
  {
    "path": "rxlifecycle-android/src/main/java/com/trello/rxlifecycle4/android/FragmentEvent.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 */\n\npackage com.trello.rxlifecycle4.android;\n\n/**\n * Lifecycle events that can be emitted by Fragments.\n */\npublic enum FragmentEvent {\n\n    ATTACH,\n    CREATE,\n    CREATE_VIEW,\n    START,\n    RESUME,\n    PAUSE,\n    STOP,\n    DESTROY_VIEW,\n    DESTROY,\n    DETACH\n\n}\n"
  },
  {
    "path": "rxlifecycle-android/src/main/java/com/trello/rxlifecycle4/android/RxLifecycleAndroid.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 */\n\npackage com.trello.rxlifecycle4.android;\n\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.OutsideLifecycleException;\n\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.functions.Function;\n\nimport static com.trello.rxlifecycle4.RxLifecycle.bind;\nimport static com.trello.rxlifecycle4.internal.Preconditions.checkNotNull;\n\npublic class RxLifecycleAndroid {\n\n    private RxLifecycleAndroid() {\n        throw new AssertionError(\"No instances\");\n    }\n\n    /**\n     * Binds the given source to an Activity lifecycle.\n     * <p>\n     * This helper automatically determines (based on the lifecycle sequence itself) when the source\n     * should stop emitting items. In the case that the lifecycle sequence is in the\n     * creation phase (CREATE, START, etc) it will choose the equivalent destructive phase (DESTROY,\n     * STOP, etc). If used in the destructive phase, the notifications will cease at the next event;\n     * for example, if used in PAUSE, it will unsubscribe in STOP.\n     * <p>\n     * Due to the differences between the Activity and Fragment lifecycles, this method should only\n     * be used for an Activity lifecycle.\n     *\n     * @param lifecycle the lifecycle sequence of an Activity\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source during the Activity lifecycle\n     */\n    @NonNull\n    @CheckResult\n    public static <T> LifecycleTransformer<T> bindActivity(@NonNull final Observable<ActivityEvent> lifecycle) {\n        return bind(lifecycle, ACTIVITY_LIFECYCLE);\n    }\n\n    /**\n     * Binds the given source to a Fragment lifecycle.\n     * <p>\n     * This helper automatically determines (based on the lifecycle sequence itself) when the source\n     * should stop emitting items. In the case that the lifecycle sequence is in the\n     * creation phase (CREATE, START, etc) it will choose the equivalent destructive phase (DESTROY,\n     * STOP, etc). If used in the destructive phase, the notifications will cease at the next event;\n     * for example, if used in PAUSE, it will unsubscribe in STOP.\n     * <p>\n     * Due to the differences between the Activity and Fragment lifecycles, this method should only\n     * be used for a Fragment lifecycle.\n     *\n     * @param lifecycle the lifecycle sequence of a Fragment\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source during the Fragment lifecycle\n     */\n    @NonNull\n    @CheckResult\n    public static <T> LifecycleTransformer<T> bindFragment(@NonNull final Observable<FragmentEvent> lifecycle) {\n        return bind(lifecycle, FRAGMENT_LIFECYCLE);\n    }\n\n    /**\n     * Binds the given source to a View lifecycle.\n     * <p>\n     * Specifically, when the View detaches from the window, the sequence will be completed.\n     * <p>\n     * Warning: you should make sure to use the returned Transformer on the main thread,\n     * since we're binding to a View (which only allows binding on the main thread).\n     *\n     * @param view the view to bind the source sequence to\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source during the View lifecycle\n     */\n    @NonNull\n    @CheckResult\n    public static <T> LifecycleTransformer<T> bindView(@NonNull final View view) {\n        checkNotNull(view, \"view == null\");\n\n        return bind(Observable.create(new ViewDetachesOnSubscribe(view)));\n    }\n\n    // Figures out which corresponding next lifecycle event in which to unsubscribe, for Activities\n    private static final Function<ActivityEvent, ActivityEvent> ACTIVITY_LIFECYCLE =\n        new Function<ActivityEvent, ActivityEvent>() {\n            @Override\n            public ActivityEvent apply(ActivityEvent lastEvent) throws Exception {\n                switch (lastEvent) {\n                    case CREATE:\n                        return ActivityEvent.DESTROY;\n                    case START:\n                        return ActivityEvent.STOP;\n                    case RESUME:\n                        return ActivityEvent.PAUSE;\n                    case PAUSE:\n                        return ActivityEvent.STOP;\n                    case STOP:\n                        return ActivityEvent.DESTROY;\n                    case DESTROY:\n                        throw new OutsideLifecycleException(\"Cannot bind to Activity lifecycle when outside of it.\");\n                    default:\n                        throw new UnsupportedOperationException(\"Binding to \" + lastEvent + \" not yet implemented\");\n                }\n            }\n        };\n\n    // Figures out which corresponding next lifecycle event in which to unsubscribe, for Fragments\n    private static final Function<FragmentEvent, FragmentEvent> FRAGMENT_LIFECYCLE =\n        new Function<FragmentEvent, FragmentEvent>() {\n            @Override\n            public FragmentEvent apply(FragmentEvent lastEvent) throws Exception {\n                switch (lastEvent) {\n                    case ATTACH:\n                        return FragmentEvent.DETACH;\n                    case CREATE:\n                        return FragmentEvent.DESTROY;\n                    case CREATE_VIEW:\n                        return FragmentEvent.DESTROY_VIEW;\n                    case START:\n                        return FragmentEvent.STOP;\n                    case RESUME:\n                        return FragmentEvent.PAUSE;\n                    case PAUSE:\n                        return FragmentEvent.STOP;\n                    case STOP:\n                        return FragmentEvent.DESTROY_VIEW;\n                    case DESTROY_VIEW:\n                        return FragmentEvent.DESTROY;\n                    case DESTROY:\n                        return FragmentEvent.DETACH;\n                    case DETACH:\n                        throw new OutsideLifecycleException(\"Cannot bind to Fragment lifecycle when outside of it.\");\n                    default:\n                        throw new UnsupportedOperationException(\"Binding to \" + lastEvent + \" not yet implemented\");\n                }\n            }\n        };\n\n}\n"
  },
  {
    "path": "rxlifecycle-android/src/main/java/com/trello/rxlifecycle4/android/ViewDetachesOnSubscribe.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 */\n\npackage com.trello.rxlifecycle4.android;\n\nimport android.view.View;\n\nimport io.reactivex.rxjava3.core.ObservableEmitter;\nimport io.reactivex.rxjava3.core.ObservableOnSubscribe;\nimport io.reactivex.rxjava3.android.MainThreadDisposable;\n\nimport static io.reactivex.rxjava3.android.MainThreadDisposable.verifyMainThread;\n\nfinal class ViewDetachesOnSubscribe implements ObservableOnSubscribe<Object> {\n\n    static final Object SIGNAL = new Object();\n\n    final View view;\n\n    public ViewDetachesOnSubscribe(View view) {\n        this.view = view;\n    }\n\n    @Override\n    public void subscribe(ObservableEmitter<Object> emitter) throws Exception {\n        verifyMainThread();\n        EmitterListener listener = new EmitterListener(emitter);\n        emitter.setDisposable(listener);\n        view.addOnAttachStateChangeListener(listener);\n    }\n\n    class EmitterListener extends MainThreadDisposable implements View.OnAttachStateChangeListener {\n        final ObservableEmitter<Object> emitter;\n\n        public EmitterListener(ObservableEmitter<Object> emitter) {\n            this.emitter = emitter;\n        }\n\n        @Override\n        public void onViewAttachedToWindow(View view) {\n            // Do nothing\n        }\n\n        @Override\n        public void onViewDetachedFromWindow(View view) {\n            emitter.onNext(SIGNAL);\n        }\n\n        @Override\n        protected void onDispose() {\n            view.removeOnAttachStateChangeListener(this);\n        }\n    }\n\n}\n"
  },
  {
    "path": "rxlifecycle-android/src/test/java/com/trello/rxlifecycle4/RxLifecycleTest.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport android.app.Activity;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.android.ActivityEvent;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.Robolectric;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\n\nimport java.util.concurrent.CopyOnWriteArrayList;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\nimport static org.junit.Assert.assertFalse;\nimport static org.junit.Assert.assertNotNull;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class RxLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        // Simulate an actual lifecycle (hot Observable that does not end)\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testBindUntilFragmentEvent() {\n        BehaviorSubject<FragmentEvent> lifecycle = BehaviorSubject.create();\n\n        TestObserver<Object> testObserver =\n            observable.compose(RxLifecycle.bindUntilEvent(lifecycle, FragmentEvent.STOP)).test();\n\n        lifecycle.onNext(FragmentEvent.ATTACH);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(FragmentEvent.CREATE);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(FragmentEvent.CREATE_VIEW);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(FragmentEvent.START);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(FragmentEvent.RESUME);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(FragmentEvent.PAUSE);\n        testObserver.assertNotComplete();\n        testObserver.assertNotComplete();\n        lifecycle.onNext(FragmentEvent.STOP);\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void testBindUntilActivityEvent() {\n        BehaviorSubject<ActivityEvent> lifecycle = BehaviorSubject.create();\n\n        TestObserver<Object> testObserver =\n            observable.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.STOP)).test();\n\n        lifecycle.onNext(ActivityEvent.CREATE);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(ActivityEvent.START);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(ActivityEvent.RESUME);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(ActivityEvent.PAUSE);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(ActivityEvent.STOP);\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void testBindActivityLifecycle() {\n        BehaviorSubject<ActivityEvent> lifecycle = BehaviorSubject.create();\n\n        lifecycle.onNext(ActivityEvent.CREATE);\n        TestObserver<Object> createObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();\n\n        lifecycle.onNext(ActivityEvent.START);\n        createObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();\n\n        lifecycle.onNext(ActivityEvent.RESUME);\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();\n\n        lifecycle.onNext(ActivityEvent.PAUSE);\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n\n        TestObserver<Object> pauseObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();\n        lifecycle.onNext(ActivityEvent.STOP);\n        createObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();\n\n        lifecycle.onNext(ActivityEvent.DESTROY);\n        createObserver.assertComplete();\n        stopObserver.assertComplete();\n    }\n\n    @Test\n    public void testEndsImmediatelyOutsideActivityLifecycle() {\n        BehaviorSubject<ActivityEvent> lifecycle = BehaviorSubject.create();\n        lifecycle.onNext(ActivityEvent.DESTROY);\n\n        TestObserver<Object> testObserver = observable.compose(RxLifecycleAndroid.bindActivity(lifecycle)).test();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void testBindFragmentLifecycle() {\n        BehaviorSubject<FragmentEvent> lifecycle = BehaviorSubject.create();\n\n        lifecycle.onNext(FragmentEvent.ATTACH);\n        TestObserver<Object> attachObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.CREATE);\n        attachObserver.assertNotComplete();\n        TestObserver<Object> createObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.CREATE_VIEW);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        TestObserver<Object> createViewObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.START);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.RESUME);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.PAUSE);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.STOP);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.DESTROY_VIEW);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertComplete();\n        stopObserver.assertComplete();\n        TestObserver<Object> destroyViewObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle))\n            .test();\n\n        lifecycle.onNext(FragmentEvent.DESTROY);\n        attachObserver.assertNotComplete();\n        createObserver.assertComplete();\n        destroyViewObserver.assertComplete();\n        TestObserver<Object> destroyObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n\n        lifecycle.onNext(FragmentEvent.DETACH);\n        attachObserver.assertComplete();\n        destroyObserver.assertComplete();\n    }\n\n    @Test\n    public void testEndsImmediatelyOutsideFragmentLifecycle() {\n        BehaviorSubject<FragmentEvent> lifecycle = BehaviorSubject.create();\n        lifecycle.onNext(FragmentEvent.DETACH);\n\n        TestObserver<Object> testObserver = observable.compose(RxLifecycleAndroid.bindFragment(lifecycle)).test();\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void testBindView() {\n        Activity activity = Robolectric.buildActivity(Activity.class).create().get();\n        View view = new View(activity);\n        CopyOnWriteArrayList<View.OnAttachStateChangeListener> listeners = TestUtil.getAttachStateChangeListeners(view);\n\n        // Do the attach notification\n        if (listeners != null) {\n            for (View.OnAttachStateChangeListener listener : listeners) {\n                listener.onViewAttachedToWindow(view);\n            }\n        }\n\n        // Subscribe\n        TestObserver<Object> viewAttachObserver = observable.compose(RxLifecycleAndroid.bindView(view)).test();\n        viewAttachObserver.assertNotComplete();\n        listeners = TestUtil.getAttachStateChangeListeners(view);\n        assertNotNull(listeners);\n        assertFalse(listeners.isEmpty());\n\n        // Now detach\n        for (View.OnAttachStateChangeListener listener : listeners) {\n            listener.onViewDetachedFromWindow(view);\n        }\n        viewAttachObserver.assertComplete();\n    }\n\n    // Null checks\n\n    @Test(expected = NullPointerException.class)\n    public void testBindFragmentThrowsOnNull() {\n        //noinspection ResourceType\n        RxLifecycleAndroid.bindFragment(null);\n    }\n\n    @Test(expected = NullPointerException.class)\n    public void testBindActivityThrowsOnNull() {\n        //noinspection ResourceType\n        RxLifecycleAndroid.bindActivity(null);\n    }\n\n    @Test(expected = NullPointerException.class)\n    public void testBindViewThrowsOnNullView() {\n        //noinspection ResourceType\n        RxLifecycleAndroid.bindView((View) null);\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-android/src/test/java/com/trello/rxlifecycle4/TestUtil.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 */\n\npackage com.trello.rxlifecycle4;\n\nimport android.view.View;\n\nimport org.robolectric.util.ReflectionHelpers;\n\nimport java.util.concurrent.CopyOnWriteArrayList;\n\npublic class TestUtil {\n\n    /**\n     * Manually retrieve the view's attach state change listeners of an event. Robolectric\n     * doesn't currently support manually firing these, and it would seem the events are not called\n     * in normal Robolectric usage either.\n     *\n     * @param view View with listeners to notify\n     */\n    static CopyOnWriteArrayList<View.OnAttachStateChangeListener> getAttachStateChangeListeners(View view) {\n        Object listenerInfo = ReflectionHelpers.callInstanceMethod(view, \"getListenerInfo\");\n        return ReflectionHelpers.getField(listenerInfo, \"mOnAttachStateChangeListeners\");\n    }\n\n}\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    api project(':rxlifecycle')\n\n    implementation rootProject.ext.rxAndroid\n    implementation rootProject.ext.supportAnnotations\n    api rootProject.ext.lifecycle\n    annotationProcessor rootProject.ext.lifecycleProcessor\n\n    testImplementation rootProject.ext.junit\n    testImplementation rootProject.ext.robolectric\n    testImplementation rootProject.ext.lifecycleExtensions\n}\n\napply from: \"$rootDir/gradle/artifacts.gradle\"\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\"\n\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/gradle.properties",
    "content": "POM_NAME=RxLifecycle-Android-Lifecycle\nPOM_DESCRIPTION=RxLifecycle-Android-Lifecycle\nPOM_ARTIFACT_ID=rxlifecycle-android-lifecycle\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle-android-lifecycle/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"com.trello.rxlifecycle4.android.lifecycle\" />\n\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/src/main/java/com/trello/lifecycle4/android/lifecycle/AndroidLifecycle.java",
    "content": "package com.trello.lifecycle4.android.lifecycle;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\n\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.lifecycle.Lifecycle;\nimport androidx.lifecycle.LifecycleObserver;\nimport androidx.lifecycle.LifecycleOwner;\nimport androidx.lifecycle.OnLifecycleEvent;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\n/**\n * Wraps a {@link LifecycleOwner} so that it can be used as a {@link LifecycleProvider}. For example,\n * you can do\n * <pre>{@code\n * LifecycleProvider<Lifecycle.Event> provider = AndroidLifecycle.createLifecycleProvider(this);\n * myObservable\n *     .compose(provider.bindLifecycle())\n *     .subscribe();\n * }</pre>\n * where {@code this} is a {@code android.arch.lifecycle.LifecycleActivity} or\n * {@code android.arch.lifecycle.LifecycleFragment}.\n */\npublic final class AndroidLifecycle implements LifecycleProvider<Lifecycle.Event>, LifecycleObserver {\n\n    public static LifecycleProvider<Lifecycle.Event> createLifecycleProvider(LifecycleOwner owner) {\n        return new AndroidLifecycle(owner);\n    }\n\n    private final BehaviorSubject<Lifecycle.Event> lifecycleSubject = BehaviorSubject.create();\n\n    private AndroidLifecycle(LifecycleOwner owner) {\n        owner.getLifecycle().addObserver(this);\n    }\n\n    @NonNull\n    @Override\n    @CheckResult\n    public Observable<Lifecycle.Event> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @NonNull\n    @Override\n    @CheckResult\n    public <T> LifecycleTransformer<T> bindUntilEvent(@NonNull Lifecycle.Event event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @NonNull\n    @Override\n    @CheckResult\n    public <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroidLifecycle.bindLifecycle(lifecycleSubject);\n    }\n\n    @OnLifecycleEvent(Lifecycle.Event.ON_ANY)\n    void onEvent(LifecycleOwner owner, Lifecycle.Event event) {\n        lifecycleSubject.onNext(event);\n        if (event == Lifecycle.Event.ON_DESTROY) {\n            owner.getLifecycle().removeObserver(this);\n        }\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/src/main/java/com/trello/lifecycle4/android/lifecycle/RxLifecycleAndroidLifecycle.java",
    "content": "package com.trello.lifecycle4.android.lifecycle;\n\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.OutsideLifecycleException;\n\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.lifecycle.Lifecycle;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.functions.Function;\n\nimport static com.trello.rxlifecycle4.RxLifecycle.bind;\n\npublic final class RxLifecycleAndroidLifecycle {\n\n    private RxLifecycleAndroidLifecycle() {\n        throw new AssertionError(\"No instances\");\n    }\n\n    /**\n     * Binds the given source to an Android lifecycle.\n     * <p>\n     * This helper automatically determines (based on the lifecycle sequence itself) when the source\n     * should stop emitting items. In the case that the lifecycle sequence is in the\n     * creation phase (ON_CREATE, ON_START, etc) it will choose the equivalent destructive phase (ON_DESTROY,\n     * ON_STOP, etc). If used in the destructive phase, the notifications will cease at the next event;\n     * for example, if used in ON_PAUSE, it will unsubscribe in ON_STOP.\n     *\n     * @param lifecycle the lifecycle sequence of an Activity\n     * @return a reusable {@link LifecycleTransformer} that unsubscribes the source during the Activity lifecycle\n     */\n    @NonNull\n    @CheckResult\n    public static <T> LifecycleTransformer<T> bindLifecycle(@NonNull Observable<Lifecycle.Event> lifecycle) {\n        return bind(lifecycle, LIFECYCLE);\n    }\n\n    private static final Function<Lifecycle.Event, Lifecycle.Event> LIFECYCLE = new Function<Lifecycle.Event, Lifecycle.Event>() {\n        @Override\n        public Lifecycle.Event apply(Lifecycle.Event lastEvent) throws Exception {\n            switch (lastEvent) {\n                case ON_CREATE:\n                    return Lifecycle.Event.ON_DESTROY;\n                case ON_START:\n                    return Lifecycle.Event.ON_STOP;\n                case ON_RESUME:\n                    return Lifecycle.Event.ON_PAUSE;\n                case ON_PAUSE:\n                    return Lifecycle.Event.ON_STOP;\n                case ON_STOP:\n                    return Lifecycle.Event.ON_DESTROY;\n                case ON_DESTROY:\n                    throw new OutsideLifecycleException(\"Cannot bind to Activity lifecycle when outside of it.\");\n                default:\n                    throw new UnsupportedOperationException(\"Binding to \" + lastEvent + \" not yet implemented\");\n            }\n        }\n    };\n}\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/src/test/java/com/trello/rxlifecycle4/RxLifecycleTest.java",
    "content": "package com.trello.rxlifecycle4;\n\nimport com.trello.lifecycle4.android.lifecycle.RxLifecycleAndroidLifecycle;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\n\nimport androidx.lifecycle.Lifecycle;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class RxLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        // Simulate an actual lifecycle (hot Observable that does not end)\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testBindUntilLifecycleEvent() {\n        BehaviorSubject<Lifecycle.Event> lifecycle = BehaviorSubject.create();\n\n        TestObserver<Object> testObserver =\n                observable.compose(RxLifecycle.bindUntilEvent(lifecycle, Lifecycle.Event.ON_STOP)).test();\n\n        lifecycle.onNext(Lifecycle.Event.ON_CREATE);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(Lifecycle.Event.ON_START);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(Lifecycle.Event.ON_RESUME);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(Lifecycle.Event.ON_PAUSE);\n        testObserver.assertNotComplete();\n        lifecycle.onNext(Lifecycle.Event.ON_STOP);\n        testObserver.assertComplete();\n    }\n\n    @Test\n    public void testBindLifecycle() {\n        BehaviorSubject<Lifecycle.Event> lifecycle = BehaviorSubject.create();\n\n        lifecycle.onNext(Lifecycle.Event.ON_CREATE);\n        TestObserver<Object> createObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();\n\n        lifecycle.onNext(Lifecycle.Event.ON_START);\n        createObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();\n\n        lifecycle.onNext(Lifecycle.Event.ON_RESUME);\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();\n\n        lifecycle.onNext(Lifecycle.Event.ON_PAUSE);\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n\n        TestObserver<Object> pauseObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();\n        lifecycle.onNext(Lifecycle.Event.ON_STOP);\n        createObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();\n\n        lifecycle.onNext(Lifecycle.Event.ON_DESTROY);\n        createObserver.assertComplete();\n        stopObserver.assertComplete();\n    }\n\n    @Test\n    public void testEndsImmediatelyOutsideLifecycle() {\n        BehaviorSubject<Lifecycle.Event> lifecycle = BehaviorSubject.create();\n        lifecycle.onNext(Lifecycle.Event.ON_DESTROY);\n\n        TestObserver<Object> testObserver = observable.compose(RxLifecycleAndroidLifecycle.bindLifecycle(lifecycle)).test();\n        testObserver.assertComplete();\n    }\n\n    // Null checks\n\n    @Test(expected = NullPointerException.class)\n    public void testBindLifecycleThrowsOnNull() {\n        //noinspection ResourceType\n        RxLifecycleAndroidLifecycle.bindLifecycle(null);\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/src/test/java/com/trello/rxlifecycle4/android/lifecycle/AndroidLifecycleActivityTest.java",
    "content": "package com.trello.rxlifecycle4.android.lifecycle;\n\nimport com.trello.lifecycle4.android.lifecycle.AndroidLifecycle;\nimport com.trello.rxlifecycle4.LifecycleProvider;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.Robolectric;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.android.controller.ActivityController;\nimport org.robolectric.annotation.Config;\n\nimport androidx.fragment.app.FragmentActivity;\nimport androidx.lifecycle.Lifecycle;\nimport androidx.lifecycle.LifecycleOwner;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE, sdk = 17)\npublic class AndroidLifecycleActivityTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testLifecycleActivity() {\n        testLifecycle(Robolectric.buildActivity(FragmentActivity.class));\n        testBindUntilEvent(Robolectric.buildActivity(FragmentActivity.class));\n        testBindToLifecycle(Robolectric.buildActivity(FragmentActivity.class));\n    }\n\n\n    private void testLifecycle(ActivityController<? extends LifecycleOwner> controller) {\n        LifecycleProvider<Lifecycle.Event> provider = AndroidLifecycle.createLifecycleProvider(controller.get());\n\n        TestObserver<Lifecycle.Event> testObserver = provider.lifecycle().test();\n\n        controller.create();\n        controller.start();\n        controller.resume();\n        controller.pause();\n        controller.stop();\n        controller.destroy();\n\n        testObserver.assertValues(\n                Lifecycle.Event.ON_CREATE,\n                Lifecycle.Event.ON_START,\n                Lifecycle.Event.ON_RESUME,\n                Lifecycle.Event.ON_PAUSE,\n                Lifecycle.Event.ON_STOP,\n                Lifecycle.Event.ON_DESTROY\n        );\n    }\n\n    // Tests bindUntil for any given AndroidLifecycle Activity implementation\n    private void testBindUntilEvent(ActivityController<? extends LifecycleOwner> controller) {\n        LifecycleProvider<Lifecycle.Event> activity = AndroidLifecycle.createLifecycleProvider(controller.get());\n\n        TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(Lifecycle.Event.ON_STOP)).test();\n\n        controller.create();\n        testObserver.assertNotComplete();\n        controller.start();\n        testObserver.assertNotComplete();\n        controller.resume();\n        testObserver.assertNotComplete();\n        controller.pause();\n        testObserver.assertNotComplete();\n        controller.stop();\n        testObserver.assertComplete();\n    }\n\n    // Tests bindToLifecycle for any given AndroidLifecycle Activity implementation\n    private void testBindToLifecycle(ActivityController<? extends LifecycleOwner> controller) {\n        LifecycleProvider<Lifecycle.Event> provider = AndroidLifecycle.createLifecycleProvider(controller.get());\n\n        controller.create();\n        TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.start();\n        createObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.resume();\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.pause();\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.stop();\n        createObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.destroy();\n        createObserver.assertComplete();\n        stopObserver.assertComplete();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle/src/test/java/com/trello/rxlifecycle4/android/lifecycle/AndroidLifecycleFragmentTest.java",
    "content": "package com.trello.rxlifecycle4.android.lifecycle;\n\nimport com.trello.lifecycle4.android.lifecycle.AndroidLifecycle;\nimport com.trello.rxlifecycle4.LifecycleProvider;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.Robolectric;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.android.controller.ActivityController;\nimport org.robolectric.annotation.Config;\n\nimport androidx.fragment.app.Fragment;\nimport androidx.fragment.app.FragmentActivity;\nimport androidx.lifecycle.Lifecycle;\nimport androidx.lifecycle.LifecycleOwner;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class AndroidLifecycleFragmentTest {\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testLifecycleFragment() {\n        testLifecycle(new Fragment());\n        testBindUntilEvent(new Fragment());\n        testBindToLifecycle(new Fragment());\n    }\n\n    private void testLifecycle(LifecycleOwner owner) {\n        Fragment fragment = (Fragment) owner;\n        ActivityController<?> controller = startFragment(fragment);\n\n        TestObserver<Lifecycle.Event> testObserver = AndroidLifecycle.createLifecycleProvider(owner).lifecycle().test();\n\n        controller.start();\n        controller.resume();\n        controller.pause();\n        controller.stop();\n        controller.destroy();\n\n        testObserver.assertValues(\n                Lifecycle.Event.ON_CREATE,\n                Lifecycle.Event.ON_START,\n                Lifecycle.Event.ON_RESUME,\n                Lifecycle.Event.ON_PAUSE,\n                Lifecycle.Event.ON_STOP,\n                Lifecycle.Event.ON_DESTROY\n        );\n    }\n\n    // Tests bindUntil for any given AndroidLifecycle Fragment implementation\n    private void testBindUntilEvent(LifecycleOwner owner) {\n        Fragment fragment = (Fragment) owner;\n        ActivityController<?> controller = startFragment(fragment);\n\n        TestObserver<Object> testObserver = observable.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(Lifecycle.Event.ON_STOP)).test();\n\n        testObserver.assertNotComplete();\n        controller.start();\n        testObserver.assertNotComplete();\n        controller.resume();\n        testObserver.assertNotComplete();\n        controller.pause();\n        testObserver.assertNotComplete();\n        controller.stop();\n        testObserver.assertComplete();\n    }\n\n    // Tests bindToLifecycle for any given RxLifecycle Fragment implementation\n    private void testBindToLifecycle(LifecycleOwner owner) {\n        Fragment fragment = (Fragment) owner;\n        LifecycleProvider<Lifecycle.Event> provider = AndroidLifecycle.createLifecycleProvider(owner);\n        ActivityController<?> controller = startFragment(fragment);\n\n        TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.start();\n        createObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.resume();\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.pause();\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.stop();\n        createObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        controller.destroy();\n        createObserver.assertComplete();\n        stopObserver.assertComplete();\n    }\n\n    // Easier than making everyone create their own shadows\n    private ActivityController<FragmentActivity> startFragment(Fragment fragment) {\n        ActivityController<FragmentActivity> controller = Robolectric.buildActivity(FragmentActivity.class);\n        controller.create();\n        controller.get().getSupportFragmentManager()\n                .beginTransaction()\n                .add(android.R.id.content, fragment)\n                .commitNow();\n        return controller;\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\napply plugin: 'kotlin-android'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n\n    kotlinOptions {\n        freeCompilerArgs += [\"-module-name\", \"rxlifecycle-android-lifecycle-kotlin-4\"]\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    implementation kotlinStdlib\n    api project(':rxlifecycle-android-lifecycle')\n}\n\napply from: \"$rootDir/gradle/artifacts.gradle\"\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\"\n\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/gradle.properties",
    "content": "POM_NAME=RxLifecycle-Andoird-Lifecycle-kotlin\nPOM_DESCRIPTION=RxLifecycle-Android-Lifecycle-kotlin\nPOM_ARTIFACT_ID=rxlifecycle-android-lifecycle-kotlin\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /opt/android-sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# Uncomment this to preserve the line number information for\n# debugging stack traces.\n#-keepattributes SourceFile,LineNumberTable\n\n# If you keep the line number information, uncomment this to\n# hide the original source file name.\n#-renamesourcefileattribute SourceFile\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/src/main/AndroidManifest.xml",
    "content": "<manifest package=\"com.trello.rxlifecycle4.android.lifecycle.kotlin\" />\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/src/main/java/com/trello/rxlifecycle4/android/lifecycle/kotlin/rxlifecycle.kt",
    "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 */\n\npackage com.trello.rxlifecycle4.android.lifecycle.kotlin\n\nimport androidx.lifecycle.Lifecycle\nimport androidx.lifecycle.LifecycleOwner\nimport com.trello.lifecycle4.android.lifecycle.AndroidLifecycle\nimport io.reactivex.rxjava3.core.*\n\nfun <T> Observable<T>.bindToLifecycle(owner: LifecycleOwner): Observable<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindToLifecycle())\n\nfun <T> Observable<T>.bindUntilEvent(owner: LifecycleOwner, event: Lifecycle.Event): Observable<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(event))\n\nfun <T> Flowable<T>.bindToLifecycle(owner: LifecycleOwner): Flowable<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindToLifecycle())\n\nfun <T> Flowable<T>.bindUntilEvent(owner: LifecycleOwner, event: Lifecycle.Event): Flowable<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(event))\n\nfun <T> Single<T>.bindToLifecycle(owner: LifecycleOwner): Single<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindToLifecycle())\n\nfun <T> Single<T>.bindUntilEvent(owner: LifecycleOwner, event: Lifecycle.Event): Single<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(event))\n\nfun <T> Maybe<T>.bindToLifecycle(owner: LifecycleOwner): Maybe<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindToLifecycle())\n\nfun <T> Maybe<T>.bindUntilEvent(owner: LifecycleOwner, event: Lifecycle.Event): Maybe<T>\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent(event))\n\nfun Completable.bindToLifecycle(owner: LifecycleOwner): Completable\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindToLifecycle<Completable>())\n\nfun Completable.bindUntilEvent(owner: LifecycleOwner, event: Lifecycle.Event): Completable\n        = this.compose(AndroidLifecycle.createLifecycleProvider(owner).bindUntilEvent<Completable>(event))\n"
  },
  {
    "path": "rxlifecycle-android-lifecycle-kotlin/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">rxlifecycle-android-lifecycle-kotlin</string>\n</resources>\n"
  },
  {
    "path": "rxlifecycle-components/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    api project(':rxlifecycle-android')\n\n    implementation rootProject.ext.rxJava\n\n    implementation rootProject.ext.appCompat\n\n    testImplementation rootProject.ext.junit\n    testImplementation rootProject.ext.robolectric\n}\n\napply from: \"$rootDir/gradle/artifacts.gradle\"\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\""
  },
  {
    "path": "rxlifecycle-components/gradle.properties",
    "content": "POM_NAME=RxLifecycle-Components\nPOM_DESCRIPTION=RxLifecycle-Components\nPOM_ARTIFACT_ID=rxlifecycle-components\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle-components/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  http://www.apache.org/licenses/LICENSE-2.0\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=\"com.trello.rxlifecycle4.components\" />"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/RxActivity.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 */\n\npackage com.trello.rxlifecycle4.components;\n\nimport android.app.Activity;\nimport android.os.Bundle;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.ActivityEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxActivity extends Activity implements LifecycleProvider<ActivityEvent> {\n\n    private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<ActivityEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindActivity(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(ActivityEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    protected void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(ActivityEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    protected void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(ActivityEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    protected void onPause() {\n        lifecycleSubject.onNext(ActivityEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    protected void onStop() {\n        lifecycleSubject.onNext(ActivityEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    protected void onDestroy() {\n        lifecycleSubject.onNext(ActivityEvent.DESTROY);\n        super.onDestroy();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/RxDialogFragment.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 */\n\npackage com.trello.rxlifecycle4.components;\n\nimport android.app.DialogFragment;\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxDialogFragment extends DialogFragment implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/RxFragment.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 */\n\npackage com.trello.rxlifecycle4.components;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxFragment extends Fragment implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/RxPreferenceFragment.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 */\n\npackage com.trello.rxlifecycle4.components;\n\nimport android.os.Bundle;\nimport android.preference.PreferenceFragment;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxPreferenceFragment extends PreferenceFragment implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxAppCompatActivity.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 */\n\npackage com.trello.rxlifecycle4.components.support;\n\nimport android.os.Bundle;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.ContentView;\nimport androidx.annotation.LayoutRes;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.app.AppCompatActivity;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.ActivityEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxAppCompatActivity extends AppCompatActivity implements LifecycleProvider<ActivityEvent> {\n\n    private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();\n\n    public RxAppCompatActivity() {\n        super();\n    }\n\n    @ContentView\n    public RxAppCompatActivity(@LayoutRes int contentLayoutId) {\n        super(contentLayoutId);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<ActivityEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindActivity(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(ActivityEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    protected void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(ActivityEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    protected void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(ActivityEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    protected void onPause() {\n        lifecycleSubject.onNext(ActivityEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    protected void onStop() {\n        lifecycleSubject.onNext(ActivityEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    protected void onDestroy() {\n        lifecycleSubject.onNext(ActivityEvent.DESTROY);\n        super.onDestroy();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxAppCompatDialogFragment.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 */\n\npackage com.trello.rxlifecycle4.components.support;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.appcompat.app.AppCompatDialogFragment;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxAppCompatDialogFragment extends AppCompatDialogFragment implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxDialogFragment.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 */\n\npackage com.trello.rxlifecycle4.components.support;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.fragment.app.DialogFragment;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxDialogFragment extends DialogFragment implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxFragment.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 */\n\npackage com.trello.rxlifecycle4.components.support;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.ContentView;\nimport androidx.annotation.LayoutRes;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.fragment.app.Fragment;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxFragment extends Fragment implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    public RxFragment() {\n        super();\n    }\n\n    @ContentView\n    public RxFragment(@LayoutRes int contentLayoutId) {\n        super(contentLayoutId);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/main/java/com/trello/rxlifecycle4/components/support/RxFragmentActivity.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 */\n\npackage com.trello.rxlifecycle4.components.support;\n\nimport android.os.Bundle;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.ContentView;\nimport androidx.annotation.LayoutRes;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.fragment.app.FragmentActivity;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.ActivityEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxFragmentActivity extends FragmentActivity implements LifecycleProvider<ActivityEvent> {\n\n    private final BehaviorSubject<ActivityEvent> lifecycleSubject = BehaviorSubject.create();\n\n    public RxFragmentActivity() {\n        super();\n    }\n\n    @ContentView\n    public RxFragmentActivity(@LayoutRes int contentLayoutId) {\n        super(contentLayoutId);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<ActivityEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull ActivityEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindActivity(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(ActivityEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    protected void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(ActivityEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    protected void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(ActivityEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    protected void onPause() {\n        lifecycleSubject.onNext(ActivityEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    protected void onStop() {\n        lifecycleSubject.onNext(ActivityEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    protected void onDestroy() {\n        lifecycleSubject.onNext(ActivityEvent.DESTROY);\n        super.onDestroy();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/test/java/com/trello/rxlifecycle4/components/RxActivityLifecycleTest.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 */\n\npackage com.trello.rxlifecycle4.components;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.android.ActivityEvent;\nimport com.trello.rxlifecycle4.components.support.RxFragmentActivity;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.Robolectric;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.android.controller.ActivityController;\nimport org.robolectric.annotation.Config;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\nimport static com.trello.rxlifecycle4.android.ActivityEvent.STOP;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class RxActivityLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testRxActivity() {\n        testLifecycle(Robolectric.buildActivity(TestRxActivity.class));\n        testBindUntilEvent(Robolectric.buildActivity(TestRxActivity.class));\n        testBindToLifecycle(Robolectric.buildActivity(TestRxActivity.class));\n    }\n\n    @Test\n    public void testRxFragmentActivity() {\n        testLifecycle(Robolectric.buildActivity(TestRxFragmentActivity.class));\n        testBindUntilEvent(Robolectric.buildActivity(TestRxFragmentActivity.class));\n        testBindToLifecycle(Robolectric.buildActivity(TestRxFragmentActivity.class));\n    }\n\n    @Test\n    public void testRxAppCompatActivity() {\n        // TODO: Doesn't work due to https://github.com/robolectric/robolectric/issues/1796\n        //\n        // testBindUntilEvent(Robolectric.buildActivity(RxAppCompatActivity.class));\n        // testBindToLifecycle(Robolectric.buildActivity(RxAppCompatActivity.class));\n    }\n\n    private void testLifecycle(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {\n        LifecycleProvider<ActivityEvent> activity = controller.get();\n\n        TestObserver<ActivityEvent> testObserver = activity.lifecycle().test();\n\n        controller.create();\n        controller.start();\n        controller.resume();\n        controller.pause();\n        controller.stop();\n        controller.destroy();\n\n        testObserver.assertValues(\n            ActivityEvent.CREATE,\n            ActivityEvent.START,\n            ActivityEvent.RESUME,\n            ActivityEvent.PAUSE,\n            ActivityEvent.STOP,\n            ActivityEvent.DESTROY\n        );\n    }\n\n    // Tests bindUntil for any given RxActivityLifecycle implementation\n    private void testBindUntilEvent(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {\n        LifecycleProvider<ActivityEvent> activity = controller.get();\n\n        TestObserver<Object> testObserver = observable.compose(activity.bindUntilEvent(STOP)).test();\n\n        controller.create();\n        testObserver.assertNotComplete();\n        controller.start();\n        testObserver.assertNotComplete();\n        controller.resume();\n        testObserver.assertNotComplete();\n        controller.pause();\n        testObserver.assertNotComplete();\n        controller.stop();\n        testObserver.assertComplete();\n    }\n\n    // Tests bindToLifecycle for any given RxActivityLifecycle implementation\n    private void testBindToLifecycle(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {\n        LifecycleProvider<ActivityEvent> activity = controller.get();\n\n        controller.create();\n        TestObserver<Object> createObserver = observable.compose(activity.bindToLifecycle()).test();\n\n        controller.start();\n        createObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(activity.bindToLifecycle()).test();\n\n        controller.resume();\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(activity.bindToLifecycle()).test();\n\n        controller.pause();\n        createObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(activity.bindToLifecycle()).test();\n\n        controller.stop();\n        createObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(activity.bindToLifecycle()).test();\n\n        controller.destroy();\n        createObserver.assertComplete();\n        stopObserver.assertComplete();\n    }\n\n    // These classes are just for testing since components are abstract\n\n    public static class TestRxActivity extends RxActivity {\n    }\n\n    public static class TestRxFragmentActivity extends RxFragmentActivity{\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/test/java/com/trello/rxlifecycle4/components/RxFragmentLifecycleTest.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 */\n\npackage com.trello.rxlifecycle4.components;\n\nimport android.app.Fragment;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\n\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.util.FragmentTestUtil;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\nimport static com.trello.rxlifecycle4.android.FragmentEvent.STOP;\nimport static org.robolectric.util.FragmentTestUtil.startFragment;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class RxFragmentLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testRxFragment() {\n        testLifecycle(new TestRxFragment());\n        testBindUntilEvent(new TestRxFragment());\n        testBindToLifecycle(new TestRxFragment());\n    }\n\n    @Test\n    public void testRxDialogFragment() {\n        testLifecycle(new TestRxDialogFragment());\n        testBindUntilEvent(new TestRxDialogFragment());\n        testBindToLifecycle(new TestRxDialogFragment());\n    }\n\n    @Test\n    public void testRxPreferenceFragment() {\n        testLifecycle(new TestRxPreferenceFragment());\n        testBindUntilEvent(new TestRxPreferenceFragment());\n        testBindToLifecycle(new TestRxPreferenceFragment());\n    }\n\n    private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        FragmentTestUtil.startFragment(fragment);\n\n        TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();\n\n        fragment.onAttach(null);\n        fragment.onCreate(null);\n        fragment.onViewCreated(null, null);\n        fragment.onStart();\n        fragment.onResume();\n        fragment.onPause();\n        fragment.onStop();\n        fragment.onDestroyView();\n        fragment.onDestroy();\n        fragment.onDetach();\n\n        testObserver.assertValues(\n            FragmentEvent.ATTACH,\n            FragmentEvent.CREATE,\n            FragmentEvent.CREATE_VIEW,\n            FragmentEvent.START,\n            FragmentEvent.RESUME,\n            FragmentEvent.PAUSE,\n            FragmentEvent.STOP,\n            FragmentEvent.DESTROY_VIEW,\n            FragmentEvent.DESTROY,\n            FragmentEvent.DETACH\n        );\n    }\n\n    // Tests bindUntil for any given LifecycleProvider<FragmentEvent> implementation\n    private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();\n\n        fragment.onAttach(null);\n        testObserver.assertNotComplete();\n        fragment.onCreate(null);\n        testObserver.assertNotComplete();\n        fragment.onViewCreated(null, null);\n        testObserver.assertNotComplete();\n        fragment.onStart();\n        testObserver.assertNotComplete();\n        fragment.onResume();\n        testObserver.assertNotComplete();\n        fragment.onPause();\n        testObserver.assertNotComplete();\n        fragment.onStop();\n        testObserver.assertComplete();\n    }\n\n    // Tests bindToLifecycle for any given LifecycleProvider<FragmentEvent> implementation\n    private void testBindToLifecycle(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        fragment.onAttach(null);\n        TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onCreate(null);\n        attachObserver.assertNotComplete();\n        TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onViewCreated(null, null);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        TestObserver<Object> createViewObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onStart();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onResume();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onPause();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onStop();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDestroyView();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertComplete();\n        stopObserver.assertComplete();\n        TestObserver<Object> destroyViewObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDestroy();\n        attachObserver.assertNotComplete();\n        createObserver.assertComplete();\n        destroyViewObserver.assertComplete();\n        TestObserver<Object> destroyObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDetach();\n        attachObserver.assertComplete();\n        destroyObserver.assertComplete();\n    }\n\n    // These classes are just for testing since components are abstract\n\n    public static class TestRxFragment extends RxFragment {\n    }\n\n    public static class TestRxDialogFragment extends RxDialogFragment {\n    }\n\n    public static class TestRxPreferenceFragment extends RxPreferenceFragment {\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components/src/test/java/com/trello/rxlifecycle4/components/support/RxSupportFragmentLifecycleTest.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 */\n\npackage com.trello.rxlifecycle4.components.support;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.Robolectric;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\n\nimport androidx.fragment.app.Fragment;\nimport androidx.fragment.app.FragmentActivity;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\nimport static com.trello.rxlifecycle4.android.FragmentEvent.STOP;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class RxSupportFragmentLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testRxFragment() {\n        testLifecycle(new TestRxFragment());\n        testBindUntilEvent(new TestRxFragment());\n        testBindToLifecycle(new TestRxFragment());\n    }\n\n    @Test\n    public void testRxDialogFragment() {\n        testLifecycle(new TestRxDialogFragment());\n        testBindUntilEvent(new TestRxDialogFragment());\n        testBindToLifecycle(new TestRxDialogFragment());\n    }\n\n    @Test\n    public void testRxAppCompatDialogFragment() {\n        // Once Robolectric is less broken we could run these tests\n        // Until then, these are identical to RxDialogFragment, so whatever.\n        //\n        // testLifecycle(new RxAppCompatDialogFragment());\n        // testBindUntilEvent(new RxAppCompatDialogFragment());\n        // testBindToLifecycle(new RxAppCompatDialogFragment());\n    }\n\n    private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();\n\n        fragment.onAttach(null);\n        fragment.onCreate(null);\n        fragment.onViewCreated(null, null);\n        fragment.onStart();\n        fragment.onResume();\n        fragment.onPause();\n        fragment.onStop();\n        fragment.onDestroyView();\n        fragment.onDestroy();\n        fragment.onDetach();\n\n        testObserver.assertValues(\n            FragmentEvent.ATTACH,\n            FragmentEvent.CREATE,\n            FragmentEvent.CREATE_VIEW,\n            FragmentEvent.START,\n            FragmentEvent.RESUME,\n            FragmentEvent.PAUSE,\n            FragmentEvent.STOP,\n            FragmentEvent.DESTROY_VIEW,\n            FragmentEvent.DESTROY,\n            FragmentEvent.DETACH\n        );\n    }\n\n    // Tests bindUntil for any given LifecycleProvider<FragmentEvent> implementation\n    private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();\n\n        fragment.onAttach(null);\n        testObserver.assertNotComplete();\n        fragment.onCreate(null);\n        testObserver.assertNotComplete();\n        fragment.onViewCreated(null, null);\n        testObserver.assertNotComplete();\n        fragment.onStart();\n        testObserver.assertNotComplete();\n        fragment.onResume();\n        testObserver.assertNotComplete();\n        fragment.onPause();\n        testObserver.assertNotComplete();\n        fragment.onStop();\n        testObserver.assertComplete();\n    }\n\n    // Tests bindToLifecycle for any given LifecycleProvider<FragmentEvent> implementation\n    private void testBindToLifecycle(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        fragment.onAttach(null);\n        TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onCreate(null);\n        attachObserver.assertNotComplete();\n        TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onViewCreated(null, null);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        TestObserver<Object> createViewObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onStart();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onResume();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onPause();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onStop();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDestroyView();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertComplete();\n        stopObserver.assertComplete();\n        TestObserver<Object> destroyViewObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDestroy();\n        attachObserver.assertNotComplete();\n        createObserver.assertComplete();\n        destroyViewObserver.assertComplete();\n        TestObserver<Object> destroyObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDetach();\n        attachObserver.assertComplete();\n        destroyObserver.assertComplete();\n    }\n\n    // Easier than making everyone create their own shadows\n    private void startFragment(Fragment fragment) {\n        Robolectric.setupActivity(FragmentActivity.class).getSupportFragmentManager()\n            .beginTransaction()\n            .add(fragment, null)\n            .commit();\n    }\n\n    // These classes are just for testing since components are abstract\n\n    public static class TestRxFragment extends RxFragment {\n    }\n\n    public static class TestRxDialogFragment extends RxDialogFragment {\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components-preference/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    api project(':rxlifecycle-android')\n\n    implementation rootProject.ext.rxJava\n\n    implementation rootProject.ext.preferenceCompat\n\n    testImplementation rootProject.ext.junit\n    testImplementation rootProject.ext.robolectric\n}\n\napply from: \"$rootDir/gradle/artifacts.gradle\"\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\""
  },
  {
    "path": "rxlifecycle-components-preference/gradle.properties",
    "content": "POM_NAME=RxLifecycle-Components-Preference\nPOM_DESCRIPTION=RxLifecycle-Components-Preference\nPOM_ARTIFACT_ID=rxlifecycle-components-preference\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle-components-preference/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  http://www.apache.org/licenses/LICENSE-2.0\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=\"com.trello.rxlifecycle4.components.preference\" />"
  },
  {
    "path": "rxlifecycle-components-preference/src/main/java/com/trello/rxlifecycle4/components/preference/RxEditTextPreferenceDialogFragmentCompat.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 */\n\npackage com.trello.rxlifecycle4.components.preference;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.preference.EditTextPreferenceDialogFragmentCompat;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxEditTextPreferenceDialogFragmentCompat extends EditTextPreferenceDialogFragmentCompat implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components-preference/src/main/java/com/trello/rxlifecycle4/components/preference/RxListPreferenceDialogFragmentCompat.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 */\n\npackage com.trello.rxlifecycle4.components.preference;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.preference.ListPreferenceDialogFragmentCompat;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxListPreferenceDialogFragmentCompat extends ListPreferenceDialogFragmentCompat implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components-preference/src/main/java/com/trello/rxlifecycle4/components/preference/RxPreferenceDialogFragmentCompat.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 */\n\npackage com.trello.rxlifecycle4.components.preference;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.preference.PreferenceDialogFragmentCompat;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxPreferenceDialogFragmentCompat extends PreferenceDialogFragmentCompat implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components-preference/src/main/java/com/trello/rxlifecycle4/components/preference/RxPreferenceFragmentCompat.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 */\n\npackage com.trello.rxlifecycle4.components.preference;\n\nimport android.os.Bundle;\nimport android.view.View;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.LifecycleTransformer;\nimport com.trello.rxlifecycle4.RxLifecycle;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid;\n\nimport androidx.annotation.CallSuper;\nimport androidx.annotation.CheckResult;\nimport androidx.annotation.NonNull;\nimport androidx.annotation.Nullable;\nimport androidx.preference.PreferenceFragmentCompat;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.subjects.BehaviorSubject;\n\npublic abstract class RxPreferenceFragmentCompat extends PreferenceFragmentCompat implements LifecycleProvider<FragmentEvent> {\n\n    private final BehaviorSubject<FragmentEvent> lifecycleSubject = BehaviorSubject.create();\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final Observable<FragmentEvent> lifecycle() {\n        return lifecycleSubject.hide();\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindUntilEvent(@NonNull FragmentEvent event) {\n        return RxLifecycle.bindUntilEvent(lifecycleSubject, event);\n    }\n\n    @Override\n    @NonNull\n    @CheckResult\n    public final <T> LifecycleTransformer<T> bindToLifecycle() {\n        return RxLifecycleAndroid.bindFragment(lifecycleSubject);\n    }\n\n    @Override\n    @CallSuper\n    public void onAttach(android.app.Activity activity) {\n        super.onAttach(activity);\n        lifecycleSubject.onNext(FragmentEvent.ATTACH);\n    }\n\n    @Override\n    @CallSuper\n    public void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE);\n    }\n\n    @Override\n    @CallSuper\n    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {\n        super.onViewCreated(view, savedInstanceState);\n        lifecycleSubject.onNext(FragmentEvent.CREATE_VIEW);\n    }\n\n    @Override\n    @CallSuper\n    public void onStart() {\n        super.onStart();\n        lifecycleSubject.onNext(FragmentEvent.START);\n    }\n\n    @Override\n    @CallSuper\n    public void onResume() {\n        super.onResume();\n        lifecycleSubject.onNext(FragmentEvent.RESUME);\n    }\n\n    @Override\n    @CallSuper\n    public void onPause() {\n        lifecycleSubject.onNext(FragmentEvent.PAUSE);\n        super.onPause();\n    }\n\n    @Override\n    @CallSuper\n    public void onStop() {\n        lifecycleSubject.onNext(FragmentEvent.STOP);\n        super.onStop();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroyView() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY_VIEW);\n        super.onDestroyView();\n    }\n\n    @Override\n    @CallSuper\n    public void onDestroy() {\n        lifecycleSubject.onNext(FragmentEvent.DESTROY);\n        super.onDestroy();\n    }\n\n    @Override\n    @CallSuper\n    public void onDetach() {\n        lifecycleSubject.onNext(FragmentEvent.DETACH);\n        super.onDetach();\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-components-preference/src/test/java/com/trello/rxlifecycle4/components/preference/RxPreferenceFragmentLifecycleTest.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 */\n\npackage com.trello.rxlifecycle4.components.preference;\n\nimport android.os.Bundle;\n\nimport com.trello.rxlifecycle4.LifecycleProvider;\nimport com.trello.rxlifecycle4.android.FragmentEvent;\n\nimport org.junit.Before;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.robolectric.Robolectric;\nimport org.robolectric.RobolectricTestRunner;\nimport org.robolectric.annotation.Config;\n\nimport androidx.fragment.app.Fragment;\nimport androidx.fragment.app.FragmentActivity;\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.observers.TestObserver;\nimport io.reactivex.rxjava3.subjects.PublishSubject;\n\nimport static com.trello.rxlifecycle4.android.FragmentEvent.STOP;\n\n@RunWith(RobolectricTestRunner.class)\n@Config(manifest = Config.NONE)\npublic class RxPreferenceFragmentLifecycleTest {\n\n    private Observable<Object> observable;\n\n    @Before\n    public void setup() {\n        observable = PublishSubject.create().hide();\n    }\n\n    @Test\n    public void testRxPreferenceFragmentCompat() {\n        // Requires android.support.v7.preference.R.preferenceTheme\n        // attribute being set.\n        //\n        // testLifecycle(new TestRxPreferenceFragmentCompat());\n        // testBindUntilEvent(new TestRxPreferenceFragmentCompat());\n        // testBindToLifecycle(new TestRxPreferenceFragmentCompat());\n    }\n\n    private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();\n\n        fragment.onAttach(null);\n        fragment.onCreate(null);\n        fragment.onViewCreated(null, null);\n        fragment.onStart();\n        fragment.onResume();\n        fragment.onPause();\n        fragment.onStop();\n        fragment.onDestroyView();\n        fragment.onDestroy();\n        fragment.onDetach();\n\n        testObserver.assertValues(\n            FragmentEvent.ATTACH,\n            FragmentEvent.CREATE,\n            FragmentEvent.CREATE_VIEW,\n            FragmentEvent.START,\n            FragmentEvent.RESUME,\n            FragmentEvent.PAUSE,\n            FragmentEvent.STOP,\n            FragmentEvent.DESTROY_VIEW,\n            FragmentEvent.DESTROY,\n            FragmentEvent.DETACH\n        );\n    }\n\n    // Tests bindUntil for any given LifecycleProvider<FragmentEvent> implementation\n    private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();\n\n        fragment.onAttach(null);\n        testObserver.assertNotComplete();\n        fragment.onCreate(null);\n        testObserver.assertNotComplete();\n        fragment.onViewCreated(null, null);\n        testObserver.assertNotComplete();\n        fragment.onStart();\n        testObserver.assertNotComplete();\n        fragment.onResume();\n        testObserver.assertNotComplete();\n        fragment.onPause();\n        testObserver.assertNotComplete();\n        fragment.onStop();\n        testObserver.assertComplete();\n    }\n\n    // Tests bindToLifecycle for any given LifecycleProvider<FragmentEvent> implementation\n    private void testBindToLifecycle(LifecycleProvider<FragmentEvent> provider) {\n        Fragment fragment = (Fragment) provider;\n        startFragment(fragment);\n\n        fragment.onAttach(null);\n        TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onCreate(null);\n        attachObserver.assertNotComplete();\n        TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onViewCreated(null, null);\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        TestObserver<Object> createViewObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onStart();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onResume();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onPause();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertNotComplete();\n        resumeObserver.assertComplete();\n        TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onStop();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertNotComplete();\n        startObserver.assertComplete();\n        pauseObserver.assertComplete();\n        TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDestroyView();\n        attachObserver.assertNotComplete();\n        createObserver.assertNotComplete();\n        createViewObserver.assertComplete();\n        stopObserver.assertComplete();\n        TestObserver<Object> destroyViewObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDestroy();\n        attachObserver.assertNotComplete();\n        createObserver.assertComplete();\n        destroyViewObserver.assertComplete();\n        TestObserver<Object> destroyObserver = observable.compose(provider.bindToLifecycle()).test();\n\n        fragment.onDetach();\n        attachObserver.assertComplete();\n        destroyObserver.assertComplete();\n    }\n\n    // Easier than making everyone create their own shadows\n    private void startFragment(Fragment fragment) {\n        Robolectric.setupActivity(FragmentActivity.class).getSupportFragmentManager()\n            .beginTransaction()\n            .add(fragment, null)\n            .commit();\n    }\n\n    // These classes are just for testing since components are abstract\n\n    public static class TestRxPreferenceFragmentCompat extends RxPreferenceFragmentCompat {\n        @Override\n        public void onCreatePreferences(Bundle bundle, String s) {\n        }\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-kotlin/build.gradle",
    "content": "apply plugin: 'com.android.library'\napply plugin: 'com.github.dcendents.android-maven'\napply plugin: 'kotlin-android'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n    }\n\n    kotlinOptions {\n        freeCompilerArgs += [\"-module-name\", \"rxlifecycle-kotlin-4\"]\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    implementation kotlinStdlib\n    api project(':rxlifecycle-android')\n}\n\napply from: \"$rootDir/gradle/artifacts.gradle\"\napply from: \"$rootDir/gradle/gradle-mvn-push.gradle\""
  },
  {
    "path": "rxlifecycle-kotlin/gradle.properties",
    "content": "POM_NAME=RxLifecycle-kotlin\nPOM_DESCRIPTION=RxLifecycle-kotlin\nPOM_ARTIFACT_ID=rxlifecycle-kotlin\nPOM_PACKAGING=aar"
  },
  {
    "path": "rxlifecycle-kotlin/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  http://www.apache.org/licenses/LICENSE-2.0\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=\"com.trello.rxlifecycle4.kotlin\" />"
  },
  {
    "path": "rxlifecycle-kotlin/src/main/java/com/trello/rxlifecycle4/kotlin/rxlifecycle.kt",
    "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 */\n\npackage com.trello.rxlifecycle4.kotlin\n\nimport android.view.View\nimport com.trello.rxlifecycle4.LifecycleProvider\nimport com.trello.rxlifecycle4.RxLifecycle\nimport com.trello.rxlifecycle4.android.RxLifecycleAndroid\nimport io.reactivex.rxjava3.core.*\nimport io.reactivex.rxjava3.functions.Function\n\n// RxLifecycle extensions\n\nfun <T, E> Observable<T>.bind(lifecycle: Observable<E>): Observable<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle))\n\nfun <T, E> Observable<T>.bindUntilEvent(lifecycle: Observable<E>, event: E): Observable<T>\n    = this.compose<T>(RxLifecycle.bindUntilEvent(lifecycle, event))\n\nfun <T, E> Observable<T>.bind(lifecycle: Observable<E>, correspondingEvents: Function<E, E>): Observable<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle, correspondingEvents))\n\nfun <T, E> Flowable<T>.bind(lifecycle: Observable<E>): Flowable<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle))\n\nfun <T, E> Flowable<T>.bindUntilEvent(lifecycle: Observable<E>, event: E): Flowable<T>\n    = this.compose<T>(RxLifecycle.bindUntilEvent(lifecycle, event))\n\nfun <T, E> Flowable<T>.bind(lifecycle: Observable<E>, correspondingEvents: Function<E, E>): Flowable<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle, correspondingEvents))\n\nfun <T, E> Single<T>.bind(lifecycle: Observable<E>): Single<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle))\n\nfun <T, E> Single<T>.bindUntilEvent(lifecycle: Observable<E>, event: E): Single<T>\n    = this.compose<T>(RxLifecycle.bindUntilEvent(lifecycle, event))\n\nfun <T, E> Single<T>.bind(lifecycle: Observable<E>, correspondingEvents: Function<E, E>): Single<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle, correspondingEvents))\n\nfun <T, E> Maybe<T>.bind(lifecycle: Observable<E>): Maybe<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle))\n\nfun <T, E> Maybe<T>.bindUntilEvent(lifecycle: Observable<E>, event: E): Maybe<T>\n    = this.compose<T>(RxLifecycle.bindUntilEvent(lifecycle, event))\n\nfun <T, E> Maybe<T>.bind(lifecycle: Observable<E>, correspondingEvents: Function<E, E>): Maybe<T>\n    = this.compose<T>(RxLifecycle.bind(lifecycle, correspondingEvents))\n\nfun <E> Completable.bind(lifecycle: Observable<E>): Completable\n    = this.compose(RxLifecycle.bind<Any, E>(lifecycle))\n\nfun <E> Completable.bindUntilEvent(lifecycle: Observable<E>, event: E): Completable\n    = this.compose(RxLifecycle.bindUntilEvent<Any, E>(lifecycle, event))\n\nfun <E> Completable.bind(lifecycle: Observable<E>, correspondingEvents: Function<E, E>): Completable\n    = this.compose(RxLifecycle.bind<Any, E>(lifecycle, correspondingEvents))\n\n// RxLifecycleAndroid extensions\n\nfun <T, E> Observable<T>.bindToLifecycle(provider: LifecycleProvider<E>): Observable<T>\n    = this.compose<T>(provider.bindToLifecycle<T>())\n\nfun <T, E> Observable<T>.bindUntilEvent(provider: LifecycleProvider<E>, event: E): Observable<T>\n    = this.compose<T>(provider.bindUntilEvent(event))\n\nfun <T> Observable<T>.bindToLifecycle(view: View): Observable<T>\n    = this.compose<T>(RxLifecycleAndroid.bindView(view))\n\nfun <T, E> Flowable<T>.bindToLifecycle(provider: LifecycleProvider<E>): Flowable<T>\n    = this.compose<T>(provider.bindToLifecycle<T>())\n\nfun <T, E> Flowable<T>.bindUntilEvent(provider: LifecycleProvider<E>, event: E): Flowable<T>\n    = this.compose<T>(provider.bindUntilEvent(event))\n\nfun <T> Flowable<T>.bindToLifecycle(view: View): Flowable<T>\n    = this.compose<T>(RxLifecycleAndroid.bindView(view))\n\nfun <T, E> Single<T>.bindToLifecycle(provider: LifecycleProvider<E>): Single<T>\n    = this.compose(provider.bindToLifecycle<T>())\n\nfun <T, E> Single<T>.bindUntilEvent(provider: LifecycleProvider<E>, event: E): Single<T>\n    = this.compose(provider.bindUntilEvent<T>(event))\n\nfun <T> Single<T>.bindToLifecycle(view: View): Single<T>\n    = this.compose(RxLifecycleAndroid.bindView<T>(view))\n\nfun <T, E> Maybe<T>.bindToLifecycle(provider: LifecycleProvider<E>): Maybe<T>\n    = this.compose(provider.bindToLifecycle<T>())\n\nfun <T, E> Maybe<T>.bindUntilEvent(provider: LifecycleProvider<E>, event: E): Maybe<T>\n    = this.compose(provider.bindUntilEvent<T>(event))\n\nfun <T> Maybe<T>.bindToLifecycle(view: View): Maybe<T>\n    = this.compose(RxLifecycleAndroid.bindView<T>(view))\n\nfun <E> Completable.bindToLifecycle(provider: LifecycleProvider<E>): Completable\n    = this.compose(provider.bindToLifecycle<Completable>())\n\nfun <E> Completable.bindUntilEvent(provider: LifecycleProvider<E>, event: E): Completable\n    = this.compose(provider.bindUntilEvent<Completable>(event))\n\nfun Completable.bindToLifecycle(view: View): Completable\n    = this.compose(RxLifecycleAndroid.bindView<Completable>(view))\n"
  },
  {
    "path": "rxlifecycle-sample/build.gradle",
    "content": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\napply plugin: 'kotlin-android-extensions'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n\n    defaultConfig {\n        applicationId \"com.trello.rxlifecycle4.sample\"\n        minSdkVersion rootProject.ext.minSdkVersion\n\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n    }\n\n    sourceSets {\n        main.java.srcDirs += 'src/main/kotlin'\n    }\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n}\n\nrepositories {\n    mavenCentral()\n    google()\n    jcenter()\n}\n\ndependencies {\n    implementation project(':rxlifecycle-components')\n    implementation project(':rxlifecycle-kotlin')\n\n    implementation rootProject.ext.appCompat\n\n    implementation rootProject.ext.kotlinStdlib\n}"
  },
  {
    "path": "rxlifecycle-sample/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n    package=\"com.trello.rxlifecycle4.sample\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    >\n\n    <application\n        android:fullBackupContent=\"false\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:theme=\"@style/Theme.AppCompat.Light.DarkActionBar\"\n        >\n        <activity\n            android:name=\"com.trello.rxlifecycle4.sample.MainActivity\"\n            android:label=\"@string/app_name\"\n            >\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n\n        <activity\n            android:name=\"com.trello.rxlifecycle4.sample.KotlinActivity\"\n            android:label=\"@string/app_name_kotlin\"\n            >\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "rxlifecycle-sample/src/main/java/com/trello/rxlifecycle4/sample/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 */\n\npackage com.trello.rxlifecycle4.sample;\n\nimport android.os.Bundle;\nimport android.util.Log;\n\nimport com.trello.rxlifecycle4.android.ActivityEvent;\nimport com.trello.rxlifecycle4.components.support.RxAppCompatActivity;\n\nimport java.util.concurrent.TimeUnit;\n\nimport io.reactivex.rxjava3.core.Observable;\nimport io.reactivex.rxjava3.functions.Action;\nimport io.reactivex.rxjava3.functions.Consumer;\n\npublic class MainActivity extends RxAppCompatActivity {\n\n    private static final String TAG = \"RxLifecycleAndroid\";\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        Log.d(TAG, \"onCreate()\");\n\n        setContentView(R.layout.activity_main);\n\n        // Specifically bind this until onPause()\n        Observable.interval(1, TimeUnit.SECONDS)\n            .doOnDispose(new Action() {\n                @Override\n                public void run() throws Exception {\n                    Log.i(TAG, \"Unsubscribing subscription from onCreate()\");\n                }\n            })\n            .compose(this.<Long>bindUntilEvent(ActivityEvent.PAUSE))\n            .subscribe(new Consumer<Long>() {\n                @Override\n                public void accept(Long num) throws Exception {\n                    Log.i(TAG, \"Started in onCreate(), running until onPause(): \" + num);\n                }\n            });\n    }\n\n    @Override\n    protected void onStart() {\n        super.onStart();\n\n        Log.d(TAG, \"onStart()\");\n\n        // Using automatic unsubscription, this should determine that the correct time to\n        // unsubscribe is onStop (the opposite of onStart).\n        Observable.interval(1, TimeUnit.SECONDS)\n            .doOnDispose(new Action() {\n                @Override\n                public void run() throws Exception {\n                    Log.i(TAG, \"Unsubscribing subscription from onStart()\");\n                }\n            })\n            .compose(this.<Long>bindToLifecycle())\n            .subscribe(new Consumer<Long>() {\n                @Override\n                public void accept(Long num) throws Exception {\n                    Log.i(TAG, \"Started in onStart(), running until in onStop(): \" + num);\n                }\n            });\n    }\n\n    @Override\n    protected void onResume() {\n        super.onResume();\n\n        Log.d(TAG, \"onResume()\");\n\n        // `this.<Long>` is necessary if you're compiling on JDK7 or below.\n        //\n        // If you're using JDK8+, then you can safely remove it.\n        Observable.interval(1, TimeUnit.SECONDS)\n            .doOnDispose(new Action() {\n                @Override\n                public void run() throws Exception {\n                    Log.i(TAG, \"Unsubscribing subscription from onResume()\");\n                }\n            })\n            .compose(this.<Long>bindUntilEvent(ActivityEvent.DESTROY))\n            .subscribe(new Consumer<Long>() {\n                @Override\n                public void accept(Long num) throws Exception {\n                    Log.i(TAG, \"Started in onResume(), running until in onDestroy(): \" + num);\n                }\n            });\n    }\n\n    @Override\n    protected void onPause() {\n        super.onPause();\n\n        Log.d(TAG, \"onPause()\");\n    }\n\n    @Override\n    protected void onStop() {\n        super.onStop();\n\n        Log.d(TAG, \"onStop()\");\n    }\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n\n        Log.d(TAG, \"onDestroy()\");\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-sample/src/main/kotlin/com/trello/rxlifecycle4/sample/KotlinActivity.kt",
    "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 */\n\npackage com.trello.rxlifecycle4.sample\n\nimport android.os.Bundle\nimport android.util.Log\nimport com.trello.rxlifecycle4.android.ActivityEvent\nimport com.trello.rxlifecycle4.components.support.RxAppCompatActivity\nimport com.trello.rxlifecycle4.kotlin.bindToLifecycle\nimport com.trello.rxlifecycle4.kotlin.bindUntilEvent\nimport io.reactivex.rxjava3.core.Observable\nimport java.util.concurrent.TimeUnit\n\nclass KotlinActivity : RxAppCompatActivity() {\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n\n        Log.d(TAG, \"onCreate()\")\n\n        setContentView(R.layout.activity_main)\n\n        // Specifically bind this until onPause()\n        Observable.interval(1, TimeUnit.SECONDS)\n                .doOnDispose { Log.i(TAG, \"Unsubscribing subscription from onCreate()\") }\n                .bindUntilEvent(this, ActivityEvent.PAUSE)\n                .subscribe { num -> Log.i(TAG, \"Started in onCreate(), running until onPause(): \" + num) }\n    }\n\n    override fun onStart() {\n        super.onStart()\n\n        Log.d(TAG, \"onStart()\")\n\n        // Using automatic unsubscription, this should determine that the correct time to\n        // unsubscribe is onStop (the opposite of onStart).\n        Observable.interval(1, TimeUnit.SECONDS)\n                .doOnDispose { Log.i(TAG, \"Unsubscribing subscription from onStart()\") }\n                .bindToLifecycle(this)\n                .subscribe { num -> Log.i(TAG, \"Started in onStart(), running until in onStop(): \" + num) }\n    }\n\n    override fun onResume() {\n        super.onResume()\n\n        Log.d(TAG, \"onResume()\")\n\n        Observable.interval(1, TimeUnit.SECONDS)\n                .doOnDispose { Log.i(TAG, \"Unsubscribing subscription from onResume()\") }\n                .bindUntilEvent(this, ActivityEvent.DESTROY)\n                .subscribe { num -> Log.i(TAG, \"Started in onResume(), running until in onDestroy(): \" + num) }\n    }\n\n    override fun onPause() {\n        super.onPause()\n\n        Log.d(TAG, \"onPause()\")\n    }\n\n    override fun onStop() {\n        super.onStop()\n\n        Log.d(TAG, \"onStop()\")\n    }\n\n    override fun onDestroy() {\n        super.onDestroy()\n\n        Log.d(TAG, \"onDestroy()\")\n    }\n\n    companion object {\n        private val TAG = \"RxLifecycle-Kotlin\"\n    }\n}\n"
  },
  {
    "path": "rxlifecycle-sample/src/main/res/layout/activity_main.xml",
    "content": "<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n             xmlns:tools=\"http://schemas.android.com/tools\"\n             android:layout_width=\"match_parent\"\n             android:layout_height=\"match_parent\"\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             tools:context=\".MainActivity\"\n    >\n\n    <TextView\n        android:layout_width=\"wrap_content\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/message\"\n        />\n\n</FrameLayout>\n"
  },
  {
    "path": "rxlifecycle-sample/src/main/res/values/dimens.xml",
    "content": "<resources>\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n</resources>\n"
  },
  {
    "path": "rxlifecycle-sample/src/main/res/values/strings.xml",
    "content": "<resources>\n    <string name=\"app_name\">RxLifecycle</string>\n    <string name=\"app_name_kotlin\">RxLifecycle (Kotlin)</string>\n\n    <string name=\"message\">Check logcat tag \"RxLifecycle\" to see this sample in action. You\\'ll need to finish\n        the Activity (or recreate it) to see the automatic unsubscription in action.</string>\n</resources>\n"
  },
  {
    "path": "settings.gradle",
    "content": "include ':rxlifecycle'\ninclude ':rxlifecycle-android'\ninclude ':rxlifecycle-android-lifecycle'\ninclude ':rxlifecycle-android-lifecycle-kotlin'\ninclude ':rxlifecycle-components'\ninclude ':rxlifecycle-components-preference'\ninclude ':rxlifecycle-kotlin'\ninclude ':rxlifecycle-sample'"
  }
]