[
  {
    "path": ".gitignore",
    "content": "##############################################################################\n### macOS template\n# General\n.DS_Store\n.AppleDouble\n.LSOverride\n\n# Icon must end with two \\r\nIcon\n\n# Thumbnails\n._*\n\n# Files that might appear in the root of a volume\n.DocumentRevisions-V100\n.fseventsd\n.Spotlight-V100\n.TemporaryItems\n.Trashes\n.VolumeIcon.icns\n.com.apple.timemachine.donotpresent\n\n# Directories potentially created on remote AFP share\n.AppleDB\n.AppleDesktop\nNetwork Trash Folder\nTemporary Items\n.apdisk\n\n##############################################################################\n### Windows template\n# Windows thumbnail cache files\nThumbs.db\nThumbs.db:encryptable\nehthumbs.db\nehthumbs_vista.db\n\n# Dump file\n*.stackdump\n\n# Folder config file\n[Dd]esktop.ini\n\n# Recycle Bin used on file shares\n$RECYCLE.BIN/\n\n# Windows Installer files\n*.cab\n*.msi\n*.msix\n*.msm\n*.msp\n\n# Windows shortcuts\n*.lnk\n\n##############################################################################\n### Linux template\n*~\n\n# temporary files which can be created if a process still has a handle open of a deleted file\n.fuse_hidden*\n\n# KDE directory preferences\n.directory\n\n# Linux trash folder which might appear on any partition or disk\n.Trash-*\n\n# .nfs files are created when an open file is removed but is still being accessed\n.nfs*\n\n##############################################################################\n### Visual Studio template\n# Visual studio project files\n*.vcxproj\n*.vcxproj.filters\n*.sln\n\n##############################################################################\n### JetBrains template\n# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm\n# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839\n\n*.iml\n*.ipr\n*.iws\nmisc.xml\ndeploymentTargetDropDown.xml\nrender.experimental.xml\n\n/.idea/*\n\n# Exclude non-user-specific stuff\n!.idea/.name\n!.idea/codeInsightSettings.xml\n!.idea/codeStyles/\n!.idea/copyright/\n!.idea/dataSources.xml\n!.idea/detekt.xml\n!.idea/encodings.xml\n!.idea/externalDependencies.xml\n!.idea/file.template.settings.xml\n!.idea/fileTemplates/\n!.idea/icon.svg\n!.idea/inspectionProfiles/\n!.idea/runConfigurations/\n!.idea/scopes/\n!.idea/vcs.xml\n\n##############################################################################\n### Kotlin template\n# Compiled class file\n*.class\n\n# Log file\n*.log\n\n# Package Files #\n*.jar\n*.war\n*.nar\n*.ear\n*.zip\n*.tar.gz\n*.rar\n\n# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml\nhs_err_pid*\n\n\n##############################################################################\n### C++ template\n# Compiled class file\n*.cxx\n\n\n##############################################################################\n### Gradle template\n.gradle\n.gradle/\n\n# Note that you may need to exclude by hand other folders\n# named build if necessary (e.g., in src/)\n**/build/\n!src/**/build/\n\n# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)\n!gradle/wrapper/gradle-wrapper.jar\n\n# Cache of project\n.gradletasknamecache\n\n##############################################################################\n### Android-specific stuff\n\n# Built application files\n*.apk\n*.ap_\n*.aab\n*.apks\n\n# Files for the Dalvik VM\n*.dex\n\n# Generated files\nbin/\ngen/\nobj/\n\n# Local configuration file (sdk path, etc)\nlocal.properties\n\n# Google/Firebase secrets\ngoogle-services.json\n\n# Android Studio generated files and folders\ncaptures/\n.externalNativeBuild/\n.cxx/\noutput.json\n\n# Keystore files\n*.jks\n*.keystore\n\n# Android Profiling\n*.hprof\n\n\n##############################################################################\n### Project Specific\n\n# !.idea/workspace.xml\n"
  },
  {
    "path": ".idea/.name",
    "content": "Movies USF Android"
  },
  {
    "path": ".idea/vcs.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<project version=\"4\">\n  <component name=\"VcsDirectoryMappings\">\n    <mapping directory=\"\" vcs=\"Git\" />\n  </component>\n</project>"
  },
  {
    "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"
  },
  {
    "path": "README.md",
    "content": "# Movie search using a unidirectional state flow pattern\n\nThis is an attempt at coming up with a unidirectional state flow pattern that uses the concepts\nof patterns like Redux, Cycle.js, MVI etc.\n\nMany of my contemporaries have already done amazing work in this area and I've drawn a lot of lessons and learnings from their work already:\n\n* [The state of managing state with RxJava](https://jakewharton.com/the-state-of-managing-state-with-rxjava/) - [JakeWharton](https://twitter.com/JakeWharton)\n* [MVI patterns with Hannes Dorfmann](http://fragmentedpodcast.com/episodes/103/) - [Hannes Dorfmann](https://twitter.com/sockeqwe)\n* [LCE: Modeling Data Loading in RxJava](https://tech.instacart.com/lce-modeling-data-loading-in-rxjava-b798ac98d80) - [Laimonas](https://twitter.com/ThatLime)\n\nI wanted to achieve the benefits of this pattern without introducing any new libraries\nor a new framework. How would one familiar with an MVVM model today leverage the principles/benefits of a unidirectional state/data flow? I hope to demo those concepts with this app.\n\n![usf_animation.gif \"picture showing the USF animation\"](usf_animation.gif)\n\n\nThe app is a simple movie search app. Clicking the movie result populates a history list. While this is not an extremely complex app, it isn't a silly Hello World one either, so the hope is that it'll cover regular use cases for a basic application.\n\nI've also started meaninful test cases in the repo.\n\n## Setting up your OMDB API KEY\n\n_We use the wonderful [OMDB api](http://www.omdbapi.com) to fetch movie information._\n\nThere are quotas on this api, so please don't use mine :)\n\n1. Get an [api key for OMDB here](http://www.omdbapi.com/apikey.aspx)\n2. Add it to you local.properties file (which shouldn't be checked in to a VCS) like so:\n\n```\n# local.properties\nOMDB_API_KEY=\"<API_KEY_GOES_HERE>\"\n```\n\nFor great movie recommendations, ping me [@kau.sh](https://kau.sh) (seriously, I watch a lot of movies).\n\nI gave a talk at [MBLT}Dev 2018](https://twitter.com/mbltdev) on how I went about building this app. [Slides can be found here](https://speakerdeck.com/kaushikgopal/unidirectional-state-flow-patterns-a-refactoring-story).\n\n## Getting Started\n\nThis project now uses [ksp](https://kotlinlang.org/docs/ksp-overview.html) to reduce the boilerplate in wiring up a new feature. [This PR](https://github.com/kaushikgopal/movies-usf-android/pull/32) has the details for how this change was made.\n\nAll that's needed is writing the implementation of your ViewModel so `MyFeatureViewModelImpl: UsfViewModelImpl<E, R, VS, VE>` and adding the `@UsfViewModel` annotation. Your ViewModel boilerplate code will be auto-generated.\n\nTake a look at [MSMovieViewModelImpl](https://github.com/kaushikgopal/movies-usf-android/blob/master/app/src/main/java/co/kaush/msusf/movies/MSMovieViewModelImpl.kt) for the View Model logic and [MSMovieActivity](https://github.com/kaushikgopal/movies-usf-android/blob/master/app/src/main/java/co/kaush/msusf/movies/MSMovieActivity.kt) to see how the `viewModel` is invoked.\n\n# iOS app\n\nI gave another talk at [Mobilization IX](https://twitter.com/mobilizationpl/status/1184008559157219328?s=20) showing how we can use the same concepts on iOS too and wrote [my first iOS app to demonstrate these concepts - You can check that out here](https://github.com/kaushikgopal/movies-usf-ios).\n"
  },
  {
    "path": "app/build.gradle.kts",
    "content": "@file:Suppress(\"DSL_SCOPE_VIOLATION\") // TODO: Remove once KTIJ-19369 is fixed (or agp 8.1)\nplugins {\n  alias(libs.plugins.android.application)\n  alias(libs.plugins.kotlin.android)\n  alias(libs.plugins.kotlin.allopen)\n  alias(libs.plugins.google.ksp)\n  alias(libs.plugins.secrets.gradle.plugin)\n  alias(libs.plugins.mannodermaus.junit5)\n}\n\nallOpen { annotation(\"co.kaush.msusf.movies.OpenClass\") }\n\nandroid {\n  namespace = \"co.kaush.msusf.movies\"\n\n  compileSdk = libs.versions.compileSdk.get().toInt()\n\n  defaultConfig {\n    applicationId = \"co.kaush.msusf\"\n    minSdk = libs.versions.minSdk.get().toInt()\n    versionCode = libs.versions.appVersionCode.get().toInt()\n    versionName = libs.versions.appVersionName.get()\n  }\n\n  buildFeatures {\n    buildConfig = true\n    viewBinding = true\n  }\n\n  buildTypes {\n    getByName(\"release\") {\n      isMinifyEnabled = false\n      proguardFiles(getDefaultProguardFile(\"proguard-android.txt\"), \"proguard-rules.pro\")\n    }\n  }\n\n  compileOptions {\n    // after agp 8.1.0-alpha09, this is no longer needed\n    // https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support\n    sourceCompatibility = JavaVersion.VERSION_17\n    targetCompatibility = JavaVersion.VERSION_17\n  }\n}\n\ndependencies {\n  ksp(libs.kotlin.inject.compiler)\n  implementation(libs.kotlin.inject.runtime)\n\n  ksp(project(\":usf:annotations-processors\")) // todo: put all usf in same module\n  implementation(project(\":usf:annotations\"))\n  implementation(project(\":usf:api\"))\n\n  implementation(libs.kotlin.stdlib)\n  implementation(libs.kotlinx.coroutines.android)\n  implementation(libs.kotlinx.coroutines.core)\n\n  implementation(libs.androidx.constraintlayout) // todo: move to compose\n  implementation(libs.androidx.activity.ktx)\n  implementation(libs.androidx.lifecycle.runtime.ktx)\n  implementation(libs.androidx.lifecycle.viewmodel)\n  implementation(libs.androidx.lifecycle.viewmodel.ktx)\n  implementation(libs.androidx.lifecycle.viewmodel.savedstate)\n  implementation(libs.androidx.swiperefreshlayout)\n  implementation(libs.androidx.appcompat)\n  implementation(libs.androidx.recyclerview)\n\n  implementation(libs.coil)\n  implementation(libs.flow.binding)\n  implementation(libs.timber) // todo: remove\n\n  implementation(platform(libs.square.okhttp.bom))\n  implementation(libs.square.okhttp)\n  implementation(libs.square.okhttp.logging.interceptor)\n\n  implementation(libs.square.retrofit.gson)\n  implementation(libs.square.retrofit)\n\n  debugImplementation(libs.square.leakcanary)\n  releaseImplementation(libs.square.leakcanary.noop)\n\n  // (Required) Writing and executing Unit Tests on the JUnit Platform\n  testImplementation(libs.testing.junit5.api)\n  testRuntimeOnly(libs.testing.junit5.engine)\n\n  testImplementation(libs.testing.turbine)\n  testImplementation(libs.testing.assertj.core)\n  testImplementation(libs.mockito.core)\n  testImplementation(libs.mockito.kotlin)\n  testImplementation(libs.kotlinx.coroutines.test)\n\n  //  testImplementation(libs.atsl.runner)\n\n  androidTestImplementation(libs.androidx.espresso.core)\n}\n"
  },
  {
    "path": "app/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguardFiles setting in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\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": "app/src/debug/java/co/kaush/msusf/movies/OpenClass.kt",
    "content": "package co.kaush.msusf.movies\n\n@Target(AnnotationTarget.ANNOTATION_CLASS) annotation class OpenClass\n"
  },
  {
    "path": "app/src/debug/java/co/kaush/msusf/movies/OpenClassOnDebug.kt",
    "content": "package co.kaush.msusf.movies\n\n@OpenClass @Target(AnnotationTarget.CLASS) annotation class OpenClassOnDebug\n"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n  xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n  <uses-permission android:name=\"android.permission.INTERNET\"/>\n  <uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>\n\n  <application\n    android:icon=\"@mipmap/ic_launcher\"\n    android:networkSecurityConfig=\"@xml/network_security_config\"\n    android:label=\"@string/app_name\"\n    android:name=\"co.kaush.msusf.MSApp\"\n    android:roundIcon=\"@mipmap/ic_launcher_round\"\n    android:supportsRtl=\"true\"\n    android:theme=\"@style/AppTheme\">\n\n    <activity\n      android:name=\"co.kaush.msusf.movies.MSMovieActivity\"\n      android:windowSoftInputMode=\"adjustResize\"\n      android:exported=\"true\">\n\n      <intent-filter>\n        <action android:name=\"android.intent.action.MAIN\"/>\n        <category android:name=\"android.intent.category.LAUNCHER\"/>\n      </intent-filter>\n\n    </activity>\n\n  </application>\n\n\n</manifest>\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/MSApp.kt",
    "content": "package co.kaush.msusf\n\nimport android.app.Application\nimport co.kaush.msusf.di.AppComponent\nimport co.kaush.msusf.movies.OpenClassOnDebug\nimport timber.log.Timber\n\n@OpenClassOnDebug\nclass MSApp : Application() {\n\n  private val appComponent by lazy(LazyThreadSafetyMode.NONE) { AppComponent.from(this) }\n\n  override fun onCreate() {\n    super.onCreate()\n    Timber.plant(Timber.DebugTree())\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/di/AppScope.kt",
    "content": "package co.kaush.msusf.di\n\nimport me.tatarka.inject.annotations.Scope\n\n/** The application-level scope. There will only be one instance of anything annotated with this. */\n@Scope annotation class AppScope\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/di/MSAppDI.kt",
    "content": "package co.kaush.msusf.di\n\nimport android.content.Context\nimport co.kaush.msusf.MSApp\nimport co.kaush.msusf.movies.MSMovieApi\nimport co.kaush.msusf.movies.MSMovieRepository\nimport me.tatarka.inject.annotations.Component\nimport me.tatarka.inject.annotations.Provides\nimport okhttp3.OkHttpClient\nimport okhttp3.logging.HttpLoggingInterceptor\nimport retrofit2.Retrofit\nimport retrofit2.converter.gson.GsonConverterFactory\n\n/** These are components that you'll need in both Test and Prod */\nabstract class CommonAppComponent {\n  abstract val movieRepository: MSMovieRepository\n}\n\n@AppScope\n@Component\nabstract class AppComponent(\n    @get:Provides val app: MSApp,\n) : CommonAppComponent() {\n\n  @AppScope\n  @Provides\n  protected fun provideRetrofit(): Retrofit {\n    val interceptor = (HttpLoggingInterceptor()).apply { level = HttpLoggingInterceptor.Level.BODY }\n\n    val okHttpClient: OkHttpClient =\n        OkHttpClient.Builder().addNetworkInterceptor(interceptor).build()\n\n    return Retrofit.Builder()\n        .baseUrl(\"http://www.omdbapi.com\")\n        .client(okHttpClient)\n        .addConverterFactory(GsonConverterFactory.create())\n        .build()\n  }\n\n  @AppScope\n  @Provides\n  fun provideMovieApi(retrofit: Retrofit): MSMovieApi {\n    return retrofit.create(MSMovieApi::class.java)\n  }\n\n  companion object {\n    private var instance: AppComponent? = null\n\n    fun from(context: Context): AppComponent =\n        instance\n            ?: AppComponent::class.create(context.applicationContext as MSApp).also {\n              instance = it\n            }\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSAnimationExt.kt",
    "content": "package co.kaush.msusf.movies\n\nimport android.animation.AnimatorSet\nimport android.animation.ObjectAnimator\nimport android.animation.PropertyValuesHolder\nimport android.view.View\nimport android.view.animation.OvershootInterpolator\nimport android.widget.ImageView\n\nfun ImageView.growShrink() {\n  val expansionFactor: Float = 0.2F\n  val growX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f + expansionFactor)\n  val growY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f + expansionFactor)\n  val growAnimation = ObjectAnimator.ofPropertyValuesHolder(this, growX, growY)\n  growAnimation.interpolator = OvershootInterpolator()\n\n  val shrinkX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1f)\n  val shrinkY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1f)\n  val shrinkAnimation = ObjectAnimator.ofPropertyValuesHolder(this, shrinkX, shrinkY)\n  shrinkAnimation.interpolator = OvershootInterpolator()\n\n  val animSetXY = AnimatorSet()\n  animSetXY.playSequentially(growAnimation, shrinkAnimation)\n  animSetXY.start()\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieActivity.kt",
    "content": "package co.kaush.msusf.movies\n\nimport android.os.Bundle\nimport android.widget.Toast\nimport androidx.activity.ComponentActivity\nimport androidx.activity.viewModels\nimport androidx.core.content.ContextCompat\nimport androidx.lifecycle.Lifecycle\nimport androidx.lifecycle.flowWithLifecycle\nimport androidx.lifecycle.lifecycleScope\nimport androidx.recyclerview.widget.DividerItemDecoration\nimport androidx.recyclerview.widget.LinearLayoutManager\nimport androidx.recyclerview.widget.LinearLayoutManager.HORIZONTAL\nimport androidx.swiperefreshlayout.widget.CircularProgressDrawable\nimport co.kaush.msusf.di.AppComponent\nimport co.kaush.msusf.movies.MSMovieEvent.AddToHistoryEvent\nimport co.kaush.msusf.movies.MSMovieEvent.RestoreFromHistoryEvent\nimport co.kaush.msusf.movies.MSMovieEvent.ScreenLoadEvent\nimport co.kaush.msusf.movies.MSMovieEvent.SearchMovieEvent\nimport co.kaush.msusf.movies.databinding.ActivityMainBinding\nimport coil.load\nimport kotlinx.coroutines.Dispatchers\nimport kotlinx.coroutines.GlobalScope\nimport kotlinx.coroutines.flow.MutableSharedFlow\nimport kotlinx.coroutines.flow.catch\nimport kotlinx.coroutines.flow.flowOf\nimport kotlinx.coroutines.flow.launchIn\nimport kotlinx.coroutines.flow.map\nimport kotlinx.coroutines.flow.merge\nimport kotlinx.coroutines.flow.onEach\nimport kotlinx.coroutines.launch\nimport reactivecircus.flowbinding.android.view.clicks\nimport timber.log.Timber\n\nclass MSMovieActivity : ComponentActivity() {\n\n  private lateinit var movieRepo: MSMovieRepository\n  private val viewModel: MSMovieViewModel by viewModels {\n    MSMovieViewModel.MSMovieViewModelFactory(movieRepo)\n  }\n\n  private lateinit var listAdapter: MSMovieSearchHistoryAdapter\n  private lateinit var binding: ActivityMainBinding\n\n  private val historyItemClick = MutableSharedFlow<MSMovie>()\n\n  private val spinner: CircularProgressDrawable by lazy {\n    val circularProgressDrawable = CircularProgressDrawable(this)\n    circularProgressDrawable.strokeWidth = 5f\n    circularProgressDrawable.centerRadius = 30f\n    circularProgressDrawable.start()\n    circularProgressDrawable\n  }\n\n  override fun onCreate(savedInstanceState: Bundle?) {\n    super.onCreate(savedInstanceState)\n    binding = ActivityMainBinding.inflate(layoutInflater)\n    setContentView(binding.root)\n\n    val appComponent = AppComponent.from(this)\n    movieRepo = appComponent.movieRepository\n\n    setupListView()\n\n    binding.longRunningTask.setOnClickListener {\n      GlobalScope.launch(Dispatchers.Default) {\n        viewModel.processInput(MSMovieEvent.LongRunningEvent)\n      }\n    }\n\n    viewModel.viewState\n        .onEach { render(it) }\n        .catch { Timber.e(it, \"error rendering view state\") }\n        .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)\n        .launchIn(lifecycleScope)\n\n    viewModel.effects\n        .onEach { trigger(it) }\n        .catch { Timber.e(it, \"error triggering side effect\") }\n        .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)\n        .launchIn(lifecycleScope)\n  }\n\n  override fun onResume() {\n    super.onResume()\n\n    val screenLoadEvents = flowOf(ScreenLoadEvent)\n\n    val searchMovieEvents =\n        binding.msMainScreenSearchBtn.clicks().map {\n          SearchMovieEvent(binding.msMainScreenSearchText.text.toString())\n        }\n\n    val addToHistoryEvents =\n        binding.msMainScreenPoster.clicks().map {\n          binding.msMainScreenPoster.growShrink()\n          AddToHistoryEvent(binding.msMainScreenPoster.getTag(R.id.TAG_MOVIE_DATA) as MSMovie)\n        }\n\n    val restoreFromHistoryEvents = historyItemClick.map { RestoreFromHistoryEvent(it) }\n\n    merge(\n            screenLoadEvents,\n            searchMovieEvents,\n            addToHistoryEvents,\n            restoreFromHistoryEvents,\n        )\n        .onEach { viewModel.processInput(it) }\n        .catch { Timber.e(it, \"error processing input \") }\n        .flowWithLifecycle(lifecycle, Lifecycle.State.RESUMED)\n        .launchIn(lifecycleScope)\n  }\n\n  private fun trigger(effect: MSMovieEffect) {\n    Timber.d(\"----- [trigger] ${Thread.currentThread().name}\")\n    when (effect) {\n      is MSMovieEffect.AddedToHistoryToastEffect -> {\n        Toast.makeText(this, \"added to history\", Toast.LENGTH_SHORT).show()\n      }\n    }\n  }\n\n  private fun render(vs: MSMovieViewState) {\n    Timber.d(\"----- [render] ${Thread.currentThread().name}\")\n    vs.searchBoxText.let { binding.msMainScreenSearchText.setText(it) }\n    binding.msMainScreenTitle.text = vs.searchedMovieTitle\n    binding.msMainScreenRating.text = vs.searchedMovieRating\n\n    vs.searchedMoviePoster\n        .takeIf { it.isNotBlank() }\n        ?.let {\n          binding.msMainScreenPoster.load(vs.searchedMoviePoster) { placeholder(spinner) }\n\n          binding.msMainScreenPoster.setTag(R.id.TAG_MOVIE_DATA, vs.searchedMovieReference)\n        }\n        ?: run { binding.msMainScreenPoster.setImageResource(0) }\n\n    listAdapter.submitList(vs.adapterList)\n  }\n\n  private fun setupListView() {\n    val layoutManager = LinearLayoutManager(this, HORIZONTAL, false)\n    binding.msMainScreenSearchHistory.layoutManager = layoutManager\n\n    val dividerItemDecoration = DividerItemDecoration(this, HORIZONTAL)\n    dividerItemDecoration.setDrawable(\n        ContextCompat.getDrawable(this, R.drawable.ms_list_divider_space)!!,\n    )\n    binding.msMainScreenSearchHistory.addItemDecoration(dividerItemDecoration)\n\n    listAdapter = MSMovieSearchHistoryAdapter {\n      lifecycleScope.launch { historyItemClick.emit(it) }\n    }\n    binding.msMainScreenSearchHistory.adapter = listAdapter\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieApi.kt",
    "content": "package co.kaush.msusf.movies\n\nimport com.google.gson.annotations.SerializedName\nimport retrofit2.Response\nimport retrofit2.http.GET\nimport retrofit2.http.Query\n\ninterface MSMovieApi {\n\n  @GET(\"/\")\n  suspend fun searchMovie(\n      @Query(\"t\") movieName: String,\n      @Query(\"apiKey\") apiKey: String = BuildConfig.OMDB_API_KEY\n  ): Response<MSMovie>\n}\n\ndata class MSMovie(\n    @SerializedName(\"Result\") val result: Boolean,\n    @SerializedName(\"Error\") val errorMessage: String? = null,\n    @SerializedName(\"Title\") val title: String = \"\",\n    @SerializedName(\"Poster\") val posterUrl: String = \"\",\n    @SerializedName(\"Ratings\") val ratings: List<MSRating> = emptyList()\n) {\n  val ratingSummary: String\n    get() {\n      return ratings.fold(\"\") { summary, msRating -> \"$summary\\n${msRating.summary}\" }\n    }\n}\n\ndata class MSRating(\n    @SerializedName(\"Source\") val source: String,\n    @SerializedName(\"Value\") val rating: String\n) {\n\n  val summary: String\n    get() = \"$rating (${sourceShortName(source)})\"\n  private fun sourceShortName(ratingSource: String): String {\n    return when {\n      ratingSource.contains(\"Internet Movie Database\") -> \"IMDB\"\n      ratingSource.contains(\"Rotten Tomatoes\") -> \"RT\"\n      ratingSource.contains(\"Metacritic\") -> \"Metac\"\n      else -> ratingSource\n    }\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieRepository.kt",
    "content": "package co.kaush.msusf.movies\n\nimport co.kaush.msusf.di.AppScope\nimport com.google.gson.Gson\nimport me.tatarka.inject.annotations.Inject\n\nclass MSMovieRepository @AppScope @Inject constructor(val movieApi: MSMovieApi) {\n  suspend fun searchMovie(movieName: String): MSMovie? {\n    val response = movieApi.searchMovie(movieName)\n\n    response.body()?.let {\n      return it\n    }\n\n    return response.errorBody()?.let { body ->\n      Gson()\n          .fromJson(\n              body.string(),\n              MSMovie::class.java,\n          )\n    }\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieResult.kt",
    "content": "package co.kaush.msusf.movies\n\nimport kotlinx.coroutines.flow.Flow\nimport kotlinx.coroutines.flow.emptyFlow\nimport kotlinx.coroutines.flow.flow\n\nsealed class MSMovieResult {\n\n  abstract val loading: Boolean\n  abstract val errorMessage: String\n  abstract fun toViewState(currentViewState: MSMovieViewState): MSMovieViewState\n  abstract fun toEffects(): Flow<MSMovieEffect>\n\n  data class ScreenLoadResult(\n      override val loading: Boolean = false,\n      override val errorMessage: String = \"\",\n  ) : MSMovieResult() {\n    override fun toViewState(currentViewState: MSMovieViewState): MSMovieViewState =\n        currentViewState.copy(searchBoxText = \"\")\n\n    override fun toEffects(): Flow<MSMovieEffect> = emptyFlow()\n  }\n\n  data class SearchMovieResult(\n      override val loading: Boolean = false,\n      override val errorMessage: String = \"\",\n      val movie: MSMovie? = null,\n  ) : MSMovieResult() {\n\n    override fun toViewState(currentViewState: MSMovieViewState): MSMovieViewState {\n      val movie: MSMovie = movie!!\n\n      return currentViewState.copy(\n          searchBoxText = movie.title,\n          searchedMovieTitle = movie.title,\n          searchedMovieRating = movie.ratingSummary,\n          searchedMoviePoster = movie.posterUrl,\n          searchedMovieReference = movie,\n      )\n    }\n\n    override fun toEffects(): Flow<MSMovieEffect> = emptyFlow()\n  }\n\n  data class AddToHistoryResult(\n      override val loading: Boolean = false,\n      override val errorMessage: String = \"\",\n      val movie: MSMovie? = null,\n  ) : MSMovieResult() {\n\n    override fun toViewState(currentViewState: MSMovieViewState): MSMovieViewState {\n      val movie: MSMovie = movie!!\n\n      return if (!currentViewState.adapterList.contains(movie)) {\n        currentViewState.copy(adapterList = currentViewState.adapterList.plus(movie))\n      } else currentViewState.copy()\n    }\n\n    override fun toEffects(): Flow<MSMovieEffect> {\n      return flow { emit(MSMovieEffect.AddedToHistoryToastEffect) }\n    }\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieSearchHistoryAdapter.kt",
    "content": "package co.kaush.msusf.movies\n\nimport android.annotation.SuppressLint\nimport android.view.LayoutInflater\nimport android.view.View\nimport android.view.ViewGroup\nimport android.widget.ImageView\nimport android.widget.TextView\nimport androidx.annotation.LayoutRes\nimport androidx.recyclerview.widget.DiffUtil\nimport androidx.recyclerview.widget.ListAdapter\nimport androidx.recyclerview.widget.RecyclerView\nimport androidx.swiperefreshlayout.widget.CircularProgressDrawable\nimport coil.load\n\nclass MSMovieSearchHistoryAdapter(private val historyClickListener: (MSMovie) -> Unit) :\n    ListAdapter<MSMovie, MSMovieSearchVH>(MSMovieSearchDiffCallback()) {\n  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MSMovieSearchVH {\n    return MSMovieSearchVH(parent.inflate(R.layout.view_movie))\n  }\n\n  override fun onBindViewHolder(holder: MSMovieSearchVH, position: Int) {\n    holder.bind(getItem(position), historyClickListener)\n  }\n}\n\nclass MSMovieSearchDiffCallback : DiffUtil.ItemCallback<MSMovie>() {\n  // only one kind of item\n  override fun areItemsTheSame(oldItem: MSMovie, newItem: MSMovie): Boolean = true\n\n  override fun areContentsTheSame(oldItem: MSMovie, newItem: MSMovie): Boolean {\n    // this is just lazy!\n    return oldItem.posterUrl.equals(newItem.posterUrl, ignoreCase = true)\n  }\n}\n\nclass MSMovieSearchVH(itemView: View) : RecyclerView.ViewHolder(itemView) {\n\n  private val posterView: ImageView = itemView.findViewById(R.id.ms_result_poster)\n  private val ratingView: TextView = itemView.findViewById(R.id.ms_result_rating)\n  private val spinner: CircularProgressDrawable by lazy {\n    val circularProgressDrawable = CircularProgressDrawable(itemView.context)\n    circularProgressDrawable.strokeWidth = 5f\n    circularProgressDrawable.centerRadius = 30f\n    circularProgressDrawable.start()\n    circularProgressDrawable\n  }\n\n  @SuppressLint(\"SetTextI18n\")\n  fun bind(item: MSMovie, historyClickListener: (MSMovie) -> Unit) {\n\n    (item.ratings.first()).let { ratingView.text = it.summary }\n\n    item.posterUrl.takeIf { it.isNotBlank() }?.let { posterView.load(it) { placeholder(spinner) } }\n        ?: run { posterView.setImageResource(0) }\n\n    itemView.setOnClickListener {\n      historyClickListener.invoke(item)\n      posterView.growShrink()\n    }\n  }\n}\n\n// -----------------------------------------------------------------------------------\n// helpers\n\n/**\n * Usage: `val view = container?.inflate(R.layout.activity)`\n * `inflater?.inflate(R.layout.fragment_dialog_standard, c)!!`\n */\nprivate fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View =\n    LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot)\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieViewModel.kt",
    "content": "package co.kaush.msusf.movies\n\nimport androidx.lifecycle.ViewModel\nimport androidx.lifecycle.ViewModelProvider\nimport androidx.lifecycle.ViewModelProvider.Factory\nimport androidx.lifecycle.viewModelScope\nimport java.lang.Class\nimport kotlin.Suppress\nimport kotlin.Unit\nimport kotlinx.coroutines.flow.SharedFlow\nimport kotlinx.coroutines.flow.StateFlow\n\npublic class MSMovieViewModel(\n    movieRepo: MSMovieRepository,\n) : ViewModel() {\n  private val MSMovieViewModelImpl: MSMovieViewModelImpl =\n      MSMovieViewModelImpl(movieRepo = movieRepo, coroutineScope = viewModelScope)\n\n  public val effects: SharedFlow<MSMovieEffect>\n    get() = MSMovieViewModelImpl.effects\n\n  public val viewState: StateFlow<MSMovieViewState>\n    get() = MSMovieViewModelImpl.viewState\n\n  public fun processInput(event: MSMovieEvent): Unit =\n      MSMovieViewModelImpl.processInput(event = event)\n\n  public class MSMovieViewModelFactory(\n      private val movieRepo: MSMovieRepository,\n  ) : ViewModelProvider.Factory {\n    @Suppress(\"UNCHECKED_CAST\")\n    public override fun <T : ViewModel> create(modelClass: Class<T>): T =\n        MSMovieViewModel(movieRepo = movieRepo) as T\n  }\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieViewModelImpl.kt",
    "content": "package co.kaush.msusf.movies\n\nimport co.kaush.msusf.movies.MSMovieEvent.LongRunningEvent\nimport co.kaush.usf.UsfViewModelImpl\nimport kotlinx.coroutines.CoroutineDispatcher\nimport kotlinx.coroutines.CoroutineScope\nimport kotlinx.coroutines.Dispatchers\nimport kotlinx.coroutines.delay\nimport kotlinx.coroutines.flow.Flow\nimport kotlinx.coroutines.flow.flow\n\n// @UsfViewModel\nclass MSMovieViewModelImpl(\n    private val movieRepo: MSMovieRepository,\n    coroutineScope: CoroutineScope,\n    dispatcher: CoroutineDispatcher = Dispatchers.IO,\n) :\n    UsfViewModelImpl<MSMovieEvent, MSMovieResult, MSMovieViewState, MSMovieEffect>(\n        MSMovieViewState(),\n        coroutineScope,\n        dispatcher,\n    ) {\n\n  // -----------------------------------------------------------------------------------\n  // Event -> Results\n  override fun eventToResultFlow(event: MSMovieEvent): Flow<MSMovieResult> {\n    return when (event) {\n      is MSMovieEvent.ScreenLoadEvent -> onScreenLoad()\n      is MSMovieEvent.SearchMovieEvent -> onSearchMovie(event)\n      is MSMovieEvent.AddToHistoryEvent -> onAddToHistory(event)\n      is MSMovieEvent.RestoreFromHistoryEvent -> onRestoreFromHistory(event)\n      is LongRunningEvent -> onLongRunningTask(event)\n    }\n  }\n\n  private fun onScreenLoad(): Flow<MSMovieResult> = flow { emit(MSMovieResult.ScreenLoadResult()) }\n\n  private fun onLongRunningTask(event: LongRunningEvent): Flow<MSMovieResult> {\n    return flow {\n      delay(2000)\n      emit(\n          MSMovieResult.SearchMovieResult(\n              movie =\n                  MSMovie(\n                      true,\n                      title = \"Batman (1989)\",\n                      posterUrl =\n                          \"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAoHCBYWFRgWFRUZGBgaGhkcHBoYGBwaGBwaGhwcHBkcGRgdIS4lHB4rIRoYJjgmKy8xNTU1GiQ7QDszPy40NTEBDAwMEA8QHxISHzQrJCs0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NDQ0NP/AABEIARMAtwMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAA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jwsdQehrzxbqiDMHfmdqs3scpGgC7a6mZEjvSy8fK7qUHGnVtjImd/wrPcrl8OYloPQcxH1nzqe/ylhrrsdvlTGtnQSJIkDXaYnatMZoWqtmwTA2HeT9orWxfEnZmLMpYkEwIk5QsgchCiqCiNmEQTOsaadJqNhOuYRGafFtOXpO/aqnQs3d1cdyRJj5/hVd2pt5SoIkGDBid/UCq7OaVp4wrv3qFjNKxpgpNIdFJRRSMUUUUAUUUUAUUUUAUUUUAUU/3Z6U1VJ2oABqQPTfdnpR7s9KaVyzcMCP3X36azSuwgagTH8qCPvVWDEFQYnefwNPV208I027SAOvQU9p0sW7vw+af9lP8AxqLOTlImcu/PViv4/WmZyADlECI35Ekc+5otXGHwjUCJ5xM9Yo2NJCfB/L/MD/1NIWhTGoGYDyDKR/ypvvG2yjcGNd9TO/ekLkg+Ea776mR36gbUDQuOcpnfNB9Aark1NcZmnwjUkmOvPnUWQ9PyaVVDaKf7s9KQoaR9G0U4oelNoMUUUUAUUUUAUUUUAUUUUBIHJ5/anbAw32pmYfu/WkJHT60y0lDnWW+3f8+tBbX4tOulRSOh+f8AaiRyH1mgaS59YzaddKVm38f261G9yREDelW7HIc/rRsaPUgjVvt6UjED4W+1NS5AiKR7k8oo2Wkkifi+3aKar/xdxtvSG7yigXu1GxorvB0b7UgfbXp060iXI5UhcEkkfWg9JGbo3Xp6Uinq32qMkdPrQGHSgaSOx1AMjrpUNSi9AIA3qKkIKKKKDFFFFAFFFFMCiiigCiiigCiiigCiiigCiiigCiiigCiiigCiiigCiiigCiiigCiiigP/2Q==\",\n                  ),\n          ),\n      )\n    }\n  }\n\n  private fun onSearchMovie(event: MSMovieEvent.SearchMovieEvent): Flow<MSMovieResult> {\n    return flow {\n      emit(MSMovieResult.SearchMovieResult(loading = true))\n      try {\n        val movie = movieRepo.searchMovie(event.searchedMovieTitle)\n        emit(\n            MSMovieResult.SearchMovieResult(\n                movie = movie,\n                errorMessage = movie?.errorMessage ?: \"\",\n            ),\n        )\n      } catch (e: Exception) {\n        emit(\n            MSMovieResult.SearchMovieResult(\n                movie = MSMovie(result = false, errorMessage = e.localizedMessage),\n                errorMessage = e.localizedMessage ?: \"\",\n            ),\n        )\n      }\n    }\n  }\n\n  private fun onAddToHistory(event: MSMovieEvent.AddToHistoryEvent): Flow<MSMovieResult> {\n    return flow { emit(MSMovieResult.AddToHistoryResult(movie = event.searchedMovie)) }\n  }\n\n  private fun onRestoreFromHistory(\n      event: MSMovieEvent.RestoreFromHistoryEvent\n  ): Flow<MSMovieResult> {\n    return flow { emit(MSMovieResult.SearchMovieResult(movie = event.movieFromHistory)) }\n  }\n\n  // -----------------------------------------------------------------------------------\n  // Results -> ViewState\n\n  override fun resultToViewState(\n      currentViewState: MSMovieViewState,\n      result: MSMovieResult\n  ): MSMovieViewState {\n    return when {\n      result.loading -> {\n        currentViewState.copy(\n            searchBoxText = \"\",\n            searchedMovieTitle = \"Searching Movie...\",\n            searchedMovieRating = \"\",\n            searchedMoviePoster = \"\",\n            searchedMovieReference = null,\n        )\n      }\n      result.errorMessage.isNotBlank() -> {\n        currentViewState.copy(searchedMovieTitle = result.errorMessage)\n      }\n      else -> result.toViewState(currentViewState)\n    }\n  }\n\n  // -----------------------------------------------------------------------------------\n  // Results -> Effect\n\n  override fun resultToEffects(result: MSMovieResult): Flow<MSMovieEffect?> = result.toEffects()\n}\n"
  },
  {
    "path": "app/src/main/java/co/kaush/msusf/movies/MSMovieViewState.kt",
    "content": "package co.kaush.msusf.movies\n\ndata class MSMovieViewState(\n    val searchBoxText: String = \"Blade\",\n    val searchedMovieTitle: String = \"\",\n    val searchedMovieRating: String = \"\",\n    val searchedMoviePoster: String = \"\",\n    val searchedMovieReference: MSMovie? = null,\n    val adapterList: List<MSMovie> = emptyList()\n)\n\nsealed class MSMovieEffect {\n  object AddedToHistoryToastEffect : MSMovieEffect()\n}\n\nsealed class MSMovieEvent {\n  object ScreenLoadEvent : MSMovieEvent()\n  object LongRunningEvent : MSMovieEvent()\n  data class SearchMovieEvent(val searchedMovieTitle: String = \"\") : MSMovieEvent()\n  data class AddToHistoryEvent(val searchedMovie: MSMovie) : MSMovieEvent()\n  data class RestoreFromHistoryEvent(val movieFromHistory: MSMovie) : MSMovieEvent()\n}\n"
  },
  {
    "path": "app/src/main/res/drawable/ic_launcher_background.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<vector\n    android:height=\"108dp\"\n    android:width=\"108dp\"\n    android:viewportHeight=\"108\"\n    android:viewportWidth=\"108\"\n    xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <path android:fillColor=\"#26A69A\"\n          android:pathData=\"M0,0h108v108h-108z\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M9,0L9,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,0L19,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M29,0L29,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M39,0L39,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M49,0L49,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M59,0L59,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M69,0L69,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M79,0L79,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M89,0L89,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M99,0L99,108\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,9L108,9\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,19L108,19\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,29L108,29\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,39L108,39\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,49L108,49\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,59L108,59\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,69L108,69\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,79L108,79\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,89L108,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M0,99L108,99\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,29L89,29\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,39L89,39\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,49L89,49\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,59L89,59\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,69L89,69\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M19,79L89,79\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M29,19L29,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M39,19L39,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M49,19L49,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M59,19L59,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M69,19L69,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n    <path android:fillColor=\"#00000000\" android:pathData=\"M79,19L79,89\"\n          android:strokeColor=\"#33FFFFFF\" android:strokeWidth=\"0.8\"/>\n</vector>\n"
  },
  {
    "path": "app/src/main/res/drawable/ms_list_divider_space.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:shape=\"rectangle\">\n    <solid android:color=\"@android:color/transparent\"/>\n    <size android:height=\"@dimen/ms_spacing_list\"/>\n    <size android:width=\"@dimen/ms_spacing_list\"/>\n</shape>"
  },
  {
    "path": "app/src/main/res/drawable-v24/ic_launcher_foreground.xml",
    "content": "<vector xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  xmlns:aapt=\"http://schemas.android.com/aapt\"\n  android:height=\"108dp\"\n  android:viewportHeight=\"108\"\n  android:viewportWidth=\"108\"\n  android:width=\"108dp\">\n  <path\n    android:fillType=\"evenOdd\"\n    android:pathData=\"M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z\"\n    android:strokeColor=\"#00000000\"\n    android:strokeWidth=\"1\">\n    <aapt:attr name=\"android:fillColor\">\n      <gradient\n        android:endX=\"78.5885\"\n        android:endY=\"90.9159\"\n        android:startX=\"48.7653\"\n        android:startY=\"61.0927\"\n        android:type=\"linear\">\n        <item\n          android:color=\"#44000000\"\n          android:offset=\"0.0\"/>\n        <item\n          android:color=\"#00000000\"\n          android:offset=\"1.0\"/>\n      </gradient>\n    </aapt:attr>\n  </path>\n  <path\n    android:fillColor=\"#FFFFFF\"\n    android:fillType=\"nonZero\"\n    android:pathData=\"M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z\"\n    android:strokeColor=\"#00000000\"\n    android:strokeWidth=\"1\"/>\n</vector>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n  xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n  xmlns:tools=\"http://schemas.android.com/tools\"\n  android:layout_width=\"match_parent\"\n  android:layout_height=\"0dp\"\n  app:layout_constraintBottom_toTopOf=\"@id/longRunningTask\"\n  tools:context=\"co.kaush.msusf.movies.MSMovieActivity\">\n\n  <androidx.constraintlayout.widget.Guideline\n    android:id=\"@+id/ms_mainScreen_guideline_1\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    android:orientation=\"horizontal\"\n    app:layout_constraintGuide_percent=\"0.15\"/>\n\n  <androidx.constraintlayout.widget.Guideline\n    android:id=\"@+id/ms_mainScreen_guideline_2\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:orientation=\"vertical\"\n    app:layout_constraintGuide_percent=\"0.50\"/>\n\n  <ImageView\n      android:id=\"@+id/ms_mainScreen_poster\"\n      android:layout_width=\"wrap_content\"\n      android:layout_height=\"180dp\"\n      android:adjustViewBounds=\"true\"\n      android:scaleType=\"centerCrop\"\n      android:clickable=\"true\"\n      android:focusable=\"true\"\n      app:layout_constraintTop_toBottomOf=\"@id/ms_mainScreen_guideline_1\"\n\n      app:layout_constraintEnd_toStartOf=\"@+id/ms_mainScreen_guideline_2\"\n      app:layout_constraintStart_toStartOf=\"parent\"\n\n      tools:background=\"@android:color/holo_blue_bright\"\n      tools:ignore=\"ContentDescription\" />\n\n  <TextView\n    android:id=\"@+id/ms_mainScreen_title\"\n    android:textStyle=\"bold\"\n    android:layout_width=\"@dimen/ms_mainSreen_0\"\n    android:layout_height=\"wrap_content\"\n    android:textSize=\"@dimen/ms_mainSreen_titleSize\"\n\n    app:layout_constraintEnd_toEndOf=\"parent\"\n    app:layout_constraintStart_toEndOf=\"@id/ms_mainScreen_guideline_2\"\n    app:layout_constraintTop_toBottomOf=\"@id/ms_mainScreen_guideline_1\"\n\n    tools:text=\"Guardians of the Galaxy- Chapter 2\"/>\n\n  <TextView\n    android:id=\"@+id/ms_mainScreen_rating\"\n    android:textStyle=\"bold\"\n    android:layout_width=\"@dimen/ms_mainSreen_0\"\n    android:layout_height=\"wrap_content\"\n    android:textColor=\"@android:color/darker_gray\"\n    android:textSize=\"@dimen/ms_mainSreen_titleSize\"\n    app:layout_constraintEnd_toEndOf=\"parent\"\n    app:layout_constraintStart_toEndOf=\"@id/ms_mainScreen_guideline_2\"\n    app:layout_constraintTop_toBottomOf=\"@id/ms_mainScreen_title\"\n\n    tools:text=\"9.1/10\"/>\n\n  <Button\n    android:id=\"@+id/ms_mainScreen_searchBtn\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginBottom=\"@dimen/ms_spacing\"\n    android:layout_marginEnd=\"@dimen/ms_spacing\"\n    android:text=\"@string/ms_mainScree_searchBtnText\"\n    app:layout_constraintBottom_toTopOf=\"@id/ms_mainScreen_guideline_1\"\n    app:layout_constraintEnd_toEndOf=\"parent\"/>\n\n  <EditText\n    android:id=\"@+id/ms_mainScreen_searchText\"\n    android:layout_width=\"0dp\"\n    android:layout_height=\"wrap_content\"\n    android:layout_marginBottom=\"@dimen/ms_spacing\"\n    android:layout_marginLeft=\"@dimen/ms_spacing\"\n    android:layout_marginRight=\"@dimen/ms_spacing\"\n    android:inputType=\"text\"\n\n    app:layout_constraintBottom_toTopOf=\"@id/ms_mainScreen_guideline_1\"\n    app:layout_constraintEnd_toStartOf=\"@id/ms_mainScreen_searchBtn\"\n    app:layout_constraintStart_toStartOf=\"parent\"\n    tools:ignore=\"LabelFor\"/>\n\n  <androidx.constraintlayout.widget.Guideline\n    android:id=\"@+id/ms_mainScreen_guideline_3\"\n    android:layout_width=\"wrap_content\"\n    android:layout_height=\"wrap_content\"\n    android:orientation=\"horizontal\"\n    app:layout_constraintGuide_percent=\"0.55\"/>\n\n  <androidx.recyclerview.widget.RecyclerView\n    android:id=\"@+id/ms_mainScreen_searchHistory\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"wrap_content\"\n    app:layout_constraintBottom_toBottomOf=\"parent\"\n    app:layout_constraintTop_toBottomOf=\"@id/ms_mainScreen_guideline_3\"/>\n\n\n  <Button\n      android:id=\"@+id/longRunningTask\"\n      android:layout_width=\"match_parent\"\n      android:layout_height=\"wrap_content\"\n      android:text=\"Long running task\"\n      app:layout_constraintBottom_toBottomOf=\"parent\"\n      />\n\n</androidx.constraintlayout.widget.ConstraintLayout>\n"
  },
  {
    "path": "app/src/main/res/layout/view_movie.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<androidx.constraintlayout.widget.ConstraintLayout\n  xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n        xmlns:tools=\"http://schemas.android.com/tools\"\n        android:layout_width=\"100dp\"\n        android:layout_height=\"wrap_content\">\n\n\n    <ImageView\n            android:id=\"@+id/ms_result_poster\"\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"180dp\"\n            android:adjustViewBounds=\"true\"\n            android:scaleType=\"centerCrop\"\n\n            app:layout_constraintLeft_toLeftOf=\"parent\"\n            app:layout_constraintRight_toRightOf=\"parent\"\n            app:layout_constraintTop_toTopOf=\"parent\"\n            app:layout_constraintBottom_toBottomOf=\"parent\"\n\n            tools:ignore=\"ContentDescription\"\n            tools:background=\"@android:color/holo_blue_bright\"\n    />\n\n    <TextView\n            android:id=\"@+id/ms_result_rating\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"match_parent\"\n            android:gravity=\"center\"\n            android:textStyle=\"bold\"\n            android:textColor=\"@color/textColorLight\"\n\n            app:autoSizeTextType=\"uniform\"\n            app:autoSizeMaxTextSize=\"@dimen/ms_search_titleSize\"\n            app:layout_constraintLeft_toLeftOf=\"parent\"\n            app:layout_constraintRight_toRightOf=\"parent\"\n            app:layout_constraintTop_toTopOf=\"parent\"\n            app:layout_constraintBottom_toBottomOf=\"parent\"\n            tools:text=\"9.1/10 (Internet movie database)\"\n\n            tools:ignore=\"ContentDescription,MissingPrefix\"/>\n\n</androidx.constraintlayout.widget.ConstraintLayout>\n"
  },
  {
    "path": "app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<adaptive-icon xmlns:android=\"http://schemas.android.com/apk/res/android\">\n    <background android:drawable=\"@drawable/ic_launcher_background\"/>\n    <foreground android:drawable=\"@mipmap/ic_launcher_foreground\"/>\n</adaptive-icon>"
  },
  {
    "path": "app/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n  <color name=\"colorPrimary\">#3F51B5</color>\n  <color name=\"colorPrimaryDark\">#303F9F</color>\n  <color name=\"colorAccent\">#FF4081</color>\n  <color name=\"textColorLight\">#fff</color>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/dimens.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n  <dimen name=\"ms_spacing\">12dp</dimen>\n  <dimen name=\"ms_spacing_list\">10dp</dimen>\n  <dimen name=\"ms_mainSreen_0\">0dp</dimen>\n  <dimen name=\"ms_mainSreen_titleSize\">20sp</dimen>\n  <dimen name=\"ms_search_titleSize\">30sp</dimen>\n</resources>"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "content": "<resources>\n  <string name=\"app_name\">Movie Searching through USF</string>\n  <string name=\"ms_mainScree_searchBtnText\">Search</string>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "content": "<resources>\n\n  <!-- Base application theme. -->\n  <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n    <!-- Customize your theme here. -->\n    <item name=\"colorPrimary\">@color/colorPrimary</item>\n    <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n    <item name=\"colorAccent\">@color/colorAccent</item>\n  </style>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/tags.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources xmlns:android=\"http://schemas.android.com/apk/res/android\">\n  <item name=\"TAG_MOVIE_DATA\" type=\"id\"/>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/xml/network_security_config.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<network-security-config>\n  <domain-config cleartextTrafficPermitted=\"true\">\n    <domain includeSubdomains=\"true\">omdbapi.com</domain>\n  </domain-config>\n</network-security-config>"
  },
  {
    "path": "app/src/test/java/co/kaush/msusf/movies/CoroutineTestRule.kt",
    "content": "package co.kaush.msusf.movies\n\n/*\n * Copyright 2019 The Android 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 *     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\nimport kotlinx.coroutines.Dispatchers\nimport kotlinx.coroutines.ExperimentalCoroutinesApi\nimport kotlinx.coroutines.test.StandardTestDispatcher\nimport kotlinx.coroutines.test.TestCoroutineScheduler\nimport kotlinx.coroutines.test.TestDispatcher\nimport kotlinx.coroutines.test.resetMain\nimport kotlinx.coroutines.test.setMain\nimport org.junit.jupiter.api.extension.AfterEachCallback\nimport org.junit.jupiter.api.extension.BeforeEachCallback\nimport org.junit.jupiter.api.extension.ExtensionContext\n\n/**\n * Primary rule for Coroutine Tests.\n *\n * @constructor Create empty Test coroutine rule\n *\n * Use it as follows\n *\n * ```kotlin\n * class MyViewModelTest {\n *    @RegisterExtension val testRule = CoroutineTestRule()\n * }\n * ```\n */\n@ExperimentalCoroutinesApi\nclass CoroutineTestRule(\n    private val scheduler: TestCoroutineScheduler? =\n        null, // if you want multiple types of dispatchers\n    private val dispatcher: TestDispatcher? = null,\n) : BeforeEachCallback, AfterEachCallback {\n\n  val testDispatcher by lazy {\n    when {\n      dispatcher != null -> dispatcher\n      scheduler != null -> StandardTestDispatcher(scheduler)\n      else -> StandardTestDispatcher()\n    }\n  }\n\n  override fun beforeEach(p0: ExtensionContext?) {\n    // ⚠️ Calling this with a TestDispatcher has special behavior:\n    // subsequently-called runTest, as well as TestScope and test dispatcher constructors,\n    // will use the TestCoroutineScheduler of the provided dispatcher.\n\n    // This means in runTest you don't have to\n    Dispatchers.setMain(testDispatcher)\n  }\n\n  override fun afterEach(p0: ExtensionContext?) {\n    Dispatchers.resetMain()\n  }\n\n  fun currentTestTime(): Long {\n    return testDispatcher.scheduler.currentTime\n  }\n}\n"
  },
  {
    "path": "app/src/test/java/co/kaush/msusf/movies/MSMovieViewModelTest.kt",
    "content": "package co.kaush.msusf.movies\n\nimport app.cash.turbine.test\nimport co.kaush.msusf.movies.MSMovieEffect.AddedToHistoryToastEffect\nimport co.kaush.msusf.movies.MSMovieEvent.AddToHistoryEvent\nimport co.kaush.msusf.movies.MSMovieEvent.RestoreFromHistoryEvent\nimport co.kaush.msusf.movies.MSMovieEvent.ScreenLoadEvent\nimport co.kaush.msusf.movies.MSMovieEvent.SearchMovieEvent\nimport co.kaush.msusf.movies.di.TestAppComponent\nimport co.kaush.msusf.movies.di.blade\nimport co.kaush.msusf.movies.di.bladeRunner2049\nimport co.kaush.msusf.movies.di.create\nimport kotlinx.coroutines.ExperimentalCoroutinesApi\nimport kotlinx.coroutines.flow.first\nimport kotlinx.coroutines.flow.toList\nimport kotlinx.coroutines.launch\nimport kotlinx.coroutines.test.TestScope\nimport kotlinx.coroutines.test.runCurrent\nimport kotlinx.coroutines.test.runTest\nimport org.assertj.core.api.Assertions.assertThat\nimport org.junit.jupiter.api.DisplayName\nimport org.junit.jupiter.api.Test\nimport org.junit.jupiter.api.extension.RegisterExtension\n\n@OptIn(ExperimentalCoroutinesApi::class)\nclass MSMovieViewModelTest {\n\n  // Set the main coroutines dispatcher for unit testing.\n  @OptIn(ExperimentalCoroutinesApi::class)\n  @JvmField\n  @RegisterExtension\n  val testRule = CoroutineTestRule()\n\n  // Subject under test\n  private lateinit var viewModel: MSMovieViewModelImpl\n\n  // Use a fake repository to be injected into the viewModel\n  private val testAppComponent = TestAppComponent::class.create()\n  private var fakeMovieAppRepository: MSMovieRepository = testAppComponent.movieRepository\n\n  @Test\n  @DisplayName(\"on init, initial view state should have Blade pre-populated\")\n  fun onSubscription_InitialStateIsEmitted() = runTest {\n    viewModel = createTestViewModel()\n    val vs = viewModel.viewState.first()\n    assertThat(vs.searchBoxText).isEqualTo(\"Blade\")\n  }\n\n  @Test\n  @DisplayName(\"on screen load, search box test should be cleared\")\n  fun onScreenLoad_searchBoxText_shouldBeCleared() = runTest {\n    val vm = createTestViewModel()\n    assertThat(vm.viewState.first().searchBoxText).isEqualTo(\"Blade\") // starts off with blade\n    vm.processInput(ScreenLoadEvent)\n    runCurrent()\n    assertThat(vm.viewState.first().searchBoxText).isEmpty()\n  }\n\n  @Test\n  @DisplayName(\"on screen load, search box test should be cleared - using turbine\")\n  fun onScreenLoad_searchBoxText_shouldBeCleared_2() =\n      // Functionally the exact same test as the previous one\n      // we use turbine here as a demonstration\n      runTest {\n        viewModel = createTestViewModel()\n        viewModel.viewState.test() {\n          assertThat(awaitItem().searchBoxText).isEqualTo(\"Blade\") // starts off with blade\n          viewModel.processInput(ScreenLoadEvent)\n          // notice that we don't need to runCurrent()\n          // runCurrent()\n          // this is because Turbine uses an UnconfinedTestDispatcher internally\n          // https://github.com/cashapp/turbine/blob/trunk/src/commonMain/kotlin/app/cash/turbine/flow.kt#L199-L201\n          assertThat(awaitItem().searchBoxText).isEmpty()\n        }\n      }\n\n  @Test\n  @DisplayName(\"on search movie, show loading indicator\")\n  fun onSearchingMovie_showLoadingIndicator_ThenResult() = runTest {\n    viewModel = createTestViewModel()\n    viewModel.viewState.test {\n      skipItems(1) // starting state\n\n      viewModel.processInput(SearchMovieEvent(\"blade runner 2049\"))\n      assertThat(awaitItem().searchedMovieTitle).isEqualTo(\"Searching Movie...\")\n      with(awaitItem()) {\n        assertThat(searchedMovieTitle).isEqualTo(\"Blade Runner 2049\")\n        assertThat(searchedMoviePoster)\n            .isEqualTo(\n                \"https://m.media-amazon.com/images/M/MV5BNzA1Njg4NzYxOV5BMl5BanBnXkFtZTgwODk5NjU3MzI@._V1_SX300.jpg\",\n            )\n        assertThat(searchedMovieRating).isEqualTo(\"\\n8.1/10 (IMDB)\\n87% (RT)\")\n      }\n      expectNoEvents()\n    }\n  }\n\n  @Test\n  @DisplayName(\"click search result, should show it in history\")\n  fun onClickingMovieSearchResult_shouldPopulateHistoryList() = runTest {\n    viewModel = createTestViewModel()\n\n    val vs = mutableListOf<MSMovieViewState>()\n    val ve = mutableListOf<MSMovieEffect>()\n    backgroundScope.launch { viewModel.viewState.toList(vs) }\n    backgroundScope.launch { viewModel.effects.toList(ve) }\n\n    viewModel.processInput(SearchMovieEvent(\"blade runner 2049\"))\n    viewModel.processInput(AddToHistoryEvent(bladeRunner2049))\n\n    runCurrent()\n\n    vs[1].let {\n      assertThat(it.adapterList).hasSize(1)\n      assertThat(it.adapterList[0]).isEqualTo(bladeRunner2049)\n    }\n    assertThat(ve[0]).isEqualTo(AddedToHistoryToastEffect)\n  }\n\n  @Test\n  @DisplayName(\"adding to history twice, should show two toasts\")\n  fun onClickingMovieSearchResultTwice_shouldShowToastEachTime() = runTest {\n    viewModel = createTestViewModel()\n\n    val ve = mutableListOf<MSMovieEffect>()\n    backgroundScope.launch { viewModel.effects.toList(ve) }\n\n    viewModel.processInput(SearchMovieEvent(\"blade runner 2049\"))\n    assertThat(ve.size).isEqualTo(0)\n\n    viewModel.processInput(AddToHistoryEvent(bladeRunner2049))\n    runCurrent()\n    assertThat(ve[0]).isEqualTo(AddedToHistoryToastEffect)\n\n    viewModel.processInput(AddToHistoryEvent(bladeRunner2049))\n    runCurrent()\n    assertThat(ve[1]).isEqualTo(AddedToHistoryToastEffect)\n  }\n\n  @Test\n  fun onClickingMovieHistoryResult_ResultViewIsRepopulatedWithInfo() = runTest {\n    viewModel = createTestViewModel()\n    viewModel.viewState.test {\n      skipItems(1) // starting state\n\n      // populate history\n      viewModel.processInput(SearchMovieEvent(\"blade runner 2049\"))\n      skipItems(2)\n\n      viewModel.processInput(SearchMovieEvent(\"blade\"))\n      skipItems(2)\n\n      // click blade runner 2049 from history\n      viewModel.processInput(RestoreFromHistoryEvent(bladeRunner2049))\n      with(awaitItem()) {\n        assertThat(searchedMovieTitle).isEqualTo(\"Blade Runner 2049\")\n        assertThat(searchedMovieRating).isEqualTo(bladeRunner2049.ratingSummary)\n      }\n\n      // click blade again\n      viewModel.processInput(RestoreFromHistoryEvent(blade))\n      with(awaitItem()) {\n        assertThat(searchedMovieTitle).isEqualTo(\"Blade\")\n        assertThat(searchedMovieRating).isEqualTo(blade.ratingSummary)\n      }\n    }\n  }\n\n  private fun TestScope.createTestViewModel() =\n      MSMovieViewModelImpl(fakeMovieAppRepository, backgroundScope, testRule.testDispatcher)\n}\n"
  },
  {
    "path": "app/src/test/java/co/kaush/msusf/movies/di/TestMSAppDI.kt",
    "content": "package co.kaush.msusf.movies.di\n\nimport co.kaush.msusf.di.AppScope\nimport co.kaush.msusf.di.CommonAppComponent\nimport co.kaush.msusf.movies.MSMovie\nimport co.kaush.msusf.movies.MSMovieRepository\nimport co.kaush.msusf.movies.MSRating\nimport kotlinx.coroutines.runBlocking\nimport me.tatarka.inject.annotations.Component\nimport me.tatarka.inject.annotations.Provides\nimport org.mockito.kotlin.doReturn\nimport org.mockito.kotlin.mock\n\ninternal val bladeRunner2049 by lazy {\n  val ratingImdb =\n      MSRating(\n          source = \"Internet Movie Database\",\n          rating = \"8.1/10\",\n      )\n\n  val ratingRottenTomatoes =\n      MSRating(\n          source = \"Rotten Tomatoes\",\n          rating = \"87%\",\n      )\n\n  MSMovie(\n      result = true,\n      errorMessage = null,\n      title = \"Blade Runner 2049\",\n      ratings = listOf(ratingImdb, ratingRottenTomatoes),\n      posterUrl =\n          \"https://m.media-amazon.com/images/M/MV5BNzA1Njg4NzYxOV5BMl5BanBnXkFtZTgwODk5NjU3MzI@._V1_SX300.jpg\",\n  )\n}\n\ninternal val blade by lazy {\n  val ratingImdb =\n      MSRating(\n          source = \"Internet Movie Database\",\n          rating = \"7.1/10\",\n      )\n\n  val ratingRottenTomatoes =\n      MSRating(\n          source = \"Rotten Tomatoes\",\n          rating = \"54%\",\n      )\n\n  MSMovie(\n      result = true,\n      errorMessage = null,\n      title = \"Blade\",\n      ratings = listOf(ratingImdb, ratingRottenTomatoes),\n      posterUrl =\n          \"https://m.media-amazon.com/images/M/MV5BMTQ4MzkzNjcxNV5BMl5BanBnXkFtZTcwNzk4NTU0Mg@@._V1_SX300.jpg\",\n  )\n}\n\ninternal val movieNotFound by lazy {\n  val ratingImdb =\n      MSRating(\n          source = \"Internet Movie Database\",\n          rating = \"8.1/10\",\n      )\n\n  val ratingRottenTomatoes =\n      MSRating(\n          source = \"Rotten Tomatoes\",\n          rating = \"87%\",\n      )\n\n  MSMovie(\n      result = true,\n      errorMessage = null,\n      title = \"Blade Runner 2049\",\n      ratings = listOf(ratingImdb, ratingRottenTomatoes),\n      posterUrl =\n          \"https://m.media-amazon.com/images/M/MV5BNzA1Njg4NzYxOV5BMl5BanBnXkFtZTgwODk5NjU3MzI@._V1_SX300.jpg\",\n  )\n}\n\nclass TestFakes {\n\n  @Provides\n  fun provideFakeMovieRepository(): MSMovieRepository {\n    return mock<MSMovieRepository> {\n      on { runBlocking { searchMovie(\"blade runner 2049\") } } doReturn bladeRunner2049\n\n      on { runBlocking { searchMovie(\"blade\") } } doReturn blade\n    }\n  }\n}\n\n@AppScope\n@Component\nabstract class TestAppComponent(@Component val fakes: TestFakes = TestFakes()) :\n    CommonAppComponent()\n"
  },
  {
    "path": "build.gradle.kts",
    "content": "@file:Suppress(\"DSL_SCOPE_VIOLATION\") // TODO: Remove once KTIJ-19369 is fixed (or agp 8.1)\nplugins {\n  alias(libs.plugins.spotless)\n  alias(libs.plugins.kotlin.jvm) apply false\n  alias(libs.plugins.kotlin.android) apply false\n  // https://youtrack.jetbrains.com/issue/KT-46200\n  alias(libs.plugins.android.application) apply false\n  alias(libs.plugins.android.library) apply false\n  alias(libs.plugins.secrets.gradle.plugin) apply false\n}\n\nspotless {\n  kotlin {\n    target(\"**/*.kt\")\n    targetExclude(\"**/build/**/*.kt\")\n    ktfmt(\"0.43\")\n  }\n\n  format(\"kts\") {\n    target(\"**/*.gradle.kts\")\n    targetExclude(\"**/build/**/*.kts\")\n  }\n}\n"
  },
  {
    "path": "gradle/libs.versions.toml",
    "content": "\n[versions]\n#region ------------------ VERSIONS --------------------------\ncompileSdk = \"34\"\nminSdk = \"21\"\n\nappVersionCode = \"2\"\nappVersionName = \"23.063.000\"\n\ngradle = \"8.7\" # Gradle\nandroid-gradle-plugin = \"8.3.2\" # AGP\n\nkotlin = \"1.9.23\"\nkotlin-coroutines = \"1.8.0\"\nkotlin-serialization = \"1.6.3\"\nkotlin-compiler = \"1.5.11\"\nkotlin-bcv = \"0.13.2\"\n\nandroidx-annotation = \"1.7.1\"\nandroidx-compose-bom = \"2024.04.01\" # https://developer.android.com/jetpack/compose/bom/bom-mapping\nandroidx-compose-compiler = \"1.4.2\" # https://developer.android.com/jetpack/androidx/releases/compose-kotlin#kts\nandroidx-compose = \"1.6.5\"\nandroidx-constraintlayout = \"2.1.4\"\nandroidx-datastore = \"1.1.0\"\nandroidx-lifecycle = \"2.7.0\"\nandroidx-navigation = \"2.7.7\"\nandroidx-work = \"2.9.0\"\nandroidx-room = \"2.6.1\"\nandroidx-appcompat = \"1.1.0\"\nandroidx-test = \"1.5.2\"\nandroidx-activity = \"1.7.2\"\n\nfirebase-bom = \"32.8.1\"\nfirebase-crashlytics = \"18.6.4\"\nfirebase-crashlytics-plugin = \"2.9.9\"\n\ngoogle-ksp = \"1.9.23-1.0.19\" # first half is kotlin version\ngoogle-protobuf = \"3.25.3\"\ngoogle-gms = \"4.4.1\"\ngoogle-dagger = \"2.51.1\"\n\nassertj = \"3.25.3\"\nanvil = \"2.4.9\"\ncoil = \"2.6.0\"\ndatadog = \"2.8.0\"\nandroid-desugar-jdk = \"2.0.4\"\nespresso = \"3.3.0\"\nflowbinding = \"1.2.0\"\ngrcp = \"1.63.0\"\njackson = \"2.17.0\"\njacoco = \"0.8.12\"\njunit = \"4.12\"\njunit-platform = \"1.10.0.0\"\njunit5 = \"5.10.2\"\nkotlinInject = \"0.6.1\"\nkotlinpoet = \"1.12.0\"\nleakCanary = \"2.11\"\nlottie = \"6.4.0\"\nmockito = \"5.11.0\"\nmockitoKotlin = \"5.0.0\"\nokhttp = \"4.12.0\"\npaparazzi = \"1.3.3\"\npicasso = \"2.71828\"\nretrofit = \"2.11.0\"\nsecretsGradlePlugin = \"2.0.1\"\nspotless = \"6.15.0\"\ntimber = \"4.7.1\"\ntrueTime = \"4.0.0.alpha\"\ntruth = \"0.42\"\nturbine = \"1.0.0\"\n#endregion\n\n[plugins]\n#region ------------------ PLUGINS --------------------------\nandroid-application = { id = \"com.android.application\", version.ref = \"android-gradle-plugin\" }\nandroid-library = { id = \"com.android.library\", version.ref = \"android-gradle-plugin\" }\nandroid-test = { id = \"com.android.test\", version.ref = \"android-gradle-plugin\" }\nandroid-baseline = { id = \"androidx.baselineprofile\", version = \"1.2.4\" }\n\nkotlin-android = { id = \"org.jetbrains.kotlin.android\", version.ref = \"kotlin\" }\nkotlin-allopen = { id = \"org.jetbrains.kotlin.plugin.allopen\",  version.ref = \"kotlin\" }  #\nkotlin-jvm = { id = \"org.jetbrains.kotlin.jvm\", version.ref = \"kotlin\" }\nkotlin-kapt = { id = \"org.jetbrains.kotlin.kapt\", version.ref = \"kotlin\" }\nkotlin-kovert = { id = \"org.jetbrains.kotlinx.kovert\", version = \"0.8.0-Beta2\" }\nkotlin-lombok = { id = \"org.jetbrains.kotlin.plugin.lombok\", version.ref = \"kotlin\" }\nkotlin-multiplatform = { id = \"org.jetbrains.kotlin.multiplatform\", version.ref = \"kotlin\" }\nkotlin-parcelize = { id = \"org.jetbrains.kotlin.plugin.parcelize\", version.ref = \"kotlin\" }\nkotlin-samreceiver = { id = \"org.jetbrains.kotlin.plugin.sam.with.receiver\", version.ref = \"kotlin\" }\nkotlin-serialization = { id = \"org.jetbrains.kotlin.plugin.serialization\", version.ref = \"kotlin\" }\nkotlin-compatibilityValidator = { id = \"org.jetbrains.kotlinx.binary-compatibility-validator\", version.ref = \"kotlin-bcv\" }\n\n\ngoogle-ksp = { id = \"com.google.devtools.ksp\", version.ref = \"google-ksp\" }\ngoogle-firebase-crashlytics = { id = \"com.google.firebase.crashlytics\", version.ref = \"firebase-crashlytics-plugin\" }\ngoogle-protobuf = { id = \"com.google.protobuf\", version = \"google-protobuf\" }\ngoogle-services = { id = \"com.google.gms.google-services\", version = \"google-gms\" }\n\nmannodermaus-junit5 = { id = \"de.mannodermaus.android-junit5\", version.ref = \"junit-platform\" }\nspotless = { id = \"com.diffplug.spotless\", version.ref = \"spotless\" }\nsecrets-gradle-plugin = { id = \"com.google.android.libraries.mapsplatform.secrets-gradle-plugin\", version.ref = \"secretsGradlePlugin\" }\n#endregion\n\n[libraries]\n#region ------------------ SINGLE ARTIFACT DEPENDENCIES --------------------------\ncoil = { group = \"io.coil-kt\", name = \"coil\", version.ref = \"coil\" }\nandroid-desugar-jdk = { group = \"com.android.tools\", name = \"desugar_jdk_libs\", version.ref = \"android-desugar-jdk\" }\nflow-binding = { group = \"io.github.reactivecircus.flowbinding\", name = \"flowbinding-android\", version.ref = \"flowbinding\" }\ninstacart-truetime = { group = \"com.github.instacart\", name = \"truetime-android\", version.ref = \"trueTime\" }\ntesting-assertj-core = { group = \"org.assertj\", name = \"assertj-core\", version.ref = \"assertj\" }\ntimber = { group = \"com.jakewharton.timber\", name = \"timber\", version.ref = \"timber\" }\ntesting-turbine = { group = \"app.cash.turbine\", name = \"turbine\", version.ref = \"turbine\" }\n#endregion\n\n#region ------------------ FAMILY ARTIFACT DEPENDENCIES --------------------------\nandroidx-activity-compose = { module = \"androidx.activity:activity-compose\", version.ref = \"androidx-activity\" }\nandroidx-activity-ktx = { module = \"androidx.activity:activity-ktx\", version.ref = \"androidx-activity\" }\nandroidx-appcompat = { group = \"androidx.appcompat\", name = \"appcompat\", version.ref = \"androidx-appcompat\" }\nandroidx-atsl-runner = { group = \"androidx.test\", name = \"runner\", version.ref = \"androidx-test\" }\nandroidx-compose-bom = { module = \"androidx.compose:compose-bom\", version.ref = \"androidx-compose-bom\" }\nandroidx-compose-material3 = { module = \"androidx.compose.material3:material3\" }\nandroidx-compose-ui-tooling = { module = \"androidx.compose.ui:ui-tooling\" }\nandroidx-compose-ui-tooling-preview = { module = \"androidx.compose.ui:ui-tooling-preview\" }\nandroidx-compose-ui-ui = { module = \"androidx.compose.ui:ui\" }\nandroidx-constraintlayout = { group = \"androidx.constraintlayout\", name = \"constraintlayout\", version.ref = \"androidx-constraintlayout\" }\nandroidx-espresso-core = { group = \"androidx.test.espresso\", name = \"espresso-core\", version.ref = \"espresso\" }\nandroidx-lifecycle-compiler = { group = \"androidx.lifecycle\", name = \"lifecycle-compiler\", version.ref = \"androidx-lifecycle\" }\nandroidx-lifecycle-runtime = { group = \"androidx.lifecycle\", name = \"lifecycle-runtime\", version.ref = \"androidx-lifecycle\" }\nandroidx-lifecycle-runtime-ktx = { group = \"androidx.lifecycle\", name = \"lifecycle-runtime-ktx\", version.ref = \"androidx-lifecycle\" }\nandroidx-lifecycle-viewmodel = { group = \"androidx.lifecycle\", name = \"lifecycle-viewmodel\", version.ref = \"androidx-lifecycle\" }\nandroidx-lifecycle-viewmodel-ktx = { group = \"androidx.lifecycle\", name = \"lifecycle-viewmodel-ktx\", version.ref = \"androidx-lifecycle\" }\nandroidx-lifecycle-viewmodel-savedstate = { group = \"androidx.lifecycle\", name = \"lifecycle-viewmodel-savedstate\", version.ref = \"androidx-lifecycle\" }\nandroidx-recyclerview = { group = \"androidx.recyclerview\", name = \"recyclerview\", version.ref = \"androidx-appcompat\" }\nandroidx-swiperefreshlayout = { group = \"androidx.swiperefreshlayout\", name = \"swiperefreshlayout\", version.ref = \"androidx-appcompat\" }\n\ngoogle-dagger =          { group = \"com.google.dagger\", name = \"dagger\", version.ref = \"google-dagger\" }\ngoogle-dagger-compiler = { group = \"com.google.dagger\", name = \"dagger-compiler\", version.ref = \"google-dagger\" }\ngoogle-truth = { group = \"com.google.truth\", name = \"truth\", version.ref = \"truth\" }\ngoogle-ksp = { group = \"com.google.devtools.ksp\", name = \"symbol-processing-api\", version.ref = \"google-ksp\" }\ngoogle-firebase-bom = { group = \"com.google.firebase\", name = \"firebase-bom\", version.ref = \"firebase-bom\" }\ngoogle-firebase-crashlytics = { group = \"com.google.firebase\", name = \"firebase-crashlytics\", version.ref = \"firebase-crashlytics\" }\ngoogle-firebase-ndk = { group = \"com.google.firebase\", name = \"firebase-crashlytics-ndk\", version.ref = \"firebase-crashlytics\" }\n\ntesting-junit5-bom = { group = \"org.junit\", name = \"junit-bom\", version.ref = \"junit5\" }\ntesting-junit5 = { group = \"org.junit.jupiter\", name = \"junit-jupiter\", version.ref = \"junit5\" }\ntesting-junit5-accesor = { group = \"org.junit.jupiter\", name = \"junit-jupiter\", version.ref = \"junit5\" }\ntesting-junit5-api = { group = \"org.junit.jupiter\", name = \"junit-jupiter-api\", version.ref = \"junit5\" }\ntesting-junit5-engine = { group = \"org.junit.jupiter\", name = \"junit-jupiter-engine\", version.ref = \"junit5\" }\ntesting-junit5-migrationsupport = { group = \"org.junit.jupiter\", name = \"junit-jupiter-migrationsupport\", version.ref = \"junit5\" }\ntesting-junit5-params = { group = \"org.junit.jupiter\", name = \"junit-jupiter-params\", version.ref = \"junit5\" }\n\nkotlin-stdlib = { group = \"org.jetbrains.kotlin\", name = \"kotlin-stdlib-jdk8\", version.ref = \"kotlin\" }\nkotlinx-coroutines-android = { group = \"org.jetbrains.kotlinx\", name = \"kotlinx-coroutines-android\", version.ref = \"kotlin-coroutines\" }\nkotlinx-coroutines-core = { group = \"org.jetbrains.kotlinx\", name = \"kotlinx-coroutines-core\", version.ref = \"kotlin-coroutines\" }\nkotlinx-coroutines-test = { group = \"org.jetbrains.kotlinx\", name = \"kotlinx-coroutines-test\", version.ref = \"kotlin-coroutines\" }\n\nsquare-kotlinpoet-core = { group = \"com.squareup\", name = \"kotlinpoet\", version.ref = \"kotlinpoet\" }\nsquare-kotlinpoet-ksp = { group = \"com.squareup\", name = \"kotlinpoet-ksp\", version.ref = \"kotlinpoet\" }\nsquare-leakcanary = { group = \"com.squareup.leakcanary\", name = \"leakcanary-android\", version.ref = \"leakCanary\" }\nsquare-leakcanary-noop = { group = \"com.squareup.leakcanary\", name = \"leakcanary-android-no-op\", version.ref = \"leakCanary\" }\nsquare-okhttp-bom = { module = \"com.squareup.okhttp3:okhttp-bom\", version.ref = \"okhttp\" }\nsquare-okhttp = { group = \"com.squareup.okhttp3\", name = \"okhttp\" }\nsquare-okhttp-logging-interceptor = { group = \"com.squareup.okhttp3\", name = \"logging-interceptor\" }\nsquare-picasso = { group = \"com.squareup.picasso\", name = \"picasso\", version.ref = \"picasso\" }\nsquare-retrofit = { group = \"com.squareup.retrofit2\", name = \"retrofit\", version.ref = \"retrofit\" }\nsquare-retrofit-gson = { group = \"com.squareup.retrofit2\", name = \"converter-gson\", version.ref = \"retrofit\" }\nsquare-retrofit-mock = { group = \"com.squareup.retrofit2\", name = \"retrofit-mock\", version.ref = \"retrofit\" }\n\nkotlin-inject-compiler = { group = \"me.tatarka.inject\", name = \"kotlin-inject-compiler-ksp\", version.ref = \"kotlinInject\" }\nkotlin-inject-runtime = { group = \"me.tatarka.inject\", name = \"kotlin-inject-runtime\", version.ref = \"kotlinInject\" }\n\nmockito-core = { group = \"org.mockito\", name = \"mockito-core\", version.ref = \"mockito\" }\nmockito-kotlin = { group = \"org.mockito.kotlin\", name = \"mockito-kotlin\", version.ref = \"mockitoKotlin\" }\n#endregion\n\n\n#TODO: arrange all this and rename it better\n"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-8.7-bin.zip\nnetworkTimeout=10000\nvalidateDistributionUrl=true\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\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.\norg.gradle.jvmargs=-Xmx1536m\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\n# org.gradle.parallel=true\n\nandroid.useAndroidX=true\nandroid.enableJetifier=true"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\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\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\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\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\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\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\" ] ; 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# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\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\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\nset DIRNAME=%~dp0\r\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\r\nset APP_BASE_NAME=%~n0\r\nset APP_HOME=%DIRNAME%\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 Windowz variants\r\n\r\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\r\nif \"%@eval[2+2]\" == \"4\" goto 4NT_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\ngoto execute\r\n\r\n:4NT_args\r\n@rem Get arguments from the 4NT Shell from JP Software\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.kts",
    "content": "pluginManagement {\n  repositories {\n    google()\n    mavenCentral()\n    gradlePluginPortal()\n  }\n}\n\ndependencyResolutionManagement {\n  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n  repositories {\n    gradlePluginPortal()\n    google()\n    mavenCentral()\n    maven(\"https://jitpack.io\")\n    maven(\"https://oss.sonatype.org/content/repositories/snapshots\")\n    mavenLocal()\n  }\n}\n\nrootProject.name = \"Movies USF Android\"\n\ninclude(\":app\")\n\ninclude(\n    \":usf:annotations\",\n    \":usf:annotations-processors\",\n    \":usf:api\",\n)\n"
  },
  {
    "path": "usf/annotations/build.gradle.kts",
    "content": "@file:Suppress(\"DSL_SCOPE_VIOLATION\") // TODO: Remove once KTIJ-19369 is fixed (or agp 8.1)\nplugins { alias(libs.plugins.kotlin.jvm) }\n"
  },
  {
    "path": "usf/annotations/src/main/java/co/kaush/msusf/annotations/UsfViewModel.kt",
    "content": "package co.kaush.msusf.annotations\n\n@Target(AnnotationTarget.CLASS) // targeting classes\n@Retention(AnnotationRetention.SOURCE) // valid in compile time and removed in binary output\n@MustBeDocumented // allows annotation to be included in generated docs\nannotation class UsfViewModel\n"
  },
  {
    "path": "usf/annotations-processors/build.gradle.kts",
    "content": "@file:Suppress(\"DSL_SCOPE_VIOLATION\") // TODO: Remove once KTIJ-19369 is fixed (or agp 8.1)\nplugins {\n  alias(libs.plugins.kotlin.jvm)\n  alias(libs.plugins.google.ksp)\n}\n\ndependencies {\n  implementation(project(\":usf:annotations\"))\n  implementation(libs.google.ksp)\n  implementation(libs.square.kotlinpoet.core)\n  implementation(libs.square.kotlinpoet.ksp)\n}\n"
  },
  {
    "path": "usf/annotations-processors/src/main/java/co/kaush/msusf/processors/UsfViewModelClassBuilderDefinition.kt",
    "content": "package co.kaush.msusf.processors\n\nimport com.squareup.kotlinpoet.TypeName\n\ndata class UsfViewModelClassBuilderDefinition(\n    val parameters: List<ParametersDefinition>,\n    val functions: List<FunctionsDefinition>,\n    val properties: List<ParametersDefinition>,\n    val viewModel: ParametersDefinition\n) {\n  val simplifiedClassName: String\n    get() {\n      val vmConstant = \"ViewModel\"\n      val className = this.viewModel.paramName\n      val indexOfViewModel = className.indexOf(vmConstant)\n      return if (indexOfViewModel != -1) {\n        className.substring(0, indexOfViewModel + vmConstant.length)\n      } else {\n        className + \"GenViewModel\"\n      }\n    }\n}\n\ndata class FunctionsDefinition(\n    val name: String,\n    val parameters: List<ParametersDefinition>,\n    val returnType: TypeName?\n)\n\ndata class ParametersDefinition(\n    val paramName: String,\n    val paramType: TypeName,\n)\n"
  },
  {
    "path": "usf/annotations-processors/src/main/java/co/kaush/msusf/processors/UsfViewModelFileBuilder.kt",
    "content": "package co.kaush.msusf.processors\n\nimport com.squareup.kotlinpoet.AnnotationSpec\nimport com.squareup.kotlinpoet.ClassName\nimport com.squareup.kotlinpoet.FileSpec\nimport com.squareup.kotlinpoet.FunSpec\nimport com.squareup.kotlinpoet.KModifier\nimport com.squareup.kotlinpoet.ParameterSpec\nimport com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy\nimport com.squareup.kotlinpoet.PropertySpec\nimport com.squareup.kotlinpoet.TypeSpec\nimport com.squareup.kotlinpoet.asClassName\n\n/** This is the primary class that builds out the structure of the ViewModel class */\nobject UsfViewModelFileBuilder {\n\n  private const val androidxPackage = \"androidx.lifecycle\"\n  private val androidViewModelTypeClassName = ClassName(androidxPackage, \"ViewModel\")\n\n  private val viewModelProviderTypeClassName =\n      ClassName(androidxPackage, \"ViewModelProvider.Factory\")\n\n  private const val kotlinxPackage = \"kotlinx.coroutines\"\n  private val coroutineScopeClassName = ClassName(kotlinxPackage, \"CoroutineScope\")\n\n  private const val viewModelScopeReservedWord = \"viewModelScope\"\n\n  /** File level structure */\n  fun buildFileSpec(\n      viewModelClassBuilderDefinition: UsfViewModelClassBuilderDefinition,\n      packageName: String,\n  ): FileSpec {\n    return FileSpec.builder(packageName, viewModelClassBuilderDefinition.simplifiedClassName)\n        .addType(buildAndroidViewModelClassSpec(viewModelClassBuilderDefinition))\n        .addImport(androidxPackage, \"viewModelScope\", \"ViewModelProvider\")\n        .build()\n  }\n\n  /** Class level structure */\n  private fun buildAndroidViewModelClassSpec(\n      viewModelClassBuilderDefinition: UsfViewModelClassBuilderDefinition,\n  ): TypeSpec {\n\n    val classBuilder =\n        TypeSpec.classBuilder(viewModelClassBuilderDefinition.simplifiedClassName)\n            .addModifiers(KModifier.PUBLIC)\n            .superclass(androidViewModelTypeClassName)\n\n    val constructorBuilder = FunSpec.constructorBuilder()\n\n    val paramsForConstructor =\n        buildParamForwardingConstructorBody(\n            viewModelClassBuilderDefinition.parameters, setOf(), setOf(coroutineScopeClassName)) {\n                sb,\n                param ->\n              when (param.paramType) {\n                coroutineScopeClassName -> {\n                  sb.append(\"\\t${param.paramName} = $viewModelScopeReservedWord,\\n\")\n                }\n                else -> {\n                  // no-op\n                }\n              }\n            }\n\n    addParamsToClassConstructor(\n        viewModelClassBuilderDefinition, constructorBuilder, classBuilder, false)\n\n    classBuilder.addProperty(\n        PropertySpec.builder(\n                viewModelClassBuilderDefinition.viewModel.paramName,\n                viewModelClassBuilderDefinition.viewModel.paramType,\n                KModifier.PRIVATE)\n            .initializer(\n                \"${(viewModelClassBuilderDefinition.viewModel.paramType as? ClassName)?.simpleName}$paramsForConstructor\")\n            .build())\n    classBuilder.primaryConstructor(constructorBuilder.build())\n\n    viewModelClassBuilderDefinition.functions.forEach { functionMetaData ->\n      val functionBuilder = FunSpec.builder(functionMetaData.name).addModifiers(KModifier.PUBLIC)\n\n      val params = functionMetaData.parameters.map { ParameterSpec(it.paramName, it.paramType) }\n      functionBuilder.addParameters(params)\n\n      val funcCallString =\n          \"${viewModelClassBuilderDefinition.viewModel.paramName}.${functionMetaData.name}${buildParamForwardingConstructorBody(functionMetaData.parameters)}\"\n\n      if (functionMetaData.returnType != null) {\n        functionBuilder.returns(functionMetaData.returnType)\n      }\n\n      val codeBody =\n          if (functionMetaData.returnType != null) {\n            \"return $funcCallString\"\n          } else {\n            funcCallString\n          }\n\n      functionBuilder.addCode(codeBody)\n      classBuilder.addFunction(functionBuilder.build())\n    }\n\n    viewModelClassBuilderDefinition.properties.forEach { propertyMetaData ->\n      val property =\n          PropertySpec.builder(propertyMetaData.paramName, propertyMetaData.paramType)\n              .getter(\n                  FunSpec.getterBuilder()\n                      .addStatement(\n                          \"return ${viewModelClassBuilderDefinition.viewModel.paramName}.${propertyMetaData.paramName}\")\n                      .build())\n\n      classBuilder.addProperty(property.build())\n    }\n\n    classBuilder.addType(buildFactory(viewModelClassBuilderDefinition))\n\n    return classBuilder.build()\n  }\n\n  private fun buildFactory(\n      ViewModelClassBuilderDefinition: UsfViewModelClassBuilderDefinition\n  ): TypeSpec {\n    val classBuilder =\n        TypeSpec.classBuilder(\"${ViewModelClassBuilderDefinition.simplifiedClassName}Factory\")\n            .addSuperinterface(viewModelProviderTypeClassName)\n\n    val constructorBuilder = FunSpec.constructorBuilder()\n\n    val paramsForConstructor =\n        buildParamForwardingConstructorBody(\n            ViewModelClassBuilderDefinition.parameters, setOf(coroutineScopeClassName), emptySet())\n\n    addParamsToClassConstructor(\n        ViewModelClassBuilderDefinition, constructorBuilder, classBuilder, true)\n\n    val genericViewModel =\n        com.squareup.kotlinpoet.TypeVariableName(\"T\", androidViewModelTypeClassName)\n\n    val suppressAnnotation =\n        AnnotationSpec.Companion.builder(Suppress::class).addMember(\"%S\", \"UNCHECKED_CAST\").build()\n\n    val factoryCreateFunctionSpec =\n        FunSpec.builder(\"create\")\n            .addTypeVariable(genericViewModel)\n            .addAnnotation(suppressAnnotation)\n            .addParameter(\n                \"modelClass\", Class::class.asClassName().parameterizedBy(genericViewModel))\n            .addCode(\n                \"return ${ViewModelClassBuilderDefinition.simplifiedClassName}$paramsForConstructor as T\")\n            .returns(genericViewModel)\n            .addModifiers(KModifier.OVERRIDE)\n\n    classBuilder.addFunction(factoryCreateFunctionSpec.build())\n    classBuilder.primaryConstructor(constructorBuilder.build())\n\n    return classBuilder.build()\n  }\n\n  private fun addParamsToClassConstructor(\n      ViewModelClassBuilderDefinition: UsfViewModelClassBuilderDefinition,\n      constructorBuilder: FunSpec.Builder,\n      classBuilder: TypeSpec.Builder,\n      addAsProperty: Boolean\n  ) {\n    for (paramMetaData in ViewModelClassBuilderDefinition.parameters) {\n\n      // TODO: better way to do this\n      if (paramMetaData.paramType == coroutineScopeClassName) {\n        continue\n      }\n\n      constructorBuilder.addParameter(paramMetaData.paramName, paramMetaData.paramType)\n\n      if (addAsProperty) {\n        classBuilder.addProperty(\n            PropertySpec.builder(\n                    paramMetaData.paramName, paramMetaData.paramType, KModifier.PRIVATE)\n                .initializer(paramMetaData.paramName)\n                .build())\n      }\n    }\n  }\n\n  private fun buildParamForwardingConstructorBody(\n      params: List<ParametersDefinition>,\n      ignoreList: Set<ClassName> = emptySet(),\n      overrides: Set<ClassName> = emptySet(),\n      overrideAction: ((StringBuilder, ParametersDefinition) -> Unit)? = null\n  ): String {\n\n    return buildString {\n      append(\"(\\n\")\n      for (param in params) {\n        if (ignoreList.contains(param.paramType)) {\n          continue\n        }\n\n        if (overrides.contains(param.paramType)) {\n          overrideAction?.let { it(this, param) }\n          continue\n        }\n\n        append(\"\\t${param.paramName} = ${param.paramName},\\n\")\n      }\n\n      if (params.isNotEmpty()) {\n        delete(length - 2, length)\n      }\n      append(\"\\n)\")\n    }\n  }\n}\n"
  },
  {
    "path": "usf/annotations-processors/src/main/java/co/kaush/msusf/processors/UsfViewModelProcessor.kt",
    "content": "package co.kaush.msusf.processor\n\nimport co.kaush.msusf.annotations.UsfViewModel\nimport co.kaush.msusf.processors.UsfViewModelVisitor\nimport com.google.devtools.ksp.processing.CodeGenerator\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.processing.Resolver\nimport com.google.devtools.ksp.processing.SymbolProcessor\nimport com.google.devtools.ksp.symbol.KSAnnotated\nimport com.google.devtools.ksp.symbol.KSClassDeclaration\nimport com.google.devtools.ksp.validate\nimport com.squareup.kotlinpoet.asClassName\n\n/**\n * This processor handles all classes annotated with @[UsfViewModel].\n *\n * You typically annotate a ViewModel implementation class (*VMImpl) with @[UsfViewModel]. The\n * processor then goes on to generate the corresponding *VM boilerplate code necessary to access the\n * ViewModel from an Activity/Fragment.\n *\n * @param codeGenerator [CodeGenerator] responsible for creating the files that will be generated\n *   using the code from the processor\n * @param logger [KSPLogger] responsible for logging messages to the console (errors/warnings)\n */\nclass UsfViewModelProcessor(\n    private val codeGenerator: CodeGenerator,\n    private val logger: KSPLogger,\n    private val options: Map<String, String>,\n) : SymbolProcessor {\n\n  /**\n   * This function contains the main logic to process the [ViewModel] annotation.\n   *\n   * @param resolver [Resolver] helps you grab a bunch of info on class annotated with\n   *   [UsfViewModel] including classes, properties, functions (each having their own\n   *   [KDeclaration])\n   */\n  override fun process(resolver: Resolver): List<KSAnnotated> {\n    val viewModelClassName = UsfViewModel::class.asClassName()\n\n    // find all classes that have been annotated with @UsfViewModel\n    val symbols =\n        resolver\n            .getSymbolsWithAnnotation(viewModelClassName.toString())\n            .filterIsInstance<KSClassDeclaration>()\n\n    // symbols is a [Sequence] not a [List], so we don't know its size in advance\n    // hence the use of an iterator to check if it's empty\n    if (!symbols.iterator().hasNext()) return emptyList()\n\n    symbols.forEach { annotatedClass ->\n      // Visit different parts of the class and perform actions\n      annotatedClass.accept(UsfViewModelVisitor(codeGenerator, logger, options), Unit)\n    }\n\n    /*val sourceFiles = symbols.mapNotNull { it.containingFile }\n\n    val fileText = buildString {\n      sourceFiles.forEach {\n        append(\"// \")\n        append(it.fileName)\n        append(\"\\n\")\n      }\n    }\n    val file =\n        codeGenerator.createNewFile(\n            Dependencies(\n                false,\n                *sourceFiles.toList().toTypedArray(),\n            ),\n            \"your.generated.file.package\",\n            \"GeneratedLists\",\n        )\n\n    file.write(fileText.toByteArray())*/\n\n    return (symbols).filterNot { it.validate() }.toList()\n  }\n}\n"
  },
  {
    "path": "usf/annotations-processors/src/main/java/co/kaush/msusf/processors/UsfViewModelProcessorProvider.kt",
    "content": "package co.kaush.msusf.processors\n\nimport co.kaush.msusf.processor.UsfViewModelProcessor\nimport com.google.devtools.ksp.processing.SymbolProcessor\nimport com.google.devtools.ksp.processing.SymbolProcessorEnvironment\nimport com.google.devtools.ksp.processing.SymbolProcessorProvider\n\n/**\n * this class is responsible for instantiating the [UsfViewModelProcessor] processor and introducing\n * it to the KSP\n */\nclass UsfViewModelProcessorProvider : SymbolProcessorProvider {\n  override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {\n    return UsfViewModelProcessor(\n        environment.codeGenerator,\n        environment.logger,\n        environment.options,\n    )\n  }\n}\n"
  },
  {
    "path": "usf/annotations-processors/src/main/java/co/kaush/msusf/processors/UsfViewModelVisitor.kt",
    "content": "package co.kaush.msusf.processors\n\nimport com.google.devtools.ksp.isPublic\nimport com.google.devtools.ksp.processing.CodeGenerator\nimport com.google.devtools.ksp.processing.Dependencies\nimport com.google.devtools.ksp.processing.KSPLogger\nimport com.google.devtools.ksp.symbol.ClassKind\nimport com.google.devtools.ksp.symbol.KSClassDeclaration\nimport com.google.devtools.ksp.symbol.KSFunctionDeclaration\nimport com.google.devtools.ksp.symbol.KSVisitorVoid\nimport com.squareup.kotlinpoet.ksp.toClassName\nimport com.squareup.kotlinpoet.ksp.toTypeName\n\nclass UsfViewModelVisitor(\n    private val codeGenerator: CodeGenerator,\n    private val logger: KSPLogger,\n    private val options: Map<String, String>,\n) : KSVisitorVoid() {\n\n  private val reservedFunctionsNames =\n      setOf(\"equals\", \"hashCode\", \"toString\", \"getApplication\", \"<init>\", \"addCloseable\")\n\n  override fun visitClassDeclaration(classDeclaration: KSClassDeclaration, data: Unit) {\n    if (classDeclaration.classKind != ClassKind.CLASS) {\n      logger.error(\"Only a class can be annotated with this annotation\", classDeclaration)\n      throw IllegalArgumentException()\n    }\n\n    if (classDeclaration.containingFile == null) {\n      logger.error(\n          \"Attempted to add annotation to file that does not exist\",\n          classDeclaration.containingFile)\n      throw IllegalArgumentException()\n    }\n\n    val packageName = classDeclaration.toClassName().packageName\n    val definition = generateGenericClassBuilderDefinition(classDeclaration)\n    val fileSpec = UsfViewModelFileBuilder.buildFileSpec(definition, packageName)\n\n    codeGenerator\n        .createNewFile(\n            dependencies = Dependencies(false, classDeclaration.containingFile!!),\n            packageName = classDeclaration.toClassName().packageName,\n            fileName = fileSpec.name)\n        .use { it.write(fileSpec.toString().toByteArray()) }\n  }\n\n  private fun generateGenericClassBuilderDefinition(\n      classDeclaration: KSClassDeclaration\n  ): UsfViewModelClassBuilderDefinition {\n    val constructorParams = mutableListOf<ParametersDefinition>()\n\n    classDeclaration.primaryConstructor?.parameters?.forEach { ksValueParameter ->\n      val paramType = ksValueParameter.type.resolve().toTypeName()\n      val name = ksValueParameter.name?.getShortName()\n\n      if (name != null) {\n        constructorParams.add(ParametersDefinition(name, paramType))\n      }\n    }\n\n    val functions = mutableListOf<FunctionsDefinition>()\n    classDeclaration.getAllFunctions().forEach { ksFunctionDeclaration ->\n      val functionName = ksFunctionDeclaration.simpleName.getShortName()\n\n      if (ksFunctionDeclaration.isPublic() && !reservedFunctionsNames.contains(functionName)) {\n        val funParams = mutableListOf<ParametersDefinition>()\n        ksFunctionDeclaration.parameters.map {\n          val varName = it.name?.getShortName()\n          if (varName != null) {\n            funParams.add(ParametersDefinition(varName, it.type.resolve().toTypeName()))\n          }\n        }\n\n        val returnType =\n            try {\n              ksFunctionDeclaration.returnType?.resolve()?.toTypeName()\n            } catch (ex: Exception) {\n              throw ex\n            }\n\n        functions.add(FunctionsDefinition(functionName, funParams, returnType))\n      }\n    }\n\n    val properties = mutableListOf<ParametersDefinition>()\n    classDeclaration.getAllProperties().forEach { ksPropertyDecleration ->\n      if (ksPropertyDecleration.isPublic()) {\n\n        val returnType = ksPropertyDecleration.type.resolve().toTypeName()\n\n        properties.add(\n            ParametersDefinition(ksPropertyDecleration.simpleName.getShortName(), returnType))\n      }\n    }\n\n    return UsfViewModelClassBuilderDefinition(\n        constructorParams,\n        functions,\n        properties,\n        ParametersDefinition(\n            classDeclaration.simpleName.getShortName(), classDeclaration.toClassName()))\n  }\n\n  override fun visitFunctionDeclaration(function: KSFunctionDeclaration, data: Unit) {\n    function.returnType!!.accept(this, Unit)\n  }\n}\n"
  },
  {
    "path": "usf/annotations-processors/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider",
    "content": "co.kaush.msusf.processors.UsfViewModelProcessorProvider\n"
  },
  {
    "path": "usf/api/build.gradle.kts",
    "content": "@file:Suppress(\"DSL_SCOPE_VIOLATION\") // TODO: Remove once KTIJ-19369 is fixed (or agp 8.1)\nplugins { alias(libs.plugins.kotlin.jvm) }\n\ndependencies { implementation(libs.kotlinx.coroutines.core) }\n"
  },
  {
    "path": "usf/api/src/main/java/co/kaush/usf/UsfViewModelImpl.kt",
    "content": "package co.kaush.usf\n\nimport kotlinx.coroutines.*\nimport kotlinx.coroutines.flow.*\n\n/**\n * When building features, we create <Feature>ViewModelImpl.kt classes that extend this class. and\n * only implement the relevant parts of the feature. All boilerplate code is handled by\n * [UsfViewModelImpl] & the corresponding <Feature>UsfViewModel] class generated by the annotation\n * processor.\n */\n@OptIn(ExperimentalCoroutinesApi::class)\nabstract class UsfViewModelImpl<E : Any, R : Any, VS : Any, Effect : Any>(\n    initialState: VS,\n    private val coroutineScope: CoroutineScope,\n    private val processingDispatcher: CoroutineDispatcher = Dispatchers.IO,\n    logger: UsfVmLogger =\n        object : UsfVmLogger {\n          val tag = Thread.currentThread().stackTrace[4].className.split(\".\").last()\n          override fun debug(message: String) = run { /*do something*/}\n          override fun warning(message: String) = run { /*do something*/}\n          override fun error(error: Throwable, message: String) = run { /*do something*/}\n        }\n) : UsfVm<E, VS, Effect> {\n\n  /**\n   * @param event every input is processed into an [E]vent\n   * @return [Flow]<[R]> a single [E]vent can result in multiple [R]esults for e.g. emit a R for\n   *   loading and another for the actual result\n   */\n  protected abstract fun eventToResultFlow(event: E): Flow<R>\n\n  /**\n   * @param currentViewState the current [VS]tate of the view (.copy it for the returned [VS]tate)\n   * @return [VS]tate Curiously, we don't return a [Flow]<[VS]> here every [R]esult will only ever\n   *   be transformed into a single [VS]tate if you want multiple [VS]tates emit multiple [R]esults\n   *   transforming each [R]esult to the respective [VS]tate\n   */\n  protected abstract fun resultToViewState(currentViewState: VS, result: R): VS\n\n  /**\n   * @param result a single [R]esult can result in multiple [Effect]s for e.g. emit a VE for\n   *   navigation and another for an analytics call hence a return type of [Flow]<[Effect]>\n   * @return [Flow] of [Effect]s where null emissions will be ignored automatically\n   */\n  protected abstract fun resultToEffects(result: R): Flow<Effect?>\n\n  /**\n   * we use a \"shared\" flow vs state flow here to avoid conflation of state flows.\n   *\n   * every single event needs to reach the view model as they could have important implications to\n   * the VM logic state flow might conflate multiple events if they happen simultaneously.\n   */\n  private val _events =\n      MutableSharedFlow<E>(\n          /**\n           * we do this to prevent a race condition misfire for events sent in very early. for e.g.\n           * OnScreenLoad events that are sent via [processInput()] right after the VM is created\n           * can get ignored as .collect(ion) has started yet.\n           *\n           * inside the init block, we \"launch\" (which is fire and forget with coroutines) so the VM\n           * proceeds to \"finish\" initialization and allows the Screen/Fragment/Activity to send\n           * inputs to the \"hot\" _events flow which will drop it, since noone is listening.\n           *\n           * Adding a replay ensures that the first event is always sent to \"new\" subscribers.\n           */\n          replay = 1)\n  private val _viewState = MutableStateFlow(initialState)\n\n  /**\n   * we use a \"shared\" flow vs state flow here to avoid conflation of state flows.\n   *\n   * every effect must be sent out and cannot be ignored even if there are multiple side effects\n   * emitted quickly/simultaneously as that could have implications to the Screen logic\n   *\n   * there are times where we _want_ to ignore certain effects (like multiple loading spinner calls)\n   * these can be handled in the Results emission layer.\n   */\n  private val _effects = MutableSharedFlow<Effect>()\n\n  override val viewState = _viewState.asStateFlow()\n  override val effects = _effects.asSharedFlow()\n\n  init {\n    logger.debug(\"------ [init] ${Thread.currentThread().name}\")\n\n    coroutineScope.launch(processingDispatcher) {\n      _events\n          .flatMapMerge { event ->\n            logger.debugEvents(event)\n            eventToResultFlow(event)\n          }\n          .collect { result ->\n            logger.debugResults(result)\n\n            // StateFlow already behaves as if distinctUntilChanged operator is applied to it\n            resultToViewState(_viewState.value, result).let { vs ->\n              logger.debugViewState(vs)\n              _viewState.emit(vs)\n            }\n\n            // effects are emitted after a view state by virtue of this collect call\n            // (rarely) would we want VS & VE to be emitted at the exact same instant\n            _effects.emitAll(\n                resultToEffects(result).filterNotNull().onEach { logger.debugSideEffects(it) },\n            )\n          }\n    }\n  }\n\n  override fun processInput(event: E) {\n    coroutineScope.launch(processingDispatcher) { _events.emit(event) }\n  }\n\n  interface UsfVmLogger {\n    fun debug(message: String)\n\n    fun debugEvents(event: Any, message: String? = null) =\n        debug(message ?: \"----- [event] ${Thread.currentThread().name} $event\")\n\n    fun debugResults(result: Any, message: String? = null) =\n        debug(message ?: \"----- [result] ${Thread.currentThread().name} $result\")\n\n    fun debugViewState(viewState: Any, message: String? = null) =\n        debug(message ?: \"----- [view-state] ${Thread.currentThread().name} $viewState\")\n\n    fun debugSideEffects(effect: Any, message: String? = null) =\n        debug(message ?: \"----- [effect] ${Thread.currentThread().name} $effect\")\n\n    fun warning(message: String)\n\n    fun error(error: Throwable, message: String)\n  }\n}\n"
  },
  {
    "path": "usf/api/src/main/java/co/kaush/usf/UsfVm.kt",
    "content": "package co.kaush.usf\n\nimport kotlinx.coroutines.flow.SharedFlow\nimport kotlinx.coroutines.flow.StateFlow\n\n/**\n * We intentionally name this interface [UsfVm] instead of `UsfViewModel` because we want to avoid\n * naming conflict with the annotation @[UsfViewModel]\n *\n * This interface provides the contract for the ViewModel to follow USF/UDF architecture. Having\n * this as an interface allows us to possibly avoid using of [AndroidViewModel] or [ViewModel] if we\n * don't need it.\n *\n * [Any] type used because of a Kotlin Compiler bug that won't take in @NotNull event: E\n * https://youtrack.jetbrains.com/issue/KT-36770\n *\n * @param Event\n */\ninterface UsfVm<Event : Any, ViewState : Any, Effect : Any> {\n\n  fun processInput(event: Event)\n\n  val viewState: StateFlow<ViewState>\n\n  val effects: SharedFlow<Effect>\n}\n"
  }
]