[
  {
    "path": ".gitignore",
    "content": "# Windows thumbnail db\nThumbs.db\n\n# OSX files\n.DS_Store\n\n# built application files\n*.apk\n*.ap_\n\n# files for the dex VM\n*.dex\n  \n# Java class files\n*.class\n  \n# generated files\nbin/\ngen/\nbuild/\n  \n# Local configuration file (sdk path, etc)\nlocal.properties\n  \n# Eclipse project files\n.classpath\n.project\n  \n# Android Studio\n.idea\n.gradle\n/*/local.properties\n/*/out\n/*/*/build\nbuild\n/*/*/production\n*.iml\n*.iws\n*.ipr\n*~\n*.swp\n"
  },
  {
    "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": "Android-ReactiveProgramming\n===========================\n\nThis is a sample app that is part of a serie of blog posts I will be writting about experience with Reactive Programming on Android.\n\n[1 - Blog post: RxJava Observable tranformation: concatMap() vs flatMap()](http://fernandocejas.com/2015/01/11/rxjava-observable-tranformation-concatmap-vs-flatmap/)\n\n\nLocal Development\n-----------------\n\nHere are some useful Gradle/adb commands for executing this example:\n\n * `gradlew clean build` - Build the entire example.\n * `gradlew installDebug` - Install the debug apk in the current connected device.\n\n\nLicense\n--------\n\n    Copyright 2015 Fernando Cejas\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n\n![http://www.fernandocejas.com](https://github.com/android10/Sample-Data/blob/master/android10/android10_logo_big.png)\n\n<a href=\"https://www.buymeacoffee.com/android10\" target=\"_blank\"><img src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: auto !important;width: auto !important;\" ></a>\n"
  },
  {
    "path": "app/build.gradle",
    "content": "apply plugin: 'com.android.application'\napply plugin: 'me.tatarka.retrolambda'\n\nandroid {\n  compileSdkVersion 25\n  buildToolsVersion \"23.0.3\"\n\n  defaultConfig {\n    applicationId \"com.fernandocejas.android10.rx.sample\"\n    minSdkVersion 15\n    targetSdkVersion 21\n    versionCode 1\n    versionName \"1.0\"\n  }\n\n  compileOptions {\n    sourceCompatibility JavaVersion.VERSION_1_8\n    targetCompatibility JavaVersion.VERSION_1_8\n  }\n\n  packagingOptions {\n    exclude 'LICENSE.txt'\n    exclude 'META-INF/DEPENDENCIES'\n    exclude 'META-INF/ASL2.0'\n    exclude 'META-INF/NOTICE'\n    exclude 'META-INF/LICENSE'\n    exclude 'META-INF/LICENSE.txt'\n  }\n\n  lintOptions {\n    quiet true\n    abortOnError false;\n    ignoreWarnings true\n    disable 'InvalidPackage'  // Some libraries have issues with this.\n    disable 'OldTargetApi'    // Lint gives this warning but SDK 20 would be Android L Beta.\n    disable 'IconDensities'   // For testing purpose. This is safe to remove.\n  }\n\n  buildTypes {\n    release {\n      minifyEnabled false\n      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n    }\n  }\n}\n\ndependencies {\n  compile 'com.android.support:recyclerview-v7:25.0.1'\n  compile 'com.jakewharton:butterknife:7.0.1'\n  compile 'com.squareup.okhttp:okhttp:2.5.0'\n  compile 'com.fernandocejas:arrow:1.0.0'\n  compile 'io.reactivex.rxjava2:rxjava:2.0.2'\n  compile 'io.reactivex.rxjava2:rxandroid:2.0.1'\n}\n\n"
  },
  {
    "path": "app/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 /Users/fernandocejas/Software/SDKs/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"
  },
  {
    "path": "app/src/androidTest/java/com/fernandocejas/android10/rx/sample/ApplicationTest.java",
    "content": "package com.fernandocejas.android10.rx.sample;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n  public ApplicationTest() {\n    super(Application.class);\n  }\n}"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n    package=\"com.fernandocejas.android10.rx.sample\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n  <application\n      android:allowBackup=\"true\"\n      android:icon=\"@drawable/ic_launcher\"\n      android:name=\".AndroidApplication\"\n      android:label=\"@string/app_name\"\n      android:theme=\"@style/AppTheme\">\n    <activity\n        android:name=\".activity.MainActivity\"\n        android:label=\"@string/app_name\">\n      <intent-filter>\n        <action android:name=\"android.intent.action.MAIN\" />\n        <category android:name=\"android.intent.category.LAUNCHER\" />\n      </intent-filter>\n    </activity>\n\n    <activity\n        android:name=\".activity.ActivitySubscriberSample\"\n        android:label=\"@string/app_sample_observer\" />\n\n    <activity\n        android:name=\".activity.ActivityObservableCompositionSamples\"\n        android:label=\"@string/app_sample_observable_composition\" />\n\n    <activity\n        android:name=\".activity.backpressure.ActivityBackpressureSamples\"\n        android:label=\"@string/app_sample_backpressure\" />\n\n    <activity\n        android:name=\".activity.ActivityObservableConcatVsFlatMapSample\"\n        android:label=\"@string/app_sample_observable_composition_concat_vs_flat_map\" />\n\n  </application>\n\n</manifest>\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/AndroidApplication.java",
    "content": "/**\n * Copyright (C) 2016 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample;\n\nimport android.app.Application;\nimport android.widget.Toast;\nimport com.fernandocejas.arrow.annotations.Issue;\n\npublic class AndroidApplication extends Application {\n\n  @Override public void onCreate() {\n    super.onCreate();\n    setupRxRingBufferSize();\n  }\n\n  @Issue(ref = \"https://github.com/ReactiveX/RxJava/issues/1820\")\n  private void setupRxRingBufferSize() {\n    //Default on Android is 16 for performance reasons\n    //This is a hack and should not be used it, it is for learning purpose\n    final String rxBufferSizeProperty = \"rx.ring-buffer.size\";\n    final String rxBufferSizeValue = \"16\";\n    System.setProperty(rxBufferSizeProperty, rxBufferSizeValue);\n    Toast.makeText(this, rxBufferSizeProperty + \"=\" + rxBufferSizeValue, Toast.LENGTH_SHORT).show();\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/ActivityObservableCompositionSamples.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.activity;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\nimport com.fernandocejas.android10.rx.sample.R;\nimport com.fernandocejas.android10.rx.sample.navigation.Navigator;\n\npublic class ActivityObservableCompositionSamples extends BaseActivity {\n\n  public static Intent getCallingIntent(Context context) {\n    return new Intent(context, ActivityObservableCompositionSamples.class);\n  }\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_samples_observable_composition);\n    ButterKnife.bind(this);\n    initialize();\n  }\n\n  private void initialize() {\n    navigator = new Navigator();\n  }\n\n  @OnClick(R.id.btn_sampleConcatVsFlatMap) void navigateToObservableConcatVsFlatMap() {\n    navigator.navigateToObservableConcatVsFlatMap(this);\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/ActivityObservableConcatVsFlatMapSample.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\n * <p>\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 * <p>\n * http://www.apache.org/licenses/LICENSE-2.0\n * <p>\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.fernandocejas.android10.rx.sample.activity;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.util.Log;\nimport android.widget.TextView;\nimport android.widget.Toast;\nimport butterknife.Bind;\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\nimport com.fernandocejas.android10.rx.sample.R;\nimport com.fernandocejas.android10.rx.sample.data.DataManager;\nimport com.fernandocejas.android10.rx.sample.data.NumberGenerator;\nimport com.fernandocejas.android10.rx.sample.data.StringGenerator;\nimport com.fernandocejas.android10.rx.sample.executor.JobExecutor;\nimport com.fernandocejas.arrow.annotations.See;\nimport io.reactivex.Observable;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.disposables.CompositeDisposable;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.observers.DisposableObserver;\n\n@See(ref = \"http://fernandocejas.com/2015/01/11/rxjava-observable-tranformation-concatmap-vs-flatmap/\")\npublic class ActivityObservableConcatVsFlatMapSample extends BaseActivity {\n\n  private static final String LOG_TAG = \"ConcatVsFlatMap\";\n  private static final String SEPARATOR = \" \";\n\n  @Bind(R.id.tv_streamOriginalOrder) TextView tv_streamOriginalOrder;\n  @Bind(R.id.tv_flatMapResult) TextView tv_flatMapResult;\n  @Bind(R.id.tv_concatMapResult) TextView tv_concatMapResult;\n\n  private DataManager dataManager;\n  private CompositeDisposable disposables;\n\n  public static Intent getCallingIntent(Context context) {\n    return new Intent(context, ActivityObservableConcatVsFlatMapSample.class);\n  }\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_sample_observervable_composition_flat_vs_concat);\n\n    ButterKnife.bind(this);\n    initialize();\n    populateData();\n  }\n\n  @Override\n  protected void onDestroy() {\n    disposables.dispose();\n    super.onDestroy();\n  }\n\n  private void initialize() {\n    dataManager = new DataManager(new StringGenerator(), new NumberGenerator(), JobExecutor.getInstance());\n    disposables = new CompositeDisposable();\n  }\n\n  @OnClick(R.id.btn_flatMap)\n  void onFlatMapClick() {\n    final DisposableObserver<Integer> observer = new DisposableObserver<Integer>() {\n      final StringBuilder stringBuilder = new StringBuilder(40);\n\n      @Override\n      public void onNext(Integer number) {\n        stringBuilder.append(number);\n        stringBuilder.append(SEPARATOR);\n        debugLog(\"onFlatMapClick() ------>>>> \" + number);\n      }\n\n      @Override\n      public void onComplete() {\n        stringBuilder.append(\"Complete!\");\n        printFlatMapResult(stringBuilder.toString());\n        showToast(\"flatMap() Sequence Completed!!!\");\n      }\n\n      @Override\n      public void onError(Throwable e) {\n        // handle the exception\n      }\n    };\n\n    final Observable<Integer> observable = buildNumbersObservable()\n        .flatMap(dataManager::squareOfAsync)\n        .observeOn(AndroidSchedulers.mainThread());\n    addDisposable(observable.subscribeWith(observer));\n  }\n\n  @OnClick(R.id.btn_concatMap)\n  void onConcatMapClick() {\n    final DisposableObserver<Integer> observer = new DisposableObserver<Integer>() {\n      final StringBuilder stringBuilder = new StringBuilder(40);\n\n      @Override\n      public void onNext(Integer number) {\n        stringBuilder.append(number);\n        stringBuilder.append(SEPARATOR);\n        debugLog(\"onConcatMapClick() ------>>>> \" + number);\n      }\n\n      @Override\n      public void onComplete() {\n        stringBuilder.append(\"Complete!\");\n        printConcatMapResult(stringBuilder.toString());\n        showToast(\"concatMap() Sequence Completed!!!\");\n      }\n\n      @Override\n      public void onError(Throwable e) {\n        // handle the exception\n      }\n    };\n\n    final Observable<Integer> observable = buildNumbersObservable()\n        .concatMap(dataManager::squareOfAsync)\n        .observeOn(AndroidSchedulers.mainThread());\n    addDisposable(observable.subscribeWith(observer));\n  }\n\n  private Observable<Integer> buildNumbersObservable() {\n    return dataManager.numbers();\n  }\n\n  private void showToast(String message) {\n    Toast.makeText(this, message, Toast.LENGTH_SHORT).show();\n  }\n\n  private void debugLog(String message) {\n    Log.d(LOG_TAG, message);\n  }\n\n  private void printFlatMapResult(String result) {\n    tv_flatMapResult.setText(result);\n  }\n\n  private void printConcatMapResult(String result) {\n    tv_concatMapResult.setText(result);\n  }\n\n  private void populateData() {\n    StringBuilder stringBuilder = new StringBuilder(15);\n    for (int number : dataManager.getNumbersSynchronously()) {\n      stringBuilder.append(number);\n      stringBuilder.append(SEPARATOR);\n    }\n    this.tv_streamOriginalOrder.setText(stringBuilder.toString());\n  }\n\n  private void addDisposable(Disposable disposable) {\n    disposables.add(disposable);\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/ActivitySubscriberSample.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\n * <p>\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 * <p>\n * http://www.apache.org/licenses/LICENSE-2.0\n * <p>\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.fernandocejas.android10.rx.sample.activity;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v7.widget.LinearLayoutManager;\nimport android.support.v7.widget.RecyclerView;\nimport android.widget.Toast;\nimport butterknife.Bind;\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\nimport com.fernandocejas.android10.rx.sample.R;\nimport com.fernandocejas.android10.rx.sample.adapter.ElementsAdapter;\nimport com.fernandocejas.android10.rx.sample.data.DataManager;\nimport com.fernandocejas.android10.rx.sample.data.NumberGenerator;\nimport com.fernandocejas.android10.rx.sample.data.StringGenerator;\nimport com.fernandocejas.android10.rx.sample.executor.JobExecutor;\n\npublic class ActivitySubscriberSample extends BaseActivity\n    implements ElementsAdapter.ElementAddedListener {\n\n  @Bind(android.R.id.list) RecyclerView rv_elements;\n\n  private DataManager dataManager;\n  private ElementsAdapter adapter;\n\n  public static Intent getCallingIntent(Context context) {\n    return new Intent(context, ActivitySubscriberSample.class);\n  }\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_sample_subscriber);\n\n    ButterKnife.bind(this);\n    initialize();\n    fillData();\n  }\n\n  @Override\n  protected void onDestroy() {\n    adapter.dispose();\n    super.onDestroy();\n  }\n\n  private void initialize() {\n    dataManager =\n        new DataManager(new StringGenerator(), new NumberGenerator(), JobExecutor.getInstance());\n    adapter = new ElementsAdapter(this, this);\n    rv_elements.setLayoutManager(new LinearLayoutManager(this));\n    rv_elements.setAdapter(this.adapter);\n  }\n\n  private void fillData() {\n    this.dataManager.elements().subscribe(this.adapter);\n  }\n\n  @OnClick(android.R.id.button1) void onAddElementClick() {\n    this.dataManager.newElement().subscribe(this.adapter);\n    Toast.makeText(this, \"Element added using an observable!!!\", Toast.LENGTH_SHORT).show();\n  }\n\n  @Override\n  public void onElementAdded() {\n    rv_elements.smoothScrollToPosition(adapter.getItemCount());\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/BaseActivity.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.activity;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport com.fernandocejas.android10.rx.sample.navigation.Navigator;\n\npublic abstract class BaseActivity extends Activity {\n  Navigator navigator;\n\n  @Override protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    initialize();\n  }\n\n  private void initialize() {\n    this.navigator = new Navigator();\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/MainActivity.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.activity;\n\nimport android.os.Bundle;\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\nimport com.fernandocejas.android10.rx.sample.R;\n\npublic class MainActivity extends BaseActivity {\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    setContentView(R.layout.activity_main);\n    ButterKnife.bind(this);\n  }\n\n  @OnClick(R.id.btn_sampleObserver) void navigateToObserverSample() {\n    navigator.navigateToSubscriberSample(this);\n  }\n\n  @OnClick(R.id.btn_sampleBackpressure) void navigateToBackpressureSample() {\n    navigator.navigateToBackpressureSamples(this);\n  }\n\n  @OnClick(R.id.btn_sampleObservableComposition) void navigateToObservableCompositionSamples() {\n    navigator.navigateToObservableCompositionSamples(this);\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/backpressure/ActivityBackpressureSamples.java",
    "content": "/**\n * Copyright (C) 2016 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.activity.backpressure;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport android.content.res.ColorStateList;\nimport android.graphics.Color;\nimport android.os.Bundle;\nimport android.view.Window;\nimport android.widget.ScrollView;\nimport android.widget.TextView;\nimport butterknife.Bind;\nimport butterknife.ButterKnife;\nimport butterknife.OnClick;\nimport com.fernandocejas.android10.rx.sample.R;\nimport com.fernandocejas.android10.rx.sample.activity.BaseActivity;\nimport com.fernandocejas.android10.rx.sample.data.DataManager;\nimport com.fernandocejas.android10.rx.sample.data.NumberGenerator;\nimport com.fernandocejas.android10.rx.sample.data.StringGenerator;\nimport com.fernandocejas.android10.rx.sample.executor.JobExecutor;\nimport com.fernandocejas.arrow.strings.Strings;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.disposables.CompositeDisposable;\nimport io.reactivex.schedulers.Schedulers;\nimport java.util.concurrent.TimeUnit;\n\npublic class ActivityBackpressureSamples extends BaseActivity implements\n    BackpressureSubscriber.BackPressureResultListener {\n\n  @Bind(R.id.sv_container) ScrollView sv_container;\n  @Bind(R.id.tv_sampleDescription) TextView tv_sampleDescription;\n  @Bind(R.id.tv_itemsRequested) TextView tv_itemsRequested;\n  @Bind(R.id.tv_itemsProcessed) TextView tv_itemsProcessed;\n  @Bind(R.id.tv_itemsEmitted) TextView tv_itemsEmitted;\n  @Bind(R.id.tv_result) TextView tv_result;\n\n  private CompositeDisposable disposables;\n  private DataManager dataManager;\n\n  public static Intent getCallingIntent(Context context) {\n    return new Intent(context, ActivityBackpressureSamples.class);\n  }\n\n  @Override\n  protected void onCreate(Bundle savedInstanceState) {\n    super.onCreate(savedInstanceState);\n    initialize();\n  }\n\n  @Override\n  protected void onDestroy() {\n    disposables.dispose();\n    super.onDestroy();\n  }\n\n  private void initialize() {\n    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);\n    setContentView(R.layout.activity_samples_backpressure);\n\n    ButterKnife.bind(this);\n    clearUpUI();\n\n    dataManager = new DataManager(new StringGenerator(),\n        new NumberGenerator(), JobExecutor.getInstance());\n    disposables = new CompositeDisposable();\n  }\n\n  private void clearUpUI() {\n    tv_sampleDescription.setText(Strings.EMPTY);\n    tv_itemsRequested.setText(Strings.EMPTY);\n    tv_itemsProcessed.setText(Strings.EMPTY);\n    tv_itemsEmitted.setText(Strings.EMPTY);\n    tv_result.setText(Strings.EMPTY);\n  }\n\n  private void toggleProgressBar(boolean visible) {\n    setProgressBarIndeterminateVisibility(visible);\n  }\n\n  @OnClick(R.id.btn_backpressureException) void onBackpressureExceptionClick() {\n    dataManager.milliseconds(100)\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribeOn(Schedulers.computation())\n        .subscribe(new BackpressureSubscriber<>(this, getString(R.string.btn_text_backpressure_exception), 15));\n  }\n\n  @OnClick(R.id.btn_backpressureDrop) void onBackpressureDropClick() {\n    dataManager.milliseconds(1000)\n        .onBackpressureDrop()\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribeOn(Schedulers.computation())\n        .subscribe(new BackpressureSubscriber<>(this, getString(R.string.btn_text_backpressure_drop)));\n  }\n\n  @OnClick(R.id.btn_backpressureBuffer) void onBackpressureBuffer() {\n    dataManager.milliseconds(600)\n        .onBackpressureBuffer(200)\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribeOn(Schedulers.computation())\n        .subscribe(new BackpressureSubscriber<>(this, getString(R.string.btn_text_backpressure_buffer)));\n  }\n\n  @OnClick(R.id.btn_backpressureWindow) void onBackpressureWindow() {\n    dataManager.milliseconds(1000)\n        .window(5)\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribeOn(Schedulers.computation())\n        .subscribe(new BackpressureSubscriber<>(this, getString(R.string.btn_text_backpressure_window)));\n  }\n\n  @OnClick(R.id.btn_backpressureToList) void onBackpressureToList() {\n    dataManager.milliseconds(1000)\n        .toList()\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribeOn(Schedulers.computation());\n        //.subscribe(new BackpressureSubscriber<>(this, getString(R.string.btn_text_backpressure_toList)));\n  }\n\n  @OnClick(R.id.btn_backpressureThrottleLast) void onBackpressureThrottleLast() {\n    dataManager.milliseconds(10000)\n        .throttleLast(10, TimeUnit.MILLISECONDS)\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribeOn(Schedulers.computation());\n        //.subscribe(new BackpressureSubscriber<>(this, getString(R.string.btn_text_backpressure_throttleLast)));\n  }\n\n  @Override\n  public void onOperationStart(String name, long itemsRequested) {\n    clearUpUI();\n    toggleProgressBar(true);\n    sv_container.fullScroll(ScrollView.FOCUS_DOWN);\n    tv_sampleDescription.setText(name);\n    if (itemsRequested != Long.MAX_VALUE) {\n      tv_itemsRequested.setText(String.valueOf(itemsRequested));\n    } else {\n      tv_itemsRequested.setText(\"Flowable emitting at its own pace\");\n    }\n  }\n\n  @Override public void onOperationProgress(long itemsProcessedSoFar) {\n    tv_itemsProcessed.setText(String.valueOf(itemsProcessedSoFar));\n  }\n\n  @Override\n  public void onOperationResult(long itemsEmitted, OperationResult operation) {\n    tv_itemsEmitted.setText(String.valueOf(itemsEmitted));\n    switch (operation.result()) {\n      case SUCCESS:\n        tv_result.setText(getString(R.string.string_success));\n        tv_result.setTextColor(ColorStateList.valueOf(Color.BLUE));\n        break;\n      case FAILURE:\n        String failureMessage;\n        if (operation.throwable().isPresent()) {\n          failureMessage = String.format(getString(R.string.string_failure),\n              operation.throwable().get().toString());\n        } else {\n          failureMessage = getString(R.string.string_failure);\n        }\n        tv_result.setText(failureMessage);\n        tv_result.setTextColor(ColorStateList.valueOf(Color.RED));\n        break;\n      default:\n        tv_result.setText(Strings.EMPTY);\n    }\n    toggleProgressBar(false);\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/backpressure/BackpressureSubscriber.java",
    "content": "/**\n * Copyright (C) 2016 android10.org Open Source Project\n * <p>\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 * <p>\n * http://www.apache.org/licenses/LICENSE-2.0\n * <p>\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.fernandocejas.android10.rx.sample.activity.backpressure;\n\nimport io.reactivex.subscribers.DisposableSubscriber;\nimport java.lang.ref.WeakReference;\n\nclass BackpressureSubscriber<T> extends DisposableSubscriber<T> {\n\n  interface BackPressureResultListener {\n    void onOperationStart(String name, long itemsRequested);\n\n    void onOperationProgress(long itemsProcessedSoFar);\n\n    void onOperationResult(long itemsEmitted, OperationResult operation);\n  }\n\n  private final WeakReference<BackPressureResultListener> backPressureListener;\n  private final String name;\n  private final long itemsRequested;\n  private boolean shouldRequestItem;\n\n  private long itemsEmitted = 0;\n  private long itemsRequestedProcessed = 0;\n\n  BackpressureSubscriber(BackPressureResultListener listener, String name) {\n    this(listener, name, Long.MAX_VALUE);\n  }\n\n  BackpressureSubscriber(BackPressureResultListener listener, String name, long requestedItems) {\n    this.backPressureListener = new WeakReference<>(listener);\n    this.name = name;\n    this.itemsRequested = requestedItems;\n    this.shouldRequestItem = requestedItems != Long.MAX_VALUE;\n  }\n\n  @Override\n  public void onStart() {\n    if (shouldRequestItem) {\n      request(itemsRequested);\n    }\n    sendStartData();\n  }\n\n  @Override\n  public void onNext(T item) {\n    itemsEmitted++;\n    sendProgressData(itemsEmitted);\n    requestMoreItems();\n  }\n\n  @Override\n  public void onComplete() {\n    sendResultData(OperationResult.success());\n  }\n\n  @Override\n  public void onError(Throwable throwable) {\n    //if (throwable instanceof MissingBackpressureException) {\n    //    sendResultData(OperationResult.failure(throwable));\n    //}\n  }\n\n  private void requestMoreItems() {\n    itemsRequestedProcessed++;\n    if (shouldRequestItem && itemsRequestedProcessed >= itemsRequested) {\n      request(itemsRequested);\n      itemsRequestedProcessed = 0;\n    }\n  }\n\n  private void sendStartData() {\n    if (backPressureListener.get() != null) {\n      backPressureListener.get().onOperationStart(name, itemsRequested);\n    }\n  }\n\n  private void sendProgressData(long itemsProcessedSoFar) {\n    if (backPressureListener.get() != null) {\n      backPressureListener.get().onOperationProgress(itemsProcessedSoFar);\n    }\n  }\n\n  private void sendResultData(OperationResult operation) {\n    if (backPressureListener.get() != null) {\n      backPressureListener.get().onOperationResult(itemsEmitted, operation);\n    }\n  }\n\n  //    private static class BackPressureProducer<T> implements Producer {\n  //        private final Subscriber<T> subscriber;\n  //\n  //        BackPressureProducer(Subscriber subscriber) {\n  //            this.subscriber = subscriber;\n  //        }\n  //\n  //        @Override\n  //        public void request(long requested) {\n  //            for (int i = 0; i < requested && !subscriber.isUnsubscribed(); i++) {\n  ////                subscriber.onNext(T);\n  //            }\n  //        }\n  //    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/activity/backpressure/OperationResult.java",
    "content": "/**\n * Copyright (C) 2016 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.activity.backpressure;\n\nimport com.fernandocejas.arrow.optional.Optional;\n\nclass OperationResult {\n  enum Result {\n    SUCCESS,\n    FAILURE\n  }\n  private final Optional<Throwable> throwable;\n  private final Result result;\n\n  private OperationResult(Throwable throwable, Result result) {\n    this.throwable = Optional.fromNullable(throwable);\n    this.result = result;\n  }\n\n  static OperationResult success() {\n    return new OperationResult(null, Result.SUCCESS);\n  }\n\n  static OperationResult failure(Throwable throwable) {\n    return new OperationResult(throwable, Result.FAILURE);\n  }\n\n  Optional<Throwable> throwable() {\n    return throwable;\n  }\n\n  Result result() {\n    return result;\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/adapter/ElementsAdapter.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.adapter;\n\nimport android.content.Context;\nimport android.support.v7.widget.RecyclerView;\nimport android.util.Log;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.widget.TextView;\nimport butterknife.Bind;\nimport butterknife.ButterKnife;\nimport com.fernandocejas.android10.rx.sample.R;\nimport io.reactivex.Observer;\nimport io.reactivex.disposables.Disposable;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class ElementsAdapter extends RecyclerView.Adapter<ElementsAdapter.ElementViewHolder>\n    implements Observer<String> {\n\n  public interface ElementAddedListener {\n    void onElementAdded();\n  }\n\n  private static final String LOG_TAG = \"ElementsAdapter\";\n\n  private final List<String> elements;\n  private final LayoutInflater layoutInflater;\n  private final ElementAddedListener listener;\n\n  private Disposable disposable;\n\n  public ElementsAdapter(Context context, ElementAddedListener listener) {\n    if (listener == null) {\n      throw new IllegalArgumentException(\"Listener cannot be null\");\n    }\n    this.elements = new ArrayList<>();\n    this.layoutInflater =\n        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);\n    this.listener = listener;\n  }\n\n  @Override public ElementViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {\n    final View view = layoutInflater.inflate(R.layout.row_element, parent, false);\n    return new ElementViewHolder(view);\n  }\n\n  @Override public void onBindViewHolder(ElementViewHolder holder, int position) {\n    final String element = elements.get(position);\n    holder.textViewText.setText(element);\n  }\n\n  @Override public int getItemCount() {\n    return elements.size();\n  }\n\n  @Override public void onSubscribe(Disposable disposable) {\n    this.disposable = disposable;\n  }\n\n  @Override public void onNext(String stringElement) {\n    elements.add(stringElement);\n  }\n\n  @Override public void onComplete() {\n    notifyDataSetChanged();\n    listener.onElementAdded();\n  }\n\n  @Override public void onError(Throwable e) {\n    Log.e(LOG_TAG, e.getMessage());\n  }\n\n  public void dispose() {\n    if (disposable != null && !disposable.isDisposed()) disposable.dispose();\n  }\n\n  static class ElementViewHolder extends RecyclerView.ViewHolder {\n    @Bind(R.id.title) TextView textViewText;\n\n    ElementViewHolder(View itemView) {\n      super(itemView);\n      ButterKnife.bind(this, itemView);\n    }\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/data/DataManager.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\n * <p>\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 * <p>\n * http://www.apache.org/licenses/LICENSE-2.0\n * <p>\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.fernandocejas.android10.rx.sample.data;\n\nimport io.reactivex.Flowable;\nimport io.reactivex.Observable;\nimport io.reactivex.schedulers.Schedulers;\n\nimport java.util.List;\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.TimeUnit;\n\npublic class DataManager {\n\n    private final StringGenerator stringGenerator;\n    private final NumberGenerator numberGenerator;\n    private final Executor jobExecutor;\n\n    public DataManager(StringGenerator stringGenerator,\n                       NumberGenerator numberGenerator, Executor jobExecutor) {\n        this.stringGenerator = stringGenerator;\n        this.numberGenerator = numberGenerator;\n        this.jobExecutor = jobExecutor;\n    }\n\n    public Observable<Integer> numbers() {\n        return Observable.fromIterable(numberGenerator.numbers());\n    }\n\n    public Observable<Long> numbers(int upUntil) {\n        return Observable.fromIterable(numberGenerator.numbers(upUntil));\n    }\n\n    public Flowable<Long> milliseconds(int upUntil) {\n        return Flowable.interval(0, 1, TimeUnit.MILLISECONDS).take(upUntil);\n    }\n\n    public Observable<Integer> squareOfAsync(int number) {\n        return Observable.just(number * number).subscribeOn(Schedulers.from(jobExecutor));\n    }\n\n    public Observable<String> elements() {\n        return Observable.fromIterable(stringGenerator.randomStringList());\n    }\n\n    public Observable<String> newElement() {\n        return Observable\n                .just(stringGenerator.nextString())\n                .map((string -> \"RandomItem\" + string));\n    }\n\n    public List<Integer> getNumbersSynchronously() {\n        return numberGenerator.numbers();\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/data/NumberGenerator.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.data;\n\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.List;\n\npublic class NumberGenerator {\n\n  public NumberGenerator() {}\n\n  List<Integer> numbers() {\n    return new ArrayList<>(Arrays.asList(2, 3, 4, 5, 6, 7, 8, 9, 10));\n  }\n\n  List<Long> numbers(int upUntil) {\n    final ArrayList<Long> numberList = new ArrayList<>(upUntil);\n    for (long i = 0; i < upUntil; i++) {\n      numberList.add(i);\n    }\n    return numberList;\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/data/StringGenerator.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.data;\n\nimport java.util.ArrayList;\nimport java.util.List;\nimport java.util.Random;\n\npublic class StringGenerator {\n\n  private static final int DEFAULT_STRING_LENGHT = 12;\n  private static final char[] symbols;\n\n  static {\n    StringBuilder tmpSymbols = new StringBuilder();\n    for (char numberChar = '0'; numberChar <= '9'; numberChar++) {\n      tmpSymbols.append(numberChar);\n    }\n    for (char letterChar = 'a'; letterChar <= 'z'; letterChar++) {\n      tmpSymbols.append(letterChar);\n    }\n    symbols = tmpSymbols.toString().toCharArray();\n  }\n\n  private final int stringLenght;\n  private final char[] charArray;\n  private final Random random;\n\n  public StringGenerator() {\n    this(DEFAULT_STRING_LENGHT);\n  }\n\n  public StringGenerator(int stringLength) {\n    this.stringLenght = stringLength;\n    this.charArray = new char[stringLenght];\n    this.random = new Random();\n  }\n\n  List<String> randomStringList() {\n    final int size = 10;\n    final List<String> elements = new ArrayList<>(size);\n    for (int i = 0; i < size; i++) {\n      elements.add(nextString());\n    }\n    return elements;\n  }\n\n  String nextString() {\n    for (int i = 0; i < charArray.length; i++) {\n      charArray[i] = symbols[random.nextInt(symbols.length)];\n    }\n    return String.valueOf(charArray);\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/executor/JobExecutor.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.executor;\n\nimport java.util.concurrent.BlockingQueue;\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.LinkedBlockingQueue;\nimport java.util.concurrent.ThreadPoolExecutor;\nimport java.util.concurrent.TimeUnit;\n\npublic class JobExecutor implements Executor {\n\n  private static class LazyHolder {\n    private static final JobExecutor INSTANCE = new JobExecutor();\n  }\n\n  public static JobExecutor getInstance() {\n    return LazyHolder.INSTANCE;\n  }\n\n  private static final int INITIAL_POOL_SIZE = 3;\n  private static final int MAX_POOL_SIZE = 5;\n\n  // Sets the amount of time an idle thread waits before terminating\n  private static final int KEEP_ALIVE_TIME = 10;\n\n  // Sets the Time Unit to seconds\n  private static final TimeUnit KEEP_ALIVE_TIME_UNIT = TimeUnit.SECONDS;\n\n  private final BlockingQueue<Runnable> workQueue;\n\n  private final ThreadPoolExecutor threadPoolExecutor;\n\n  private JobExecutor() {\n    this.workQueue = new LinkedBlockingQueue<>();\n    this.threadPoolExecutor = new ThreadPoolExecutor(INITIAL_POOL_SIZE, MAX_POOL_SIZE,\n        KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT, workQueue);\n  }\n\n  @Override public void execute(Runnable runnable) {\n    if (runnable == null) {\n      throw new IllegalArgumentException(\"Runnable to execute cannot be null\");\n    }\n    threadPoolExecutor.execute(runnable);\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/com/fernandocejas/android10/rx/sample/navigation/Navigator.java",
    "content": "/**\n * Copyright (C) 2015 android10.org Open Source Project\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 */\npackage com.fernandocejas.android10.rx.sample.navigation;\n\nimport android.content.Context;\nimport android.content.Intent;\nimport com.fernandocejas.android10.rx.sample.activity.backpressure.ActivityBackpressureSamples;\nimport com.fernandocejas.android10.rx.sample.activity.ActivityObservableCompositionSamples;\nimport com.fernandocejas.android10.rx.sample.activity.ActivityObservableConcatVsFlatMapSample;\nimport com.fernandocejas.android10.rx.sample.activity.ActivitySubscriberSample;\n\npublic class Navigator {\n\n  public Navigator() {\n    //empty\n  }\n\n  public void navigateToSubscriberSample(Context context) {\n    if (context != null) {\n      Intent intentToLaunch = ActivitySubscriberSample.getCallingIntent(context);\n      context.startActivity(intentToLaunch);\n    }\n  }\n\n  public void navigateToObservableCompositionSamples(Context context) {\n    if (context != null) {\n      Intent intentToLaunch = ActivityObservableCompositionSamples.getCallingIntent(context);\n      context.startActivity(intentToLaunch);\n    }\n  }\n\n  public void navigateToBackpressureSamples(Context context) {\n    if (context != null) {\n      Intent intentToLaunch = ActivityBackpressureSamples.getCallingIntent(context);\n      context.startActivity(intentToLaunch);\n    }\n  }\n\n  public void navigateToObservableConcatVsFlatMap(Context context) {\n    if (context != null) {\n      Intent intentToLaunch = ActivityObservableConcatVsFlatMapSample.getCallingIntent(context);\n      context.startActivity(intentToLaunch);\n    }\n  }\n}\n"
  },
  {
    "path": "app/src/main/res/drawable/selector_item_element.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n  <item android:drawable=\"@android:color/holo_blue_light\" android:state_focused=\"true\" />\n  <item android:drawable=\"@android:color/holo_blue_light\" android:state_pressed=\"true\" />\n  <item android:drawable=\"@android:color/holo_blue_light\" android:state_selected=\"true\" />\n  <item android:drawable=\"@android:color/background_light\" />\n</selector>"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "content": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    android:paddingBottom=\"@dimen/activity_vertical_margin\"\n    android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n    android:paddingRight=\"@dimen/activity_horizontal_margin\"\n    android:paddingTop=\"@dimen/activity_vertical_margin\"\n    >\n\n  <TextView\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_margin=\"5dp\"\n      android:gravity=\"center\"\n      android:text=\"@string/url\"\n      />\n\n  <TextView\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginBottom=\"5dp\"\n      android:text=\"@string/string_samples_main\"\n      />\n\n  <Button\n      android:id=\"@+id/btn_sampleObserver\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:text=\"@string/btn_text_load_sample_observer\"\n      />\n\n  <Button\n      android:id=\"@+id/btn_sampleObservableComposition\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:text=\"@string/btn_text_load_sample_observable_composition\"\n      />\n\n  <Button\n      android:id=\"@+id/btn_sampleBackpressure\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:text=\"@string/btn_text_load_sample_backpressure\"\n      />\n\n</LinearLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_sample_observervable_composition_flat_vs_concat.xml",
    "content": "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\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    >\n\n  <RelativeLayout\n      android:id=\"@+id/rl_buttonsHolder\"\n      android:layout_width=\"wrap_content\"\n      android:layout_height=\"wrap_content\"\n      android:layout_alignParentBottom=\"true\"\n      >\n\n    <Button\n        android:id=\"@+id/btn_flatMap\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_marginTop=\"@dimen/activity_vertical_margin\"\n        android:text=\"@string/btn_text_flat_map\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_concatMap\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:layout_below=\"@+id/btn_flatMap\"\n        android:text=\"@string/btn_text_concat_map\"\n        />\n  </RelativeLayout>\n\n  <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"match_parent\"\n      android:layout_above=\"@id/rl_buttonsHolder\"\n      android:orientation=\"vertical\"\n      >\n\n    <TextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/string_sample_observable_comp_concat_vs_flat_map\"\n        />\n\n    <TextView\n        style=\"@style/AppTheme.TextViewTitle\"\n        android:text=\"@string/tv_label_original_order\"\n        />\n    <TextView\n        android:id=\"@+id/tv_streamOriginalOrder\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        />\n\n    <TextView\n        style=\"@style/AppTheme.TextViewTitle\"\n        android:text=\"@string/tv_label_flatMap_result\"\n        />\n    <TextView\n        android:id=\"@+id/tv_flatMapResult\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        />\n\n    <TextView\n        style=\"@style/AppTheme.TextViewTitle\"\n        android:text=\"@string/tv_label_concatMap_result\"\n        />\n    <TextView\n        android:id=\"@+id/tv_concatMapResult\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        />\n\n  </LinearLayout>\n\n</RelativeLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_sample_subscriber.xml",
    "content": "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\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    >\n\n  <TextView\n      android:id=\"@+id/text\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginBottom=\"5dp\"\n      android:text=\"@string/string_sample_subscriber\"\n      />\n\n  <android.support.v7.widget.RecyclerView\n      android:id=\"@android:id/list\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"match_parent\"\n      android:layout_below=\"@+id/text\"\n      android:layout_above=\"@android:id/button1\"\n      android:scrollbars=\"vertical\"\n      />\n\n  <Button\n      android:id=\"@android:id/button1\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_alignParentBottom=\"true\"\n      android:layout_marginTop=\"@dimen/activity_vertical_margin\"\n      android:text=\"@string/btn_text_add_element\"\n      />\n\n</RelativeLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_samples_backpressure.xml",
    "content": "<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/sv_container\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:scrollbars=\"vertical\"\n    android:scrollbarAlwaysDrawVerticalTrack=\"true\"\n    android:fadeScrollbars=\"false\"\n    >\n\n  <LinearLayout\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:orientation=\"vertical\"\n      android:paddingBottom=\"@dimen/activity_vertical_margin\"\n      android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n      android:paddingRight=\"@dimen/activity_horizontal_margin\"\n      android:paddingTop=\"@dimen/activity_vertical_margin\"\n      >\n\n    <TextView\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/string_sample_backpressure\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_backpressureException\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/btn_text_backpressure_exception\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_backpressureDrop\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/btn_text_backpressure_drop\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_backpressureBuffer\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/btn_text_backpressure_buffer\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_backpressureWindow\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/btn_text_backpressure_window\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_backpressureToList\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/btn_text_backpressure_toList\"\n        />\n\n    <Button\n        android:id=\"@+id/btn_backpressureThrottleLast\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"wrap_content\"\n        android:text=\"@string/btn_text_backpressure_throttleLast\"\n        />\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        >\n\n      <TextView\n          style=\"@style/AppTheme.TextViewTitle\"\n          android:text=\"@string/tv_label_backpressure_sample\"\n          />\n      <TextView\n          android:id=\"@+id/tv_sampleDescription\"\n          android:layout_width=\"match_parent\"\n          android:layout_height=\"wrap_content\"\n          />\n\n      <TextView\n          style=\"@style/AppTheme.TextViewTitle\"\n          android:text=\"@string/tv_label_backpressure_items_requested\"\n          />\n      <TextView\n          android:id=\"@+id/tv_itemsRequested\"\n          android:layout_width=\"match_parent\"\n          android:layout_height=\"wrap_content\"\n          />\n\n      <TextView\n          style=\"@style/AppTheme.TextViewTitle\"\n          android:text=\"@string/tv_label_backpressure_items_processed\"\n          />\n      <TextView\n          android:id=\"@+id/tv_itemsProcessed\"\n          android:layout_width=\"match_parent\"\n          android:layout_height=\"wrap_content\"\n          />\n\n      <TextView\n          style=\"@style/AppTheme.TextViewTitle\"\n          android:text=\"@string/tv_label_backpressure_items_emitted\"\n          />\n      <TextView\n          android:id=\"@+id/tv_itemsEmitted\"\n          android:layout_width=\"match_parent\"\n          android:layout_height=\"wrap_content\"\n          />\n\n      <TextView\n          style=\"@style/AppTheme.TextViewTitle\"\n          android:text=\"@string/tv_label_backpressure_result\"\n          />\n      <TextView\n          android:id=\"@+id/tv_result\"\n          android:layout_width=\"match_parent\"\n          android:layout_height=\"wrap_content\"\n          />\n\n    </LinearLayout>\n\n  </LinearLayout>\n</ScrollView>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_samples_observable_composition.xml",
    "content": "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\"\n    android:orientation=\"vertical\"\n    android:paddingBottom=\"@dimen/activity_vertical_margin\"\n    android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n    android:paddingRight=\"@dimen/activity_horizontal_margin\"\n    android:paddingTop=\"@dimen/activity_vertical_margin\"\n    >\n\n  <TextView\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_margin=\"5dp\"\n      android:gravity=\"center\"\n      android:text=\"@string/url\"\n      />\n\n  <TextView\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:layout_marginBottom=\"5dp\"\n      android:text=\"@string/string_samples_observable_composition\"\n      />\n\n  <Button\n      android:id=\"@+id/btn_sampleConcatVsFlatMap\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:text=\"@string/app_sample_observable_composition_concat_vs_flat_map\"\n      />\n\n</LinearLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/row_element.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout 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=\"wrap_content\"\n    android:background=\"@drawable/selector_item_element\"\n    android:orientation=\"horizontal\"\n    android:padding=\"@dimen/lv_row_padding\"\n    tools:ignore=\"UseCompoundDrawables\"\n    >\n\n  <ImageView\n      android:id=\"@+id/avatar\"\n      android:layout_width=\"@dimen/lv_row_icon_width\"\n      android:layout_height=\"@dimen/lv_row_icon_width\"\n      android:contentDescription=\"@string/string_content_description\"\n      android:paddingLeft=\"@dimen/lv_row_icon_padding\"\n      android:paddingRight=\"@dimen/lv_row_icon_padding\"\n      android:src=\"@drawable/ic_launcher\"\n      />\n\n  <TextView\n      android:id=\"@+id/title\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"match_parent\"\n      android:ellipsize=\"end\"\n      android:gravity=\"center_vertical\"\n      android:singleLine=\"true\"\n      android:textSize=\"@dimen/lv_row_text_size\"\n      />\n\n</LinearLayout>\n"
  },
  {
    "path": "app/src/main/res/values/dimens.xml",
    "content": "<resources>\n  <!-- Default screen margins, per the Android Design guidelines. -->\n  <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n  <dimen name=\"activity_vertical_margin\">16dp</dimen>\n\n  <!--User Header stuff-->\n  <dimen name=\"header_text_size\">26sp</dimen>\n  <dimen name=\"header_margin\">5dp</dimen>\n  <dimen name=\"iv_cover_height\">140dp</dimen>\n\n  <!--Listview rows stuff-->\n  <dimen name=\"lv_row_padding\">5dp</dimen>\n  <dimen name=\"lv_row_text_size\">20sp</dimen>\n  <dimen name=\"lv_row_icon_width\">50dp</dimen>\n  <dimen name=\"lv_row_icon_padding\">5dp</dimen>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n  <string name=\"app_name\">RxJava Samples</string>\n  <string name=\"url\">http://www.fernandocejas.com/</string>\n\n  <string name=\"app_sample_observer\">Simple Observer Sample</string>\n  <string name=\"app_sample_observable_composition\">Observable Composition Samples</string>\n  <string name=\"app_sample_backpressure\">Backpressure Samples</string>\n\n  <string name=\"app_sample_observable_composition_concat_vs_flat_map\">flatMap() vs concatMap()</string>\n\n  <string name=\"btn_text_load_sample_observer\">Observer Sample</string>\n  <string name=\"btn_text_load_sample_observable_composition\">Observable Composition Samples</string>\n  <string name=\"btn_text_load_sample_backpressure\">Backpressure Samples (WIP)</string>\n\n  <string name=\"btn_text_add_element\">Add Element</string>\n\n  <string name=\"btn_text_flat_map\">Observable.flatMap()</string>\n  <string name=\"btn_text_concat_map\">Observable.concatMap()</string>\n  <string name=\"tv_label_original_order\">Original stream order:</string>\n  <string name=\"tv_label_flatMap_result\">flatMap() Unordered result:</string>\n  <string name=\"tv_label_concatMap_result\">concatMap() Ordered result:</string>\n  <string name=\"tv_label_backpressure_sample\">Sample:</string>\n  <string name=\"tv_label_backpressure_items_requested\">Items requested:</string>\n  <string name=\"tv_label_backpressure_items_processed\">Items processed:</string>\n  <string name=\"tv_label_backpressure_items_emitted\">Items emitted:</string>\n  <string name=\"tv_label_backpressure_result\">Result:</string>\n  <string name=\"btn_text_backpressure_exception\">Backpressure Exception</string>\n  <string name=\"btn_text_backpressure_drop\">Backpressure Drop Items</string>\n  <string name=\"btn_text_backpressure_buffer\">Backpressure Buffer Items</string>\n  <string name=\"btn_text_backpressure_window\">Backpressure Window Items</string>\n  <string name=\"btn_text_backpressure_toList\">Backpressure To List</string>\n  <string name=\"btn_text_backpressure_throttleLast\">Backpressure Throttle Last</string>\n\n  <string name=\"string_content_description\">Non accessible view</string>\n\n  <string name=\"string_samples_main\">This is a serie of examples regarding reactive programming\n    using RxJava.</string>\n  <string name=\"string_samples_observable_composition\">Examples to demonstrate different approaches\n    and operators when composing and transforming Observables.</string>\n  <string name=\"string_sample_subscriber\">This is a simple example that aims to demonstrate how an\n    adapter can be a subscriber and reacts when a new item is emitted by a source\n    Observable.</string>\n  <string name=\"string_sample_observable_comp_concat_vs_flat_map\">This sample demonstrates an\n    observable transformation by applying a function (square of a number) to a set of values.\n    The basic idea is to see the difference between both flatMap() and concatMap() methods whereas\n    one take care of the order and the other does not.</string>\n  <string name=\"string_sample_backpressure\">Link to the article: </string>\n  <string name=\"string_success\">Success!</string>\n  <string name=\"string_failure\">Failure! %1$s</string>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n  <style name=\"AppTheme\"\n      parent=\"android:Theme.Holo.Light.DarkActionBar\">\n  </style>\n\n  <style name=\"AppTheme.TextViewTitle\">\n    <item name=\"android:layout_width\">match_parent</item>\n    <item name=\"android:layout_height\">wrap_content</item>\n    <item name=\"android:layout_marginTop\">@dimen/header_margin</item>\n    <item name=\"android:textStyle\">bold</item>\n  </style>\n\n</resources>\n"
  },
  {
    "path": "build.gradle",
    "content": "buildscript {\n  repositories {\n    jcenter()\n    mavenCentral()\n    mavenLocal()\n  }\n  dependencies {\n    classpath 'com.android.tools.build:gradle:2.2.2'\n    classpath 'me.tatarka:gradle-retrolambda:3.2.2'\n  }\n}\n\nallprojects {\n  repositories {\n    jcenter()\n    mavenCentral()\n    mavenLocal()\n  }\n}\n\ntask deployDebug(type: Exec, dependsOn: 'app:installDebug') {\n  def rootDir = project.rootDir\n  def localProperties = new File(rootDir, \"local.properties\")\n  if (localProperties.exists()) {\n    Properties properties = new Properties()\n    localProperties.withInputStream {\n      inputStream -> properties.load(inputStream)\n  }\n  def sdkDir = properties.getProperty('sdk.dir')\n  def adb = \"$sdkDir/platform-tools/adb\"\n  commandLine \"$adb\", 'shell', 'am', 'start', '-n', 'com.fernandocejas.android10.rx.sample/com.fernandocejas.android10.rx.sample.activity.MainActivity'\n  }\n}\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "#Sat Dec 10 22:13:26 CET 2016\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-3.2.1-all.zip\n"
  },
  {
    "path": "gradle.properties",
    "content": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\norg.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\norg.gradle.parallel=true\n"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env sh\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=\"\"\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# 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, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\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=$((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\n# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong\nif [ \"$(uname)\" = \"Darwin\" ] && [ \"$HOME\" = \"$PWD\" ]; then\n  cd \"$(dirname \"$0\")\"\nfi\n\nexec \"$JAVACMD\" \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@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 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=\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@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": "settings.gradle",
    "content": "include ':app'\n"
  }
]