├── MoshiCodegenSample ├── app │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── drawable-xxhdpi │ │ │ │ │ └── placeholder460_690.png │ │ │ │ ├── values │ │ │ │ │ ├── colors.xml │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── layout │ │ │ │ │ ├── movies_list_item.xml │ │ │ │ │ ├── fragment_movies.xml │ │ │ │ │ ├── activity_movies.xml │ │ │ │ │ └── fragment_movie_detail.xml │ │ │ │ ├── drawable │ │ │ │ │ ├── ic_error_black_80dp.xml │ │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── xml │ │ │ │ │ └── network_security_config.xml │ │ │ │ ├── navigation │ │ │ │ │ └── nav_graph.xml │ │ │ │ └── drawable-v24 │ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── digian │ │ │ │ │ └── example │ │ │ │ │ └── moshicodegen │ │ │ │ │ ├── data │ │ │ │ │ ├── Genre.kt │ │ │ │ │ ├── Movie.kt │ │ │ │ │ ├── GenreAdapter.kt │ │ │ │ │ └── MoviesRepository.kt │ │ │ │ │ └── ui │ │ │ │ │ ├── MoviesActivity.kt │ │ │ │ │ ├── MoviesListViewModel.kt │ │ │ │ │ ├── MovieDetailViewModel.kt │ │ │ │ │ ├── MoviesListAdapter.kt │ │ │ │ │ ├── MoviesListFragment.kt │ │ │ │ │ └── MovieDetailFragment.kt │ │ │ ├── AndroidManifest.xml │ │ │ └── Assets │ │ │ │ └── popular_movies_list.json │ │ ├── test │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── digian │ │ │ │ └── example │ │ │ │ └── moshicodegen │ │ │ │ ├── MoviesLifeCycleOwner.kt │ │ │ │ ├── ui │ │ │ │ ├── MovieDetailFragmentCompanionTest.kt │ │ │ │ ├── MoviesListViewModelTest.kt │ │ │ │ └── MovieDetailViewModelTest.kt │ │ │ │ ├── InstantExecutorExtension.kt │ │ │ │ └── data │ │ │ │ ├── GenreAdapterTest.kt │ │ │ │ └── MoviesRepositoryTest.kt │ │ └── androidTest │ │ │ └── java │ │ │ └── com │ │ │ └── digian │ │ │ └── example │ │ │ └── moshicodegen │ │ │ └── MoviesListScreenTest.kt │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── MoshiReflectionSample ├── app │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── drawable-xxhdpi │ │ │ │ │ └── placeholder460_690.png │ │ │ │ ├── values │ │ │ │ │ ├── colors.xml │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ │ ├── ic_launcher.xml │ │ │ │ │ └── ic_launcher_round.xml │ │ │ │ ├── layout │ │ │ │ │ ├── movies_list_item.xml │ │ │ │ │ ├── fragment_movies.xml │ │ │ │ │ ├── activity_movies.xml │ │ │ │ │ └── fragment_movie_detail.xml │ │ │ │ ├── drawable │ │ │ │ │ ├── ic_error_black_80dp.xml │ │ │ │ │ └── ic_launcher_background.xml │ │ │ │ ├── xml │ │ │ │ │ └── network_security_config.xml │ │ │ │ ├── navigation │ │ │ │ │ └── nav_graph.xml │ │ │ │ └── drawable-v24 │ │ │ │ │ └── ic_launcher_foreground.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── digian │ │ │ │ │ └── example │ │ │ │ │ └── moshireflection │ │ │ │ │ ├── data │ │ │ │ │ ├── Genre.kt │ │ │ │ │ ├── Movie.kt │ │ │ │ │ ├── GenreAdapter.kt │ │ │ │ │ └── MoviesRepository.kt │ │ │ │ │ └── ui │ │ │ │ │ ├── MoviesActivity.kt │ │ │ │ │ ├── MoviesListViewModel.kt │ │ │ │ │ ├── MovieDetailViewModel.kt │ │ │ │ │ ├── MoviesListAdapter.kt │ │ │ │ │ ├── MoviesListFragment.kt │ │ │ │ │ └── MovieDetailFragment.kt │ │ │ ├── AndroidManifest.xml │ │ │ └── Assets │ │ │ │ └── popular_movies_list.json │ │ ├── test │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── digian │ │ │ │ └── example │ │ │ │ └── moshireflection │ │ │ │ ├── MoviesLifeCycleOwner.kt │ │ │ │ ├── ui │ │ │ │ ├── MovieDetailFragmentCompanionTest.kt │ │ │ │ ├── MoviesListViewModelTest.kt │ │ │ │ └── MovieDetailViewModelTest.kt │ │ │ │ ├── InstantExecutorExtension.kt │ │ │ │ └── data │ │ │ │ ├── GenreAdapterTest.kt │ │ │ │ └── MoviesRepositoryTest.kt │ │ └── androidTest │ │ │ └── java │ │ │ └── com │ │ │ └── digian │ │ │ └── example │ │ │ └── moshireflection │ │ │ └── MoviesListScreenTest.kt │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradlew.bat └── gradlew ├── README.md └── LICENSE.txt /MoshiCodegenSample/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /MoshiCodegenSample/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /MoshiReflectionSample/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /MoshiCodegenSample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /MoshiReflectionSample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/drawable-xxhdpi/placeholder460_690.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiCodegenSample/app/src/main/res/drawable-xxhdpi/placeholder460_690.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/drawable-xxhdpi/placeholder460_690.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexforrester/android-moshi/HEAD/MoshiReflectionSample/app/src/main/res/drawable-xxhdpi/placeholder460_690.png -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/data/Genre.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.data 2 | 3 | /** 4 | * Created by Alex Forrester on 2019-04-26. 5 | */ 6 | data class Genre(val id: Int, val name: String) -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /MoshiCodegenSample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 23 14:47:32 BST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /MoshiReflectionSample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 23 14:47:32 BST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/data/Genre.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.data 2 | 3 | import com.squareup.moshi.JsonClass 4 | 5 | /** 6 | * Created by Alex Forrester on 2019-04-26. 7 | */ 8 | @JsonClass(generateAdapter = true) 9 | data class Genre(val id: Int, val name: String) -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Moshi-Codegen-Sample 3 | Popular Movies 4 | Movie Detail Image 5 | Error Loading Movie Detail 6 | 7 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Moshi-Reflection-Sample 3 | Popular Movies 4 | Movie Detail Image 5 | Error Loading Movie Detail 6 | 7 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/layout/movies_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/layout/movies_list_item.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /MoshiCodegenSample/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | /.idea/caches 6 | /.idea/libraries 7 | /.idea/encodings.xml 8 | /.idea/encodings.xml 9 | /.idea/codeStyles/Project.xml 10 | /.idea/modules.xml 11 | /.idea/workspace.xml 12 | /.idea/navEditor.xml 13 | /.idea/assetWizardSettings.xml 14 | /.idea/vcs.xml 15 | .DS_Store 16 | /build 17 | build/ 18 | /captures 19 | .externalNativeBuild 20 | -------------------------------------------------------------------------------- /MoshiReflectionSample/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | .idea 4 | /local.properties 5 | /.idea/caches 6 | /.idea/libraries 7 | /.idea/encodings.xml 8 | /.idea/encodings.xml 9 | /.idea/codeStyles/Project.xml 10 | /.idea/modules.xml 11 | /.idea/workspace.xml 12 | /.idea/navEditor.xml 13 | /.idea/assetWizardSettings.xml 14 | /.idea/vcs.xml 15 | .DS_Store 16 | /build 17 | build/ 18 | /captures 19 | .externalNativeBuild 20 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/drawable/ic_error_black_80dp.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/drawable/ic_error_black_80dp.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/layout/fragment_movies.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/layout/fragment_movies.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/data/Movie.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.data 2 | 3 | import com.squareup.moshi.Json 4 | import com.squareup.moshi.JsonClass 5 | 6 | /** 7 | * Created by Alex Forrester on 11/04/2019. 8 | */ 9 | data class Movie ( 10 | @Json(name = "vote_count") val voteCount: Int = -1, 11 | val id: Int, 12 | val title: String, 13 | @Json(name = "image_path") val imagePath: String, 14 | @Json(name = "genre_ids") val genres: List, 15 | val overview: String 16 | ) 17 | 18 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/data/Movie.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.data 2 | 3 | import com.squareup.moshi.Json 4 | import com.squareup.moshi.JsonClass 5 | 6 | /** 7 | * Created by Alex Forrester on 11/04/2019. 8 | */ 9 | @JsonClass(generateAdapter = true) 10 | data class Movie ( 11 | @Json(name = "vote_count") val voteCount: Int = -1, 12 | val id: Int, 13 | val title: String, 14 | @Json(name = "image_path") val imagePath: String, 15 | @Json(name = "genre_ids") val genres: List, 16 | val overview: String 17 | ) 18 | 19 | 20 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/ui/MoviesActivity.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.digian.example.moshicodegen.R 6 | 7 | /** 8 | * Created by Alex Forrester on 18/04/2019. 9 | */ 10 | class MoviesActivity : AppCompatActivity() { 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_movies) 15 | 16 | title = getString(R.string.popular_movies) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/ui/MoviesActivity.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.digian.example.moshireflection.R 6 | 7 | /** 8 | * Created by Alex Forrester on 18/04/2019. 9 | */ 10 | class MoviesActivity : AppCompatActivity() { 11 | 12 | override fun onCreate(savedInstanceState: Bundle?) { 13 | super.onCreate(savedInstanceState) 14 | setContentView(R.layout.activity_movies) 15 | 16 | title = getString(R.string.popular_movies) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /MoshiCodegenSample/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.21' 3 | ext.moshi_version = '1.9.2' 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.4.0' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha02" 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /MoshiReflectionSample/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.21' 3 | ext.moshi_version = '1.9.2' 4 | 5 | repositories { 6 | google() 7 | jcenter() 8 | 9 | } 10 | dependencies { 11 | classpath 'com.android.tools.build:gradle:3.4.0' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0-alpha02" 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | google() 20 | jcenter() 21 | } 22 | } 23 | 24 | task clean(type: Delete) { 25 | delete rootProject.buildDir 26 | } 27 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/MoviesLifeCycleOwner.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen 2 | 3 | import androidx.lifecycle.Lifecycle 4 | import androidx.lifecycle.LifecycleOwner 5 | import androidx.lifecycle.LifecycleRegistry 6 | 7 | /** 8 | * Created by Alex Forrester on 2019-04-23. 9 | * 10 | * LifecycleOwner created for tests to ensure LiveData emits 11 | */ 12 | class MoviesLifeCycleOwner : LifecycleOwner { 13 | 14 | private val lifecycle = LifecycleRegistry(this) 15 | 16 | init { 17 | lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME) 18 | } 19 | 20 | override fun getLifecycle(): Lifecycle = lifecycle 21 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/MoviesLifeCycleOwner.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection 2 | 3 | import androidx.lifecycle.Lifecycle 4 | import androidx.lifecycle.LifecycleOwner 5 | import androidx.lifecycle.LifecycleRegistry 6 | 7 | /** 8 | * Created by Alex Forrester on 2019-04-23. 9 | * 10 | * LifecycleOwner created for tests to ensure LiveData emits 11 | */ 12 | class MoviesLifeCycleOwner : LifecycleOwner { 13 | 14 | private val lifecycle = LifecycleRegistry(this) 15 | 16 | init { 17 | lifecycle.handleLifecycleEvent(Lifecycle.Event.ON_RESUME) 18 | } 19 | 20 | override fun getLifecycle(): Lifecycle = lifecycle 21 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /MoshiCodegenSample/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # Kotlin code style for this project: "official" or "obsolete": 15 | kotlin.code.style=official 16 | android.useAndroidX=true 17 | android.enableJetifier=true 18 | -------------------------------------------------------------------------------- /MoshiReflectionSample/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # Kotlin code style for this project: "official" or "obsolete": 15 | kotlin.code.style=official 16 | android.useAndroidX=true 17 | android.enableJetifier=true 18 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/ui/MoviesListViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import android.app.Application 4 | import androidx.lifecycle.AndroidViewModel 5 | import androidx.lifecycle.LiveData 6 | import com.digian.example.moshicodegen.data.Movie 7 | import com.digian.example.moshicodegen.data.PopularMoviesRepository 8 | import com.digian.example.moshicodegen.data.PopularMoviesRepositoryImpl 9 | 10 | 11 | /** 12 | * Created by Alex Forrester on 23/04/2019. 13 | */ 14 | open class MoviesListViewModel(application: Application) : AndroidViewModel(application) { 15 | 16 | private val popularMoviesRepository: PopularMoviesRepository = getRepository() 17 | 18 | //TODO("Add coroutines to run off main thread") 19 | fun getMovies() : LiveData> { 20 | return popularMoviesRepository.getMovies() 21 | } 22 | 23 | internal open fun getRepository() : PopularMoviesRepository { 24 | return PopularMoviesRepositoryImpl(getApplication()) 25 | } 26 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/ui/MoviesListViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import android.app.Application 4 | import androidx.lifecycle.AndroidViewModel 5 | import androidx.lifecycle.LiveData 6 | import com.digian.example.moshireflection.data.Movie 7 | import com.digian.example.moshireflection.data.PopularMoviesRepository 8 | import com.digian.example.moshireflection.data.PopularMoviesRepositoryImpl 9 | 10 | 11 | /** 12 | * Created by Alex Forrester on 23/04/2019. 13 | */ 14 | open class MoviesListViewModel(application: Application) : AndroidViewModel(application) { 15 | 16 | private val popularMoviesRepository: PopularMoviesRepository = getRepository() 17 | 18 | //TODO("Add coroutines to run off main thread") 19 | fun getMovies() : LiveData> { 20 | return popularMoviesRepository.getMovies() 21 | } 22 | 23 | internal open fun getRepository() : PopularMoviesRepository { 24 | return PopularMoviesRepositoryImpl(getApplication()) 25 | } 26 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/layout/activity_movies.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 22 | 23 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/layout/activity_movies.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 22 | 23 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/ui/MovieDetailFragmentCompanionTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import com.digian.example.moshicodegen.data.Genre 4 | import org.junit.jupiter.api.Assertions.* 5 | import org.junit.jupiter.api.Test 6 | 7 | /** 8 | * Created by Alex Forrester on 2019-04-28. 9 | */ 10 | internal class MovieDetailFragmentCompanionTest { 11 | 12 | private val genres = listOf(Genre(28,"Action"), Genre(12, "Adventure"), Genre(16, "Animation")) 13 | private val emptyGenres = emptyList() 14 | 15 | 16 | @Test 17 | internal fun `given list of genres, when prepared for display print genre strings prepended with GENRES text`() { 18 | 19 | val genreNames = MovieDetailFragment.createGenreText(genres) 20 | 21 | assertEquals("GENRES: Action, Adventure, Animation", genreNames) 22 | } 23 | 24 | @Test 25 | internal fun `given empty list of genres, when prepared for display blank string returned`() { 26 | 27 | val genreNames = MovieDetailFragment.createGenreText(emptyGenres) 28 | 29 | assertEquals("", genreNames) 30 | } 31 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/ui/MovieDetailFragmentCompanionTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import com.digian.example.moshireflection.data.Genre 4 | import org.junit.jupiter.api.Assertions.assertEquals 5 | import org.junit.jupiter.api.Test 6 | 7 | /** 8 | * Created by Alex Forrester on 2019-04-28. 9 | */ 10 | internal class MovieDetailFragmentCompanionTest { 11 | 12 | private val genres = listOf(Genre(28,"Action"), Genre(12, "Adventure"), Genre(16, "Animation")) 13 | private val emptyGenres = emptyList() 14 | 15 | 16 | @Test 17 | internal fun `given list of genres, when prepared for display print genre strings prepended with GENRES text`() { 18 | 19 | val genreNames = MovieDetailFragment.createGenreText(genres) 20 | 21 | assertEquals("GENRES: Action, Adventure, Animation", genreNames) 22 | } 23 | 24 | @Test 25 | internal fun `given empty list of genres, when prepared for display blank string returned`() { 26 | 27 | val genreNames = MovieDetailFragment.createGenreText(emptyGenres) 28 | 29 | assertEquals("", genreNames) 30 | } 31 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/ui/MovieDetailViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import android.app.Application 4 | import androidx.lifecycle.AndroidViewModel 5 | import androidx.lifecycle.LiveData 6 | import androidx.lifecycle.Transformations 7 | import com.digian.example.moshicodegen.data.Movie 8 | import com.digian.example.moshicodegen.data.PopularMoviesRepository 9 | import com.digian.example.moshicodegen.data.PopularMoviesRepositoryImpl 10 | 11 | 12 | /** 13 | * Created by Alex Forrester on 23/04/2019. 14 | */ 15 | open class MovieDetailViewModel(application: Application) : AndroidViewModel(application) { 16 | 17 | private val popularMoviesRepository: PopularMoviesRepository = getRepository() 18 | 19 | //TODO("Add coroutines to run off main thread") 20 | fun getMovie(movieId : Int) : LiveData { 21 | 22 | return Transformations.map(popularMoviesRepository.getMovies()) { 23 | movieList -> movieList.find { it.id == movieId} 24 | } 25 | } 26 | 27 | internal open fun getRepository() : PopularMoviesRepository { 28 | return PopularMoviesRepositoryImpl(getApplication()) 29 | } 30 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/ui/MovieDetailViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import android.app.Application 4 | import androidx.lifecycle.AndroidViewModel 5 | import androidx.lifecycle.LiveData 6 | import androidx.lifecycle.Transformations 7 | import com.digian.example.moshireflection.data.Movie 8 | import com.digian.example.moshireflection.data.PopularMoviesRepository 9 | import com.digian.example.moshireflection.data.PopularMoviesRepositoryImpl 10 | 11 | 12 | /** 13 | * Created by Alex Forrester on 23/04/2019. 14 | */ 15 | open class MovieDetailViewModel(application: Application) : AndroidViewModel(application) { 16 | 17 | private val popularMoviesRepository: PopularMoviesRepository = getRepository() 18 | 19 | //TODO("Add coroutines to run off main thread") 20 | fun getMovie(movieId : Int) : LiveData { 21 | 22 | return Transformations.map(popularMoviesRepository.getMovies()) { 23 | movieList -> movieList.find { it.id == movieId} 24 | } 25 | } 26 | 27 | internal open fun getRepository() : PopularMoviesRepository { 28 | return PopularMoviesRepositoryImpl(getApplication()) 29 | } 30 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/navigation/nav_graph.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/navigation/nav_graph.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/InstantExecutorExtension.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen 2 | 3 | import androidx.arch.core.executor.ArchTaskExecutor 4 | import androidx.arch.core.executor.TaskExecutor 5 | import org.junit.jupiter.api.extension.AfterEachCallback 6 | import org.junit.jupiter.api.extension.BeforeEachCallback 7 | import org.junit.jupiter.api.extension.ExtensionContext 8 | 9 | /** 10 | * Created by Alex Forrester on 2019-04-23 from example in 11 | * [Jeroen Mols Blog](https://jeroenmols.com/blog/2019/01/17/livedatajunit5/) 12 | * 13 | * Used to be able to run synchronised tests on LiveData 14 | * 15 | */ 16 | class InstantExecutorExtension : BeforeEachCallback, AfterEachCallback { 17 | 18 | override fun beforeEach(context: ExtensionContext?) { 19 | ArchTaskExecutor.getInstance() 20 | .setDelegate(object : TaskExecutor() { 21 | override fun executeOnDiskIO(runnable: Runnable) = runnable.run() 22 | 23 | override fun postToMainThread(runnable: Runnable) = runnable.run() 24 | 25 | override fun isMainThread(): Boolean = true 26 | }) 27 | } 28 | 29 | override fun afterEach(context: ExtensionContext?) { 30 | ArchTaskExecutor.getInstance().setDelegate(null) 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/data/GenreAdapterTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.data 2 | 3 | import com.squareup.moshi.JsonAdapter 4 | import com.squareup.moshi.Moshi 5 | import com.squareup.moshi.Types 6 | import org.junit.jupiter.api.BeforeEach 7 | 8 | import org.junit.jupiter.api.Assertions.* 9 | import org.junit.jupiter.api.Test 10 | 11 | /** 12 | * Created by Alex Forrester on 2019-04-27. 13 | */ 14 | internal class GenreAdapterTest { 15 | 16 | val genres = listOf(Genre(28,"Action"),Genre(12, "Adventure"),Genre(16, "Animation")) 17 | val moshi = Moshi.Builder().add(GenreAdapter()).build() 18 | val listType = Types.newParameterizedType(List::class.java, Genre::class.java) 19 | val adapter: JsonAdapter> = moshi.adapter(listType) 20 | 21 | @Test 22 | internal fun `given list of genres to serialise to json, when custom adapter used, then array of Ints created`() { 23 | 24 | val genresJson = adapter.toJson(genres) 25 | assertEquals("""[28,12,16]""", genresJson) 26 | } 27 | 28 | @Test 29 | internal fun `given array of genres ids, when custom adapter used, then list of Genres created`() { 30 | 31 | val genresList = adapter.fromJson("[28,12,16]") 32 | assertEquals(genres, genresList) 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/InstantExecutorExtension.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection 2 | 3 | import androidx.arch.core.executor.ArchTaskExecutor 4 | import androidx.arch.core.executor.TaskExecutor 5 | import org.junit.jupiter.api.extension.AfterEachCallback 6 | import org.junit.jupiter.api.extension.BeforeEachCallback 7 | import org.junit.jupiter.api.extension.ExtensionContext 8 | 9 | /** 10 | * Created by Alex Forrester on 2019-04-23 from example in 11 | * [Jeroen Mols Blog](https://jeroenmols.com/blog/2019/01/17/livedatajunit5/) 12 | * 13 | * Used to be able to run synchronised tests on LiveData 14 | * 15 | */ 16 | class InstantExecutorExtension : BeforeEachCallback, AfterEachCallback { 17 | 18 | override fun beforeEach(context: ExtensionContext?) { 19 | ArchTaskExecutor.getInstance() 20 | .setDelegate(object : TaskExecutor() { 21 | override fun executeOnDiskIO(runnable: Runnable) = runnable.run() 22 | 23 | override fun postToMainThread(runnable: Runnable) = runnable.run() 24 | 25 | override fun isMainThread(): Boolean = true 26 | }) 27 | } 28 | 29 | override fun afterEach(context: ExtensionContext?) { 30 | ArchTaskExecutor.getInstance().setDelegate(null) 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/data/GenreAdapterTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.data 2 | 3 | import com.squareup.moshi.JsonAdapter 4 | import com.squareup.moshi.Moshi 5 | import com.squareup.moshi.Types 6 | import org.junit.jupiter.api.BeforeEach 7 | 8 | import org.junit.jupiter.api.Assertions.* 9 | import org.junit.jupiter.api.Test 10 | 11 | /** 12 | * Created by Alex Forrester on 2019-04-27. 13 | */ 14 | internal class GenreAdapterTest { 15 | 16 | val genres = listOf(Genre(28,"Action"),Genre(12, "Adventure"),Genre(16, "Animation")) 17 | val moshi = Moshi.Builder().add(GenreAdapter()).build() 18 | val listType = Types.newParameterizedType(List::class.java, Genre::class.java) 19 | val adapter: JsonAdapter> = moshi.adapter(listType) 20 | 21 | @Test 22 | internal fun `given list of genres to serialise to json, when custom adapter used, then array of Ints created`() { 23 | 24 | val genresJson = adapter.toJson(genres) 25 | assertEquals("""[28,12,16]""", genresJson) 26 | } 27 | 28 | @Test 29 | internal fun `given array of genres ids, when custom adapter used, then list of Genres created`() { 30 | 31 | val genresList = adapter.fromJson("[28,12,16]") 32 | assertEquals(genres, genresList) 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/ui/MoviesListAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import android.widget.TextView 6 | import androidx.recyclerview.widget.RecyclerView 7 | import com.digian.example.moshicodegen.data.Movie 8 | 9 | 10 | /** 11 | * Created by Alex Forrester on 17/04/2019. 12 | */ 13 | internal class MoviesAdapter(private val onItemClickListener: OnItemClickListener) : RecyclerView.Adapter() { 14 | 15 | internal var data: List? = null 16 | 17 | class MovieViewHolder(val textView: TextView) : RecyclerView.ViewHolder(textView) { 18 | fun bind(movie: Movie, onItemClickListener: OnItemClickListener) { 19 | textView.setOnClickListener { 20 | onItemClickListener.onItemClick(movie) 21 | } 22 | } 23 | } 24 | 25 | override fun onCreateViewHolder(parent: ViewGroup, 26 | viewType: Int): MovieViewHolder { 27 | // create a new view 28 | val textView = LayoutInflater.from(parent.context) 29 | .inflate(com.digian.example.moshicodegen.R.layout.movies_list_item, parent, false) as TextView 30 | 31 | return MovieViewHolder(textView) 32 | } 33 | 34 | override fun onBindViewHolder(holder: MovieViewHolder, position: Int) { 35 | 36 | data?.let { 37 | holder.bind(it[position], onItemClickListener) 38 | } 39 | 40 | holder.textView.text = data?.get(position)?.title 41 | } 42 | 43 | override fun getItemCount() = data?.size ?: 0 44 | 45 | } 46 | 47 | internal interface OnItemClickListener { 48 | fun onItemClick(movie : Movie) 49 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/ui/MoviesListAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import android.widget.TextView 6 | import androidx.recyclerview.widget.RecyclerView 7 | import com.digian.example.moshireflection.data.Movie 8 | 9 | 10 | /** 11 | * Created by Alex Forrester on 17/04/2019. 12 | */ 13 | internal class MoviesAdapter(private val onItemClickListener: OnItemClickListener) : RecyclerView.Adapter() { 14 | 15 | internal var data: List? = null 16 | 17 | class MovieViewHolder(val textView: TextView) : RecyclerView.ViewHolder(textView) { 18 | fun bind(movie: Movie, onItemClickListener: OnItemClickListener) { 19 | textView.setOnClickListener { 20 | onItemClickListener.onItemClick(movie) 21 | } 22 | } 23 | } 24 | 25 | override fun onCreateViewHolder(parent: ViewGroup, 26 | viewType: Int): MovieViewHolder { 27 | // create a new view 28 | val textView = LayoutInflater.from(parent.context) 29 | .inflate(com.digian.example.moshireflection.R.layout.movies_list_item, parent, false) as TextView 30 | 31 | return MovieViewHolder(textView) 32 | } 33 | 34 | override fun onBindViewHolder(holder: MovieViewHolder, position: Int) { 35 | 36 | data?.let { 37 | holder.bind(it[position], onItemClickListener) 38 | } 39 | 40 | holder.textView.text = data?.get(position)?.title 41 | } 42 | 43 | override fun getItemCount() = data?.size ?: 0 44 | 45 | } 46 | 47 | internal interface OnItemClickListener { 48 | fun onItemClick(movie : Movie) 49 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/data/GenreAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.data 2 | 3 | import com.squareup.moshi.FromJson 4 | import com.squareup.moshi.JsonDataException 5 | import com.squareup.moshi.ToJson 6 | 7 | /** 8 | * Created by Alex Forrester on 2019-04-26. 9 | * 10 | * Movie genres from the The movie database - https://www.themoviedb.org/ 11 | */ 12 | class GenreAdapter { 13 | 14 | @ToJson 15 | fun toJson(genres: List): List { 16 | return genres.map { genre -> genre.id} 17 | } 18 | 19 | @FromJson 20 | fun fromJson(genreId: Int): Genre { 21 | 22 | when (genreId) { 23 | 28 -> return Genre(28, "Action") 24 | 12 -> return Genre(12, "Adventure") 25 | 16 -> return Genre(16, "Animation") 26 | 35 -> return Genre(35, "Comedy") 27 | 80 -> return Genre(80, "Crime") 28 | 99 -> return Genre(99, "Documentary") 29 | 18 -> return Genre(18, "Drama") 30 | 10751 -> return Genre(10751, "Family") 31 | 14 -> return Genre(14, "Fantasy") 32 | 36 -> return Genre(36, "History") 33 | 27 -> return Genre(27, "Horror") 34 | 10402 -> return Genre(10402, "Music") 35 | 10749 -> return Genre(10749, "Romance") 36 | 9648 -> return Genre(9648, "Mystery") 37 | 878 -> return Genre(878, "Science Fiction") 38 | 10770 -> return Genre(10770, "TV Movie") 39 | 53 -> return Genre(53, "Mystery") 40 | 10752 -> return Genre(10752, "War") 41 | 37 -> return Genre(37, "Western") 42 | else -> throw JsonDataException("unknown genre id: $genreId") 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/data/GenreAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.data 2 | 3 | import com.squareup.moshi.FromJson 4 | import com.squareup.moshi.JsonDataException 5 | import com.squareup.moshi.ToJson 6 | 7 | /** 8 | * Created by Alex Forrester on 2019-04-26. 9 | * 10 | * Movie genres from the The movie database - https://www.themoviedb.org/ 11 | */ 12 | class GenreAdapter { 13 | 14 | @ToJson 15 | fun toJson(genres: List): List { 16 | return genres.map { genre -> genre.id} 17 | } 18 | 19 | @FromJson 20 | fun fromJson(genreId: Int): Genre { 21 | 22 | when (genreId) { 23 | 28 -> return Genre(28, "Action") 24 | 12 -> return Genre(12, "Adventure") 25 | 16 -> return Genre(16, "Animation") 26 | 35 -> return Genre(35, "Comedy") 27 | 80 -> return Genre(80, "Crime") 28 | 99 -> return Genre(99, "Documentary") 29 | 18 -> return Genre(18, "Drama") 30 | 10751 -> return Genre(10751, "Family") 31 | 14 -> return Genre(14, "Fantasy") 32 | 36 -> return Genre(36, "History") 33 | 27 -> return Genre(27, "Horror") 34 | 10402 -> return Genre(10402, "Music") 35 | 10749 -> return Genre(10749, "Romance") 36 | 9648 -> return Genre(9648, "Mystery") 37 | 878 -> return Genre(878, "Science Fiction") 38 | 10770 -> return Genre(10770, "TV Movie") 39 | 53 -> return Genre(53, "Mystery") 40 | 10752 -> return Genre(10752, "War") 41 | 37 -> return Genre(37, "Western") 42 | else -> throw JsonDataException("unknown genre id: $genreId") 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/ui/MoviesListViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import androidx.lifecycle.Observer 4 | import com.digian.example.moshicodegen.InstantExecutorExtension 5 | import com.digian.example.moshicodegen.MoviesLifeCycleOwner 6 | import com.digian.example.moshicodegen.data.ASSET_BASE_PATH 7 | import com.digian.example.moshicodegen.data.Movie 8 | import com.digian.example.moshicodegen.data.PopularMoviesRepository 9 | import com.digian.example.moshicodegen.data.PopularMoviesRepositoryImpl 10 | import io.mockk.* 11 | import org.junit.jupiter.api.Test 12 | import org.junit.jupiter.api.extension.ExtendWith 13 | import java.io.FileInputStream 14 | import java.io.InputStream 15 | 16 | /** 17 | * Created by Alex Forrester on 2019-04-24. 18 | */ 19 | @ExtendWith(InstantExecutorExtension::class) 20 | internal class MoviesListViewModelTest { 21 | 22 | private val moviesListViewModel: MoviesListViewModel = object : MoviesListViewModel(mockk()) { 23 | 24 | override fun getRepository() : PopularMoviesRepository = object : 25 | PopularMoviesRepositoryImpl(mockk()) { 26 | 27 | override fun getInputStreamForJsonFile(fileName: String): InputStream { 28 | return FileInputStream(ASSET_BASE_PATH + fileName) 29 | } 30 | } 31 | } 32 | 33 | @Test 34 | fun `given getMovies call made, when live data isInitialised, then adding observer emits onChanged`() { 35 | 36 | val observer = mockk>>() 37 | every { observer.onChanged(any()) } just Runs 38 | 39 | moviesListViewModel.getMovies().observe(MoviesLifeCycleOwner(), observer) 40 | 41 | verify { observer.onChanged(any()) } 42 | verify { 43 | observer.onChanged(match { it.size == 20 }) 44 | } 45 | 46 | confirmVerified(observer) 47 | } 48 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/ui/MoviesListViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import androidx.lifecycle.Observer 4 | import com.digian.example.moshireflection.InstantExecutorExtension 5 | import com.digian.example.moshireflection.MoviesLifeCycleOwner 6 | import com.digian.example.moshireflection.data.ASSET_BASE_PATH 7 | import com.digian.example.moshireflection.data.Movie 8 | import com.digian.example.moshireflection.data.PopularMoviesRepository 9 | import com.digian.example.moshireflection.data.PopularMoviesRepositoryImpl 10 | import io.mockk.* 11 | import org.junit.jupiter.api.Test 12 | import org.junit.jupiter.api.extension.ExtendWith 13 | import java.io.FileInputStream 14 | import java.io.InputStream 15 | 16 | /** 17 | * Created by Alex Forrester on 2019-04-24. 18 | */ 19 | @ExtendWith(InstantExecutorExtension::class) 20 | internal class MoviesListViewModelTest { 21 | 22 | private val moviesListViewModel: MoviesListViewModel = object : MoviesListViewModel(mockk()) { 23 | 24 | override fun getRepository() : PopularMoviesRepository = object : 25 | PopularMoviesRepositoryImpl(mockk()) { 26 | 27 | override fun getInputStreamForJsonFile(fileName: String): InputStream { 28 | return FileInputStream(ASSET_BASE_PATH + fileName) 29 | } 30 | } 31 | } 32 | 33 | @Test 34 | fun `given getMovies call made, when live data isInitialised, then adding observer emits onChanged`() { 35 | 36 | val observer = mockk>>() 37 | every { observer.onChanged(any()) } just Runs 38 | 39 | moviesListViewModel.getMovies().observe(MoviesLifeCycleOwner(), observer) 40 | 41 | verify { observer.onChanged(any()) } 42 | verify { 43 | observer.onChanged(match { it.size == 20 }) 44 | } 45 | 46 | confirmVerified(observer) 47 | } 48 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 17 | 18 | 24 | 25 | 31 | 32 | 39 | 40 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 17 | 18 | 24 | 25 | 31 | 32 | 39 | 40 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/data/MoviesRepository.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.data 2 | 3 | import android.content.Context 4 | import androidx.lifecycle.LiveData 5 | import androidx.lifecycle.MutableLiveData 6 | import com.squareup.moshi.JsonAdapter 7 | import com.squareup.moshi.Moshi 8 | import com.squareup.moshi.Types 9 | import java.io.IOException 10 | import java.io.InputStream 11 | 12 | /** 13 | * Created by Alex Forrester on 17/04/2019. 14 | * 15 | * Read in a flat file json list of movies from Assets folder and deserializes to list of movies before creating LiveData object 16 | * 17 | * The Live Data object is initialised with a value when {@link #getMovies() getMovies} is called which will be emitted when observer added 18 | * 19 | * No caching or optimisation is preformed for this example 20 | * 21 | */ 22 | internal interface PopularMoviesRepository { 23 | fun getMovies(): LiveData> 24 | } 25 | 26 | internal object MoshiFactory { 27 | 28 | private val moshi : Moshi = Moshi.Builder() 29 | .add(GenreAdapter()) 30 | .build() 31 | 32 | fun getInstance() = moshi 33 | } 34 | 35 | internal open class PopularMoviesRepositoryImpl( 36 | private val context: Context, 37 | private val moshi: Moshi = MoshiFactory.getInstance()) : PopularMoviesRepository { 38 | 39 | private val moviesLiveData = MutableLiveData>() 40 | 41 | /** 42 | * Sets and returns the LiveData object so observers will be notified of the last change 43 | */ 44 | override fun getMovies() : LiveData> { 45 | 46 | val moviesJson = getMovieJSON() 47 | 48 | val listType = Types.newParameterizedType(List::class.java, Movie::class.java) 49 | val adapter: JsonAdapter> = moshi.adapter(listType) 50 | val result = adapter.fromJson(moviesJson) 51 | 52 | moviesLiveData.value = result 53 | 54 | return moviesLiveData 55 | } 56 | 57 | private fun getMovieJSON(fileName : String = "popular_movies_list.json"): String { 58 | val inputStream = getInputStreamForJsonFile(fileName) 59 | return inputStream.bufferedReader().use { it.readText() } 60 | } 61 | 62 | @Throws(IOException::class) 63 | internal open fun getInputStreamForJsonFile(fileName: String): InputStream { 64 | return context.assets.open(fileName) 65 | } 66 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/data/MoviesRepository.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.data 2 | 3 | import android.content.Context 4 | import androidx.lifecycle.LiveData 5 | import androidx.lifecycle.MutableLiveData 6 | import com.squareup.moshi.JsonAdapter 7 | import com.squareup.moshi.Moshi 8 | import com.squareup.moshi.Types 9 | import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory 10 | import java.io.IOException 11 | import java.io.InputStream 12 | 13 | /** 14 | * Created by Alex Forrester on 17/04/2019. 15 | * 16 | * Read in a flat file json list of movies from Assets folder and deserializes to list of movies before creating LiveData object 17 | * 18 | * The Live Data object is initialised with a value when {@link #getMovies() getMovies} is called which will be emitted when observer added 19 | * 20 | * No caching or optimisation is preformed for this example 21 | * 22 | */ 23 | internal interface PopularMoviesRepository { 24 | fun getMovies(): LiveData> 25 | } 26 | 27 | internal object MoshiFactory { 28 | 29 | private val moshi : Moshi = Moshi.Builder() 30 | .add(GenreAdapter()) 31 | .add(KotlinJsonAdapterFactory()) 32 | .build() 33 | 34 | fun getInstance() = moshi 35 | } 36 | 37 | internal open class PopularMoviesRepositoryImpl( 38 | private val context: Context, 39 | private val moshi: Moshi = MoshiFactory.getInstance()): PopularMoviesRepository { 40 | 41 | private val moviesLiveData = MutableLiveData>() 42 | 43 | /** 44 | * Sets and returns the LiveData object so observers will be notified of the last change 45 | */ 46 | override fun getMovies() : LiveData> { 47 | 48 | val moviesJson = getMovieJSON() 49 | 50 | val listType = Types.newParameterizedType(List::class.java, Movie::class.java) 51 | val adapter: JsonAdapter> = moshi.adapter(listType) 52 | val result = adapter.fromJson(moviesJson) 53 | 54 | moviesLiveData.value = result 55 | 56 | return moviesLiveData 57 | } 58 | 59 | private fun getMovieJSON(fileName : String = "popular_movies_list.json"): String { 60 | val inputStream = getInputStreamForJsonFile(fileName) 61 | return inputStream.bufferedReader().use { it.readText() } 62 | } 63 | 64 | @Throws(IOException::class) 65 | internal open fun getInputStreamForJsonFile(fileName: String): InputStream { 66 | return context.assets.open(fileName) 67 | } 68 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: "androidx.navigation.safeargs.kotlin" 5 | 6 | android { 7 | compileSdkVersion 28 8 | defaultConfig { 9 | applicationId "com.digian.example.moshireflection" 10 | minSdkVersion 21 11 | targetSdkVersion 28 12 | versionCode 1 13 | versionName "1.0" 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | //Dependency versions added directly, for real project would be added in top level gradle file with extension properties 26 | 27 | //Kotlin 28 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 29 | 30 | //Material design 31 | implementation 'com.google.android.material:material:1.0.0' 32 | 33 | //AndroidX 34 | implementation 'androidx.appcompat:appcompat:1.1.0-alpha04' 35 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 36 | implementation 'androidx.recyclerview:recyclerview:1.0.0' 37 | implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' 38 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 39 | implementation "androidx.navigation:navigation-fragment-ktx:2.1.0-alpha02" 40 | implementation "androidx.navigation:navigation-ui-ktx:2.1.0-alpha02" 41 | 42 | //Moshi Core 43 | implementation "com.squareup.moshi:moshi:$moshi_version" 44 | 45 | //Moshi Reflection 46 | implementation "com.squareup.moshi:moshi-kotlin:$moshi_version" 47 | 48 | //Image Loading 49 | implementation 'com.squareup.picasso:picasso:2.71828' 50 | 51 | //Unit Tests 52 | testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1' 53 | testImplementation 'io.mockk:mockk:1.9.3' 54 | testImplementation 'androidx.arch.core:core-testing:2.0.0-rc01' 55 | 56 | //UI Tests 57 | androidTestImplementation 'androidx.test:core:1.2.0-alpha04' 58 | androidTestImplementation 'androidx.test.ext:junit:1.1.1-alpha04' 59 | androidTestImplementation 'androidx.test:runner:1.2.0-alpha04' 60 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha04' 61 | androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0-alpha04' 62 | 63 | } 64 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: 'kotlin-kapt' 5 | apply plugin: "androidx.navigation.safeargs.kotlin" 6 | 7 | android { 8 | compileSdkVersion 28 9 | defaultConfig { 10 | applicationId "com.digian.example.moshicodegen" 11 | minSdkVersion 21 12 | targetSdkVersion 28 13 | versionCode 1 14 | versionName "1.0" 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | //Dependency versions added directly, for real project would be added in top level gradle file with extension properties 27 | 28 | //Kotlin 29 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 30 | 31 | //Material design 32 | implementation 'com.google.android.material:material:1.0.0' 33 | 34 | //AndroidX 35 | implementation 'androidx.appcompat:appcompat:1.1.0-alpha04' 36 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 37 | implementation 'androidx.recyclerview:recyclerview:1.0.0' 38 | implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0' 39 | implementation 'androidx.legacy:legacy-support-v4:1.0.0' 40 | implementation "androidx.navigation:navigation-fragment-ktx:2.1.0-alpha02" 41 | implementation "androidx.navigation:navigation-ui-ktx:2.1.0-alpha02" 42 | 43 | //Moshi Core Artifact 44 | implementation "com.squareup.moshi:moshi:$moshi_version" 45 | 46 | //Moshi Codegen 47 | kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshi_version" 48 | 49 | //Image Loading 50 | implementation 'com.squareup.picasso:picasso:2.71828' 51 | 52 | //Unit Tests 53 | testImplementation 'org.junit.jupiter:junit-jupiter:5.4.1' 54 | testImplementation 'io.mockk:mockk:1.9.3' 55 | testImplementation 'androidx.arch.core:core-testing:2.0.0-rc01' 56 | 57 | //UI Tests 58 | androidTestImplementation 'androidx.test:core:1.2.0-alpha04' 59 | androidTestImplementation 'androidx.test.ext:junit:1.1.1-alpha04' 60 | androidTestImplementation 'androidx.test:runner:1.2.0-alpha04' 61 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha04' 62 | androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0-alpha04' 63 | 64 | } 65 | -------------------------------------------------------------------------------- /MoshiCodegenSample/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /MoshiReflectionSample/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/ui/MoviesListFragment.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.annotation.Nullable 9 | import androidx.fragment.app.Fragment 10 | import androidx.lifecycle.Observer 11 | import androidx.lifecycle.ViewModelProviders 12 | import androidx.navigation.fragment.findNavController 13 | import androidx.recyclerview.widget.DividerItemDecoration 14 | import androidx.recyclerview.widget.LinearLayoutManager 15 | import androidx.recyclerview.widget.RecyclerView 16 | import com.digian.example.moshicodegen.R 17 | import com.digian.example.moshicodegen.data.Movie 18 | import kotlinx.android.synthetic.main.fragment_movies.* 19 | 20 | /** 21 | * Created by Alex Forrester on 24/04/2019. 22 | */ 23 | class MoviesListFragment : Fragment() { 24 | 25 | private lateinit var moviesRecyclerView: RecyclerView 26 | private lateinit var moviesAdapter: MoviesAdapter 27 | private lateinit var moviesViewManager: RecyclerView.LayoutManager 28 | private lateinit var moviesListViewModel: MoviesListViewModel 29 | 30 | override fun onCreateView( 31 | inflater: LayoutInflater, container: ViewGroup?, 32 | savedInstanceState: Bundle? 33 | ): View? { 34 | return inflater.inflate(R.layout.fragment_movies, container, false) 35 | } 36 | 37 | override fun onActivityCreated(@Nullable savedInstanceState: Bundle?) { 38 | super.onActivityCreated(savedInstanceState) 39 | 40 | moviesListViewModel = ViewModelProviders.of(this).get(MoviesListViewModel::class.java) 41 | moviesViewManager = LinearLayoutManager(this.context) 42 | moviesAdapter = MoviesAdapter(object : OnItemClickListener { 43 | override fun onItemClick(movie: Movie) { 44 | val action = MoviesListFragmentDirections.actionMoviesFragmentToMovieDetailFragment(movie.id) 45 | findNavController().navigate(action) 46 | } 47 | }) 48 | 49 | moviesRecyclerView = movies_recycler_view.apply { 50 | setHasFixedSize(true) 51 | 52 | layoutManager = moviesViewManager 53 | adapter = moviesAdapter 54 | 55 | addItemDecoration(DividerItemDecoration(context, (layoutManager as LinearLayoutManager).orientation)) 56 | } 57 | 58 | moviesListViewModel.getMovies().observe(this, 59 | Observer> { popularMovies -> 60 | moviesAdapter.data = popularMovies 61 | }) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/ui/MoviesListFragment.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | 4 | import android.os.Bundle 5 | import android.view.LayoutInflater 6 | import android.view.View 7 | import android.view.ViewGroup 8 | import androidx.annotation.Nullable 9 | import androidx.fragment.app.Fragment 10 | import androidx.lifecycle.Observer 11 | import androidx.lifecycle.ViewModelProviders 12 | import androidx.navigation.fragment.findNavController 13 | import androidx.recyclerview.widget.DividerItemDecoration 14 | import androidx.recyclerview.widget.LinearLayoutManager 15 | import androidx.recyclerview.widget.RecyclerView 16 | import com.digian.example.moshireflection.R 17 | import com.digian.example.moshireflection.data.Movie 18 | import kotlinx.android.synthetic.main.fragment_movies.* 19 | 20 | /** 21 | * Created by Alex Forrester on 24/04/2019. 22 | */ 23 | class MoviesListFragment : Fragment() { 24 | 25 | private lateinit var moviesRecyclerView: RecyclerView 26 | private lateinit var moviesAdapter: MoviesAdapter 27 | private lateinit var moviesViewManager: RecyclerView.LayoutManager 28 | private lateinit var moviesListViewModel: MoviesListViewModel 29 | 30 | override fun onCreateView( 31 | inflater: LayoutInflater, container: ViewGroup?, 32 | savedInstanceState: Bundle? 33 | ): View? { 34 | return inflater.inflate(R.layout.fragment_movies, container, false) 35 | } 36 | 37 | override fun onActivityCreated(@Nullable savedInstanceState: Bundle?) { 38 | super.onActivityCreated(savedInstanceState) 39 | 40 | moviesListViewModel = ViewModelProviders.of(this).get(MoviesListViewModel::class.java) 41 | moviesViewManager = LinearLayoutManager(this.context) 42 | moviesAdapter = MoviesAdapter(object : OnItemClickListener { 43 | override fun onItemClick(movie: Movie) { 44 | val action = MoviesListFragmentDirections.actionMoviesFragmentToMovieDetailFragment(movie.id) 45 | findNavController().navigate(action) 46 | } 47 | }) 48 | 49 | moviesRecyclerView = movies_recycler_view.apply { 50 | setHasFixedSize(true) 51 | 52 | layoutManager = moviesViewManager 53 | adapter = moviesAdapter 54 | 55 | addItemDecoration(DividerItemDecoration(context, (layoutManager as LinearLayoutManager).orientation)) 56 | } 57 | 58 | moviesListViewModel.getMovies().observe(this, 59 | Observer> { popularMovies -> 60 | moviesAdapter.data = popularMovies 61 | }) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/layout/fragment_movie_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 28 | 29 | 37 | 38 | 47 | 48 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/layout/fragment_movie_detail.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 28 | 29 | 37 | 38 | 47 | 48 | 49 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # android-moshi 2 | 3 | [![Kotlin](https://kotlin.link/awesome-kotlin.svg)](https://kotlinlang.org/) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) 4 | 5 | Sample projects using Android Architecture Components to illustrate Moshi parsing of JSON into Kotlin objects with codegen and reflection 6 | 7 | ### Posting 8 | Getting started using Moshi for JSON parsing with Kotlin: https://proandroiddev.com/getting-started-using-moshi-for-json-parsing-with-kotlin-5a460bf3935a
9 | 10 | There are a number of libraries for parsing json into kotlin/java objects including Gson, Jackson and Moshi 11 | 12 | [Moshi](https://github.com/square/moshi) is developed by Square and is targeted at the Android platform. It uses Kotlin language features to make parsing JSON data simpler and and more robust when handling null and absent responses. This repo illustrates some of Moshi's features and different implementations of how the library can be added in android projects using the reflection and codegen artifacts 13 | 14 | ### App Description and Implementation 15 | 16 | Both samples use androidx and ViewModel, LiveData and Navigation architecture components to display a list of Popular movies from [The Movie Database](https://www.themoviedb.org) which has been added as a file in the Assets folder. Selecting a movie will display a movie detail page including title, overview, image, the popularity of the movie in terms of the votes received and the genres it belongs to. The genres demonstrate bespoke parsing with Moshi to map Genre ids to Genres from the ingested JSON.\ 17 | \ 18 | Unit tests use [JUnit 5](https://junit.org/junit5) and [Mockk](https://github.com/mockk/mockk)\ 19 | Integration Tests use [Espresso](https://developer.android.com/training/testing/espresso) 20 | 21 | ### Moshi Codegen and Reflection 22 | The two samples differ only in how Moshi has been included and implemented with either the moshi-kotlin-codegen artifact for codegen and the moshi-kotlin artifact for reflection. More detail about the two options are in the [official documentation](https://github.com/square/moshi#Kotlin). 23 | 24 | ### License 25 | 26 | Copyright 2019 Alex Forrester 27 | 28 | Licensed under the Apache License, Version 2.0 (the "License"); 29 | you may not use this file except in compliance with the License. 30 | You may obtain a copy of the License at 31 | 32 | http://www.apache.org/licenses/LICENSE-2.0 33 | 34 | Unless required by applicable law or agreed to in writing, software 35 | distributed under the License is distributed on an "AS IS" BASIS, 36 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 37 | See the License for the specific language governing permissions and 38 | limitations under the License. 39 | 40 | 41 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/ui/MovieDetailViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | import androidx.lifecycle.Observer 4 | import com.digian.example.moshicodegen.InstantExecutorExtension 5 | import com.digian.example.moshicodegen.MoviesLifeCycleOwner 6 | import com.digian.example.moshicodegen.data.* 7 | import io.mockk.* 8 | import org.junit.jupiter.api.Test 9 | import org.junit.jupiter.api.extension.ExtendWith 10 | import java.io.FileInputStream 11 | import java.io.InputStream 12 | 13 | /** 14 | * Created by Alex Forrester on 2019-04-24. 15 | */ 16 | @ExtendWith(InstantExecutorExtension::class) 17 | internal class MovieDetailViewModelTest { 18 | 19 | private val moviesDetailViewModel: MovieDetailViewModel = object : MovieDetailViewModel(mockk()) { 20 | 21 | override fun getRepository() : PopularMoviesRepository = object : 22 | PopularMoviesRepositoryImpl(mockk()) { 23 | 24 | override fun getInputStreamForJsonFile(fileName: String): InputStream { 25 | return FileInputStream(ASSET_BASE_PATH + fileName) 26 | } 27 | } 28 | } 29 | 30 | @Test 31 | fun `given valid movie id, when used to retrieve movie, then movie state returned correctly`() { 32 | 33 | val observer = mockk>() 34 | every{ observer.onChanged(any()) } just Runs 35 | 36 | moviesDetailViewModel.getMovie(278).observe(MoviesLifeCycleOwner(), observer) 37 | 38 | verify { observer.onChanged(any()) } 39 | verify { observer.onChanged(ofType(Movie::class))} 40 | verify { observer.onChanged(match { it.title == "The Shawshank Redemption" })} 41 | verify { observer.onChanged(match { it.voteCount == 12691 })} 42 | verify { observer.onChanged(match { it.genres == listOf(Genre(18,"Drama"),Genre(80, "Crime")) })} 43 | verify { observer.onChanged(match { it.overview == "Framed in the 1940s for the double murder of his wife and her lover, " + 44 | "upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. " + 45 | "During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- " + 46 | "for his integrity and unquenchable sense of hope." })} 47 | 48 | confirmVerified(observer) 49 | } 50 | 51 | @Test 52 | fun `given invalid movie id, when used to retrieve movie, then movie state not set`() { 53 | 54 | val observer = mockk>() 55 | every{ observer.onChanged(any()) } just Runs 56 | 57 | //Verifying observer called when no movie found 58 | moviesDetailViewModel.getMovie(UNKNOWN_MOVIE_ID).observe(MoviesLifeCycleOwner(), observer) 59 | 60 | verify { observer.onChanged(any())} 61 | verify { observer.onChanged(isNull())} 62 | 63 | confirmVerified(observer) 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/ui/MovieDetailViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | import androidx.lifecycle.Observer 4 | import com.digian.example.moshireflection.InstantExecutorExtension 5 | import com.digian.example.moshireflection.MoviesLifeCycleOwner 6 | import com.digian.example.moshireflection.data.* 7 | import io.mockk.* 8 | import org.junit.jupiter.api.Test 9 | import org.junit.jupiter.api.extension.ExtendWith 10 | import java.io.FileInputStream 11 | import java.io.InputStream 12 | 13 | /** 14 | * Created by Alex Forrester on 2019-04-24. 15 | */ 16 | @ExtendWith(InstantExecutorExtension::class) 17 | internal class MovieDetailViewModelTest { 18 | 19 | private val moviesDetailViewModel: MovieDetailViewModel = object : MovieDetailViewModel(mockk()) { 20 | 21 | override fun getRepository() : PopularMoviesRepository = object : 22 | PopularMoviesRepositoryImpl(mockk()) { 23 | 24 | override fun getInputStreamForJsonFile(fileName: String): InputStream { 25 | return FileInputStream(ASSET_BASE_PATH + fileName) 26 | } 27 | } 28 | } 29 | 30 | @Test 31 | fun `given valid movie id, when used to retrieve movie, then movie state returned correctly`() { 32 | 33 | val observer = mockk>() 34 | every{ observer.onChanged(any()) } just Runs 35 | 36 | moviesDetailViewModel.getMovie(278).observe(MoviesLifeCycleOwner(), observer) 37 | 38 | verify { observer.onChanged(any()) } 39 | verify { observer.onChanged(ofType(Movie::class))} 40 | verify { observer.onChanged(match { it.title == "The Shawshank Redemption" })} 41 | verify { observer.onChanged(match { it.voteCount == 12691 })} 42 | verify { observer.onChanged(match { it.imagePath == "/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg" })} 43 | verify { observer.onChanged(match { it.genres == listOf(Genre(18,"Drama"),Genre(80, "Crime")) })} 44 | verify { observer.onChanged(match { it.overview == "Framed in the 1940s for the double murder of his wife and her lover, " + 45 | "upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. " + 46 | "During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- " + 47 | "for his integrity and unquenchable sense of hope." })} 48 | 49 | confirmVerified(observer) 50 | } 51 | 52 | @Test 53 | fun `given invalid movie id, when used to retrieve movie, then movie state not set`() { 54 | 55 | val observer = mockk>() 56 | every{ observer.onChanged(any()) } just Runs 57 | 58 | //Verifying observer called when no movie found 59 | moviesDetailViewModel.getMovie(UNKNOWN_MOVIE_ID).observe(MoviesLifeCycleOwner(), observer) 60 | 61 | verify { observer.onChanged(any())} 62 | verify { observer.onChanged(isNull())} 63 | 64 | confirmVerified(observer) 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/test/java/com/digian/example/moshicodegen/data/MoviesRepositoryTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.data 2 | 3 | import androidx.lifecycle.Observer 4 | import com.digian.example.moshicodegen.InstantExecutorExtension 5 | import com.digian.example.moshicodegen.MoviesLifeCycleOwner 6 | import io.mockk.* 7 | import org.junit.jupiter.api.Assertions.* 8 | import org.junit.jupiter.api.Test 9 | import org.junit.jupiter.api.extension.ExtendWith 10 | import org.junit.jupiter.api.function.Executable 11 | import java.io.FileInputStream 12 | import java.io.InputStream 13 | 14 | /** 15 | * Created by Alex Forrester on 11/04/2019. 16 | */ 17 | const val ASSET_BASE_PATH = "../app/src/main/assets/" 18 | 19 | @ExtendWith(InstantExecutorExtension::class) 20 | internal class PopularPopularMoviesRepositoryTest { 21 | 22 | private val popularMoviesRepository: PopularMoviesRepository = object : 23 | PopularMoviesRepositoryImpl(mockk()) { 24 | 25 | override fun getInputStreamForJsonFile(fileName: String): InputStream { 26 | return FileInputStream(ASSET_BASE_PATH + fileName) 27 | } 28 | } 29 | 30 | @Test 31 | internal fun `given live data movie list is initialised, when observer added, then observer notified`() { 32 | 33 | val observer = mockk>>() 34 | every{ observer.onChanged(any()) } just Runs 35 | 36 | popularMoviesRepository.getMovies().observe(MoviesLifeCycleOwner(), observer) 37 | 38 | verify {observer.onChanged(any()) } 39 | } 40 | 41 | @Test 42 | internal fun `given live data movie list is called, when flat json file parsed, then movie list created`() { 43 | 44 | val popularMovies = popularMoviesRepository.getMovies().value 45 | 46 | assertAll( 47 | Executable { assertEquals(20, popularMovies?.size) } 48 | ) 49 | } 50 | 51 | @Test 52 | internal fun `given live data movie list is called, when flat json file parsed, then individual movie has correct state`() { 53 | 54 | val popularMovies = popularMoviesRepository.getMovies().value 55 | 56 | val movie = popularMovies!![1] 57 | 58 | assertAll( 59 | 60 | //Test Individual film 61 | Executable { assertEquals(12691, movie.voteCount) }, 62 | Executable { assertEquals(278, movie.id) }, 63 | Executable { assertEquals("The Shawshank Redemption", movie.title) }, 64 | Executable { assertEquals(listOf(Genre(18,"Drama"),Genre(80, "Crime")), movie.genres) }, 65 | Executable { assertEquals("Framed in the 1940s for the double murder of his wife and her lover, " + 66 | "upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. " + 67 | "During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- " + 68 | "for his integrity and unquenchable sense of hope.", movie.overview) } 69 | ) 70 | } 71 | } 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/test/java/com/digian/example/moshireflection/data/MoviesRepositoryTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.data 2 | 3 | import androidx.lifecycle.Observer 4 | import com.digian.example.moshireflection.InstantExecutorExtension 5 | import com.digian.example.moshireflection.MoviesLifeCycleOwner 6 | import io.mockk.* 7 | import org.junit.jupiter.api.Assertions.* 8 | import org.junit.jupiter.api.Test 9 | import org.junit.jupiter.api.extension.ExtendWith 10 | import org.junit.jupiter.api.function.Executable 11 | import java.io.FileInputStream 12 | import java.io.InputStream 13 | 14 | /** 15 | * Created by Alex Forrester on 11/04/2019. 16 | */ 17 | const val ASSET_BASE_PATH = "../app/src/main/assets/" 18 | 19 | @ExtendWith(InstantExecutorExtension::class) 20 | internal class PopularPopularMoviesRepositoryTest { 21 | 22 | private val popularMoviesRepository: PopularMoviesRepository = object : 23 | PopularMoviesRepositoryImpl(mockk()) { 24 | 25 | override fun getInputStreamForJsonFile(fileName: String): InputStream { 26 | return FileInputStream(ASSET_BASE_PATH + fileName) 27 | } 28 | } 29 | 30 | @Test 31 | internal fun `given live data movie list is initialised, when observer added, then observer notified`() { 32 | 33 | val observer = mockk>>() 34 | every{ observer.onChanged(any()) } just Runs 35 | 36 | popularMoviesRepository.getMovies().observe(MoviesLifeCycleOwner(), observer) 37 | 38 | verify {observer.onChanged(any()) } 39 | } 40 | 41 | @Test 42 | internal fun `given live data movie list is called, when flat json file parsed, then movie list created`() { 43 | 44 | val popularMovies = popularMoviesRepository.getMovies().value 45 | 46 | assertAll( 47 | Executable { assertEquals(20, popularMovies?.size) } 48 | ) 49 | } 50 | 51 | @Test 52 | internal fun `given live data movie list is called, when flat json file parsed, then individual movie has correct state`() { 53 | 54 | val popularMovies = popularMoviesRepository.getMovies().value 55 | 56 | val movie = popularMovies!![1] 57 | 58 | assertAll( 59 | 60 | //Test Individual film 61 | Executable { assertEquals(12691, movie.voteCount) }, 62 | Executable { assertEquals(278, movie.id) }, 63 | Executable { assertEquals("The Shawshank Redemption", movie.title) }, 64 | Executable { assertEquals("/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg", movie.imagePath) }, 65 | Executable { assertEquals(listOf(Genre(18,"Drama"),Genre(80, "Crime")), movie.genres) }, 66 | Executable { assertEquals("Framed in the 1940s for the double murder of his wife and her lover, " + 67 | "upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. " + 68 | "During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- " + 69 | "for his integrity and unquenchable sense of hope.", movie.overview) } 70 | ) 71 | } 72 | } 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/androidTest/java/com/digian/example/moshicodegen/MoviesListScreenTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen 2 | 3 | import androidx.recyclerview.widget.RecyclerView 4 | import androidx.test.core.app.ActivityScenario 5 | import androidx.test.espresso.Espresso.onView 6 | import androidx.test.espresso.action.ViewActions.click 7 | import androidx.test.espresso.assertion.ViewAssertions.doesNotExist 8 | import androidx.test.espresso.assertion.ViewAssertions.matches 9 | import androidx.test.espresso.contrib.RecyclerViewActions 10 | import androidx.test.espresso.matcher.ViewMatchers.* 11 | import androidx.test.ext.junit.runners.AndroidJUnit4 12 | import com.digian.example.moshicodegen.ui.MoviesActivity 13 | import org.junit.Before 14 | import org.junit.Test 15 | import org.junit.runner.RunWith 16 | 17 | /** 18 | * Created by Alex Forrester on 2019-04-25. 19 | */ 20 | private const val ITEM_BELOW_THE_FOLD = 18 21 | private const val ITEM_TITLE_ABOVE_THE_FOLD = "The Shawshank Redemption" 22 | private const val ITEM_TITLE_BELOW_THE_FOLD = "12 Angry Men" 23 | 24 | @RunWith(AndroidJUnit4::class) 25 | class MoviesListScreenTest { 26 | 27 | @Before 28 | fun launchActivity() { 29 | ActivityScenario.launch(MoviesActivity::class.java) 30 | } 31 | 32 | @Test 33 | fun given_app_first_loaded_when_viewing_list_then_movie_title_above_fold_displayed() { 34 | 35 | val itemElementText = ITEM_TITLE_ABOVE_THE_FOLD 36 | onView(withText(itemElementText)).check(matches(isDisplayed())) 37 | } 38 | 39 | @Test 40 | fun given_app_first_loaded_when_viewing_list_then_movie_title_below_fold_not_displayed() { 41 | 42 | val itemElementText = ITEM_TITLE_BELOW_THE_FOLD 43 | onView(withText(itemElementText)).check(doesNotExist()) 44 | } 45 | 46 | @Test 47 | fun given_app_first_loaded_when_scrolled_to_below_the_fold_then_movie_title_is_displayed() { 48 | 49 | onView(withId(R.id.movies_recycler_view)).perform( 50 | RecyclerViewActions.scrollToPosition( 51 | ITEM_BELOW_THE_FOLD 52 | ) 53 | ) 54 | 55 | val itemElementText = ITEM_TITLE_BELOW_THE_FOLD 56 | 57 | onView(withText(itemElementText)).check(matches(isDisplayed())) 58 | 59 | } 60 | 61 | @Test 62 | fun given_app_first_loaded_and_scrolled_to_below_the_fold_when_clicked_then_movie_details_are_displayed() { 63 | 64 | onView(withId(R.id.movies_recycler_view)).perform( 65 | RecyclerViewActions.scrollToPosition( 66 | ITEM_BELOW_THE_FOLD 67 | ) 68 | ) 69 | 70 | val movieTitleText = ITEM_TITLE_BELOW_THE_FOLD 71 | val movieDescriptionText = 72 | "The defense and the prosecution have rested and the jury is filing into the jury room to decide if a young Spanish-American is guilty or innocent of murdering his father. What begins as an open and shut case soon becomes a mini-drama of each of the jurors' prejudices and preconceptions about the trial, the accused, and each other." 73 | val movieVotes = "VOTES: 3603" 74 | val movieGenres = "GENRES: Drama" 75 | 76 | onView(withId(R.id.movies_recycler_view)).perform( 77 | RecyclerViewActions.actionOnItemAtPosition(ITEM_BELOW_THE_FOLD, click()) 78 | ) 79 | 80 | onView(withText(movieTitleText)).check(matches(isDisplayed())) 81 | onView(withText(movieDescriptionText)).check(matches(isDisplayed())) 82 | onView(withText(movieVotes)).check(matches(isDisplayed())) 83 | onView(withText(movieGenres)).check(matches(isDisplayed())) 84 | onView(withId(R.id.movie_image)).check(matches(isDisplayed())) 85 | 86 | } 87 | 88 | 89 | 90 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/androidTest/java/com/digian/example/moshireflection/MoviesListScreenTest.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection 2 | 3 | import androidx.recyclerview.widget.RecyclerView 4 | import androidx.test.core.app.ActivityScenario 5 | import androidx.test.espresso.Espresso.onView 6 | import androidx.test.espresso.action.ViewActions.click 7 | import androidx.test.espresso.assertion.ViewAssertions.doesNotExist 8 | import androidx.test.espresso.assertion.ViewAssertions.matches 9 | import androidx.test.espresso.contrib.RecyclerViewActions 10 | import androidx.test.espresso.matcher.ViewMatchers.* 11 | import androidx.test.ext.junit.runners.AndroidJUnit4 12 | import com.digian.example.moshireflection.ui.MoviesActivity 13 | import org.junit.Before 14 | import org.junit.Test 15 | import org.junit.runner.RunWith 16 | 17 | /** 18 | * Created by Alex Forrester on 2019-04-25. 19 | */ 20 | private const val ITEM_BELOW_THE_FOLD = 18 21 | private const val ITEM_TITLE_ABOVE_THE_FOLD = "The Shawshank Redemption" 22 | private const val ITEM_TITLE_BELOW_THE_FOLD = "12 Angry Men" 23 | 24 | @RunWith(AndroidJUnit4::class) 25 | class MoviesListScreenTest { 26 | 27 | 28 | @Before 29 | fun launchActivity() { 30 | ActivityScenario.launch(MoviesActivity::class.java) 31 | } 32 | 33 | @Test 34 | fun given_app_first_loaded_when_viewing_list_then_movie_title_above_fold_displayed() { 35 | 36 | val itemElementText = ITEM_TITLE_ABOVE_THE_FOLD 37 | onView(withText(itemElementText)).check(matches(isDisplayed())) 38 | } 39 | 40 | @Test 41 | fun given_app_first_loaded_when_viewing_list_then_movie_title_below_fold_not_displayed() { 42 | 43 | val itemElementText = ITEM_TITLE_BELOW_THE_FOLD 44 | onView(withText(itemElementText)).check(doesNotExist()) 45 | } 46 | 47 | @Test 48 | fun given_app_first_loaded_when_scrolled_to_below_the_fold_then_movie_title_is_displayed() { 49 | 50 | onView(withId(R.id.movies_recycler_view)).perform( 51 | RecyclerViewActions.scrollToPosition( 52 | ITEM_BELOW_THE_FOLD 53 | ) 54 | ) 55 | 56 | val itemElementText = ITEM_TITLE_BELOW_THE_FOLD 57 | 58 | onView(withText(itemElementText)).check(matches(isDisplayed())) 59 | 60 | } 61 | 62 | @Test 63 | fun given_app_first_loaded_and_scrolled_to_below_the_fold_when_clicked_then_movie_details_are_displayed() { 64 | 65 | onView(withId(R.id.movies_recycler_view)).perform( 66 | RecyclerViewActions.scrollToPosition( 67 | ITEM_BELOW_THE_FOLD 68 | ) 69 | ) 70 | 71 | val movieTitleText = ITEM_TITLE_BELOW_THE_FOLD 72 | val movieDescriptionText = 73 | "The defense and the prosecution have rested and the jury is filing into the jury room to decide if a young Spanish-American is guilty or innocent of murdering his father. What begins as an open and shut case soon becomes a mini-drama of each of the jurors' prejudices and preconceptions about the trial, the accused, and each other." 74 | val movieVotes = "VOTES: 3603" 75 | val movieGenres = "GENRES: Drama" 76 | 77 | onView(withId(R.id.movies_recycler_view)).perform( 78 | RecyclerViewActions.actionOnItemAtPosition(ITEM_BELOW_THE_FOLD, click()) 79 | ) 80 | 81 | onView(withText(movieTitleText)).check(matches(isDisplayed())) 82 | onView(withText(movieDescriptionText)).check(matches(isDisplayed())) 83 | onView(withText(movieVotes)).check(matches(isDisplayed())) 84 | onView(withText(movieGenres)).check(matches(isDisplayed())) 85 | onView(withId(R.id.movie_image)).check(matches(isDisplayed())) 86 | 87 | } 88 | 89 | 90 | } -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/java/com/digian/example/moshicodegen/ui/MovieDetailFragment.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshicodegen.ui 2 | 3 | 4 | import android.net.Uri 5 | import android.os.Bundle 6 | import android.util.Log 7 | import android.view.Gravity 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import android.widget.TextView 12 | import androidx.annotation.Nullable 13 | import androidx.constraintlayout.widget.ConstraintLayout 14 | import androidx.fragment.app.Fragment 15 | import androidx.lifecycle.Observer 16 | import androidx.lifecycle.ViewModelProviders 17 | import com.digian.example.moshicodegen.R 18 | import com.digian.example.moshicodegen.data.Genre 19 | import com.digian.example.moshicodegen.data.Movie 20 | import com.squareup.picasso.Callback 21 | import com.squareup.picasso.Picasso 22 | import kotlinx.android.synthetic.main.fragment_movie_detail.* 23 | 24 | const val UNKNOWN_MOVIE_ID = 0 25 | const val IMAGE_URL_AND_PATH = "https://image.tmdb.org/t/p/w400" 26 | const val PICASSO_RESULT = "PICASSO_RESULT" 27 | 28 | /** 29 | * Created by Alex Forrester on 23/04/2019. 30 | * 31 | * Fragment for displaying movie detail 32 | */ 33 | class MovieDetailFragment : Fragment() { 34 | 35 | companion object { 36 | fun createGenreText(genres: List): String { 37 | val genreNames = genres.map { genre -> genre.name } 38 | 39 | if (genres.isEmpty()) { 40 | return "" 41 | } 42 | 43 | var genresText = "GENRES: " 44 | 45 | genreNames.forEach { genre -> 46 | genresText += genre.plus(", ") 47 | } 48 | 49 | return genresText.trimEnd().substringBeforeLast(",") 50 | } 51 | } 52 | 53 | private lateinit var movieDetailViewModel: MovieDetailViewModel 54 | 55 | override fun onCreateView( 56 | inflater: LayoutInflater, container: ViewGroup?, 57 | savedInstanceState: Bundle? 58 | ): View? { 59 | // Inflate the layout for this fragment 60 | return inflater.inflate(R.layout.fragment_movie_detail, container, false) 61 | } 62 | 63 | override fun onActivityCreated(@Nullable savedInstanceState: Bundle?) { 64 | super.onActivityCreated(savedInstanceState) 65 | 66 | movieDetailViewModel = ViewModelProviders.of(this).get(MovieDetailViewModel::class.java) 67 | 68 | val movieId: Int = arguments?.getInt("movieId") ?: UNKNOWN_MOVIE_ID 69 | 70 | //Loads movie detail and returns from observer or displays error view 71 | movieDetailViewModel.getMovie(movieId).observe(this, 72 | Observer { movie -> 73 | 74 | movie?.let { movieDetail -> 75 | movieDetail.genres.let { genres -> 76 | 77 | if (genres.isNotEmpty()) { 78 | movie_genres.visibility = View.VISIBLE 79 | movie_genres.text = createGenreText(genres) 80 | } 81 | } 82 | movie_title.text = movieDetail.title 83 | movie_description.text = movieDetail.overview 84 | movie_votes.text = if (movieDetail.voteCount != -1) "VOTES: ${movieDetail.voteCount}" else "" 85 | loadImageView(movieDetail.imagePath) 86 | return@Observer 87 | } 88 | 89 | addErrorView() 90 | 91 | }) 92 | } 93 | 94 | private fun addErrorView() { 95 | 96 | val errorTextView = TextView(activity) 97 | errorTextView.text = getString(R.string.movie_detail_loading_error) 98 | errorTextView.gravity = Gravity.CENTER 99 | errorTextView.textSize = 20f 100 | errorTextView.layoutParams = 101 | ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 102 | movie_detail_root.addView(errorTextView) 103 | } 104 | 105 | private fun loadImageView(posterPath: String?) { 106 | 107 | val uri: Uri = Uri.parse(IMAGE_URL_AND_PATH.plus(posterPath)) 108 | 109 | val picasso = Picasso.get() 110 | picasso.isLoggingEnabled = true 111 | 112 | picasso 113 | .load(uri) 114 | .error(R.drawable.ic_error_black_80dp) 115 | .placeholder(R.drawable.placeholder460_690) 116 | .into(movie_image, object : Callback { 117 | override fun onSuccess() { 118 | Log.d(PICASSO_RESULT, "onSuccess") 119 | } 120 | 121 | override fun onError(e: Exception?) { 122 | Log.e(PICASSO_RESULT, "onError", e) 123 | } 124 | }) 125 | } 126 | } -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/java/com/digian/example/moshireflection/ui/MovieDetailFragment.kt: -------------------------------------------------------------------------------- 1 | package com.digian.example.moshireflection.ui 2 | 3 | 4 | import android.net.Uri 5 | import android.os.Bundle 6 | import android.util.Log 7 | import android.view.Gravity 8 | import android.view.LayoutInflater 9 | import android.view.View 10 | import android.view.ViewGroup 11 | import android.widget.TextView 12 | import androidx.annotation.Nullable 13 | import androidx.constraintlayout.widget.ConstraintLayout 14 | import androidx.fragment.app.Fragment 15 | import androidx.lifecycle.Observer 16 | import androidx.lifecycle.ViewModelProviders 17 | import com.digian.example.moshireflection.R 18 | import com.digian.example.moshireflection.data.Genre 19 | import com.digian.example.moshireflection.data.Movie 20 | import com.squareup.picasso.Callback 21 | import com.squareup.picasso.Picasso 22 | import kotlinx.android.synthetic.main.fragment_movie_detail.* 23 | 24 | const val UNKNOWN_MOVIE_ID = 0 25 | const val IMAGE_URL_AND_PATH = "https://image.tmdb.org/t/p/w400" 26 | const val PICASSO_RESULT = "PICASSO_RESULT" 27 | 28 | /** 29 | * Created by Alex Forrester on 23/04/2019. 30 | * 31 | * Fragment for displaying movie detail 32 | */ 33 | class MovieDetailFragment : Fragment() { 34 | 35 | companion object { 36 | fun createGenreText(genres: List) : String { 37 | val genreNames = genres.map { genre -> genre.name } 38 | 39 | if (genres.isEmpty()) { 40 | return "" 41 | } 42 | 43 | var genresText = "GENRES: " 44 | 45 | genreNames.forEach { genre -> 46 | genresText += genre.plus(", ") 47 | } 48 | 49 | return genresText.trimEnd().substringBeforeLast(",") 50 | } 51 | } 52 | 53 | private lateinit var movieDetailViewModel: MovieDetailViewModel 54 | 55 | override fun onCreateView( 56 | inflater: LayoutInflater, container: ViewGroup?, 57 | savedInstanceState: Bundle? 58 | ): View? { 59 | // Inflate the layout for this fragment 60 | return inflater.inflate(R.layout.fragment_movie_detail, container, false) 61 | } 62 | 63 | override fun onActivityCreated(@Nullable savedInstanceState: Bundle?) { 64 | super.onActivityCreated(savedInstanceState) 65 | 66 | movieDetailViewModel = ViewModelProviders.of(this).get(MovieDetailViewModel::class.java) 67 | 68 | val movieId: Int = arguments?.getInt("movieId") ?: UNKNOWN_MOVIE_ID 69 | 70 | //Loads movie detail and returns from observer or displays error view 71 | movieDetailViewModel.getMovie(movieId).observe(this, 72 | Observer { movie -> 73 | 74 | movie?.let {movieDetail -> 75 | movieDetail.genres.let{ genres-> 76 | 77 | if (genres.isNotEmpty()) { 78 | movie_genres.visibility = View.VISIBLE 79 | movie_genres.text = createGenreText(genres) 80 | } 81 | } 82 | movie_title.text = movieDetail.title 83 | movie_description.text = movieDetail.overview 84 | movie_votes.text = if (movieDetail.voteCount != -1) "VOTES: ${movieDetail.voteCount}" else "" 85 | loadImageView(movieDetail.imagePath) 86 | return@Observer 87 | } 88 | 89 | addErrorView() 90 | 91 | }) 92 | } 93 | 94 | private fun addErrorView() { 95 | 96 | val errorTextView = TextView(activity) 97 | errorTextView.text = getString(R.string.movie_detail_loading_error) 98 | errorTextView.gravity = Gravity.CENTER 99 | errorTextView.textSize = 20f 100 | errorTextView.layoutParams = ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); 101 | movie_detail_root.addView(errorTextView) 102 | } 103 | 104 | private fun loadImageView(posterPath: String?) { 105 | 106 | val uri : Uri = Uri.parse(IMAGE_URL_AND_PATH.plus(posterPath)) 107 | 108 | val picasso = Picasso.get() 109 | picasso.isLoggingEnabled = true 110 | 111 | picasso 112 | .load(uri) 113 | .error(R.drawable.ic_error_black_80dp) 114 | .placeholder(R.drawable.placeholder460_690) 115 | .into(movie_image, object : Callback { 116 | override fun onSuccess() { 117 | Log.d(PICASSO_RESULT, "onSuccess") 118 | } 119 | 120 | override fun onError(e: Exception?) { 121 | Log.e(PICASSO_RESULT, "onError", e) 122 | } 123 | }) 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 16 | 18 | 20 | 22 | 24 | 26 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 64 | 66 | 68 | 70 | 72 | 74 | 75 | -------------------------------------------------------------------------------- /MoshiCodegenSample/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /MoshiReflectionSample/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MoshiCodegenSample/app/src/main/Assets/popular_movies_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "vote_count": 2026, 4 | "id": 19404, 5 | "video": false, 6 | "vote_average": 9, 7 | "title": "Dilwale Dulhania Le Jayenge", 8 | "popularity": 15.736, 9 | "image_path": "/uC6TTUhPpQCmgldGyYveKRAu8JN.jpg", 10 | "original_language": "hi", 11 | "original_title": "दिलवाले दुल्हनिया ले जायेंगे", 12 | "genre_ids": [ 13 | 35, 14 | 18, 15 | 10749 16 | ], 17 | "backdrop_path": "/nl79FQ8xWZkhL3rDr1v2RFFR6J0.jpg", 18 | "overview": "Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very strict about adherence to Indian values. Simran has left for India to be married to her childhood fiancé. Raj leaves for India with a mission at his hands, to claim his lady love under the noses of her whole family. Thus begins a saga.", 19 | "release_date": "1995-10-20" 20 | }, 21 | { 22 | "vote_count": 12691, 23 | "id": 278, 24 | "video": false, 25 | "vote_average": 8.7, 26 | "title": "The Shawshank Redemption", 27 | "popularity": 35.447, 28 | "image_path": "/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg", 29 | "original_language": "en", 30 | "original_title": "The Shawshank Redemption", 31 | "genre_ids": [ 32 | 18, 33 | 80 34 | ], 35 | "backdrop_path": "/j9XKiZrVeViAixVRzCta7h1VU9W.jpg", 36 | "overview": "Framed in the 1940s for the double murder of his wife and her lover, upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- for his integrity and unquenchable sense of hope.", 37 | "release_date": "1994-09-23" 38 | }, 39 | { 40 | "vote_count": 9714, 41 | "id": 238, 42 | "video": false, 43 | "vote_average": 8.6, 44 | "title": "The Godfather", 45 | "popularity": 31.951, 46 | "image_path": "/rPdtLWNsZmAtoZl9PK7S2wE3qiS.jpg", 47 | "original_language": "en", 48 | "original_title": "The Godfather", 49 | "genre_ids": [ 50 | 18, 51 | 80 52 | ], 53 | "backdrop_path": "/6xKCYgH16UuwEGAyroLU6p8HLIn.jpg", 54 | "overview": "Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.", 55 | "release_date": "1972-03-14" 56 | }, 57 | { 58 | "vote_count": 3887, 59 | "id": 372058, 60 | "video": false, 61 | "vote_average": 8.6, 62 | "title": "Your Name.", 63 | "popularity": 20.66, 64 | "image_path": "/xq1Ugd62d23K2knRUx6xxuALTZB.jpg", 65 | "original_language": "ja", 66 | "original_title": "君の名は。", 67 | "genre_ids": [ 68 | 10749, 69 | 16, 70 | 18 71 | ], 72 | "backdrop_path": "/7OMAfDJikBxItZBIug0NJig5DHD.jpg", 73 | "overview": "High schoolers Mitsuha and Taki are complete strangers living separate lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki’s body, and he in hers. This bizarre occurrence continues to happen randomly, and the two must adjust their lives around each other.", 74 | "release_date": "2016-08-26" 75 | }, 76 | { 77 | "vote_count": 7721, 78 | "id": 424, 79 | "video": false, 80 | "vote_average": 8.5, 81 | "title": "Schindler's List", 82 | "popularity": 28.643, 83 | "image_path": "/yPisjyLweCl1tbgwgtzBCNCBle.jpg", 84 | "original_language": "en", 85 | "original_title": "Schindler's List", 86 | "genre_ids": [ 87 | 18, 88 | 36, 89 | 10752 90 | ], 91 | "backdrop_path": "/af98P1bc7lJsFjhHOVWXQgNNgSQ.jpg", 92 | "adult": false, 93 | "overview": "The true story of how businessman Oskar Schindler saved over a thousand Jewish lives from the Nazis while they worked as slaves in his factory during World War II.", 94 | "release_date": "1993-12-15" 95 | }, 96 | { 97 | "vote_count": 5667, 98 | "id": 240, 99 | "video": false, 100 | "vote_average": 8.5, 101 | "title": "The Godfather: Part II", 102 | "popularity": 17.785, 103 | "image_path": "/bVq65huQ8vHDd1a4Z37QtuyEvpA.jpg", 104 | "original_language": "en", 105 | "original_title": "The Godfather: Part II", 106 | "genre_ids": [ 107 | 18, 108 | 80 109 | ], 110 | "backdrop_path": "/gLbBRyS7MBrmVUNce91Hmx9vzqI.jpg", 111 | "overview": "In the continuing saga of the Corleone crime family, a young Vito Corleone grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts to expand the family business into Las Vegas, Hollywood and Cuba.", 112 | "release_date": "1974-12-20" 113 | }, 114 | { 115 | "vote_count": 7147, 116 | "id": 129, 117 | "video": false, 118 | "vote_average": 8.5, 119 | "title": "Spirited Away", 120 | "popularity": 27.894, 121 | "image_path": "/oRvMaJOmapypFUcQqpgHMZA6qL9.jpg", 122 | "original_language": "ja", 123 | "original_title": "千と千尋の神隠し", 124 | "genre_ids": [ 125 | 16, 126 | 10751, 127 | 14 128 | ], 129 | "backdrop_path": "/mnpRKVSXBX6jb56nabvmGKA0Wig.jpg", 130 | "overview": "A young girl, Chihiro, becomes trapped in a strange new world of spirits. When her parents undergo a mysterious transformation, she must call upon the courage she never knew she had to free her family.", 131 | "release_date": "2001-07-20" 132 | }, 133 | { 134 | "vote_count": 3175, 135 | "id": 324857, 136 | "video": false, 137 | "vote_average": 8.5, 138 | "title": "Spider-Man: Into the Spider-Verse", 139 | "popularity": 94.663, 140 | "image_path": "/iiZZdoQBEYBv6id8su7ImL0oCbD.jpg", 141 | "original_language": "en", 142 | "original_title": "Spider-Man: Into the Spider-Verse", 143 | "genre_ids": [ 144 | 28, 145 | 12, 146 | 16, 147 | 878, 148 | 35 149 | ], 150 | "backdrop_path": "/uUiId6cG32JSRI6RyBQSvQtLjz2.jpg", 151 | "overview": "Miles Morales is juggling his life between being a high school student and being a spider-man. When Wilson \"Kingpin\" Fisk uses a super collider, others from across the Spider-Verse are transported to this dimension.", 152 | "release_date": "2018-12-07" 153 | }, 154 | { 155 | "vote_count": 7962, 156 | "id": 497, 157 | "video": false, 158 | "vote_average": 8.4, 159 | "title": "The Green Mile", 160 | "popularity": 21.303, 161 | "image_path": "/sOHqdY1RnSn6kcfAHKu28jvTebE.jpg", 162 | "original_language": "en", 163 | "original_title": "The Green Mile", 164 | "genre_ids": [ 165 | 14, 166 | 18, 167 | 80 168 | ], 169 | "backdrop_path": "/Rlt20sEbOQKPVjia7lUilFm49W.jpg", 170 | "overview": "A supernatural tale set on death row in a Southern prison, where gentle giant John Coffey possesses the mysterious power to heal people's ailments. When the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift, he tries desperately to help stave off the condemned man's execution.", 171 | "release_date": "1999-12-10" 172 | }, 173 | { 174 | "vote_count": 7013, 175 | "id": 637, 176 | "video": false, 177 | "vote_average": 8.4, 178 | "title": "Life Is Beautiful", 179 | "popularity": 20.749, 180 | "image_path": "/f7DImXDebOs148U4uPjI61iDvaK.jpg", 181 | "original_language": "it", 182 | "original_title": "La vita è bella", 183 | "genre_ids": [ 184 | 35, 185 | 18 186 | ], 187 | "backdrop_path": "/bORe0eI72D874TMawOOFvqWS6Xe.jpg", 188 | "overview": "A touching story of an Italian book seller of Jewish ancestry who lives in his own little fairy tale. His creative and happy life would come to an abrupt halt when his entire family is deported to a concentration camp during World War II. While locked up he tries to convince his son that the whole thing is just a game.", 189 | "release_date": "1997-12-20" 190 | }, 191 | { 192 | "vote_count": 409, 193 | "id": 40096, 194 | "video": false, 195 | "vote_average": 8.4, 196 | "title": "A Dog's Will", 197 | "popularity": 9.927, 198 | "image_path": "/uHEmM49YphluJnGep8Ef1qwD2QX.jpg", 199 | "original_language": "pt", 200 | "original_title": "O Auto da Compadecida", 201 | "genre_ids": [ 202 | 12, 203 | 35 204 | ], 205 | "backdrop_path": "/alQqTpmEkxSLgajfEYTsTH6nAKB.jpg", 206 | "overview": "The lively João Grilo and the sly Chicó are poor guys living in the hinterland who cheat a bunch of people in a small Northeast Brazil town. But when they die, they have to be judged by Christ, the Devil and the Virgin Mary, before they are admitted to paradise.", 207 | "release_date": "2000-09-15" 208 | }, 209 | { 210 | "vote_count": 14727, 211 | "id": 680, 212 | "video": false, 213 | "vote_average": 8.4, 214 | "title": "Pulp Fiction", 215 | "popularity": 31.908, 216 | "image_path": "/dM2w364MScsjFf8pfMbaWUcWrR.jpg", 217 | "original_language": "en", 218 | "original_title": "Pulp Fiction", 219 | "genre_ids": [ 220 | 53, 221 | 80 222 | ], 223 | "backdrop_path": "/4cDFJr4HnXN5AdPw4AKrmLlMWdO.jpg", 224 | "overview": "A burger-loving hit man, his philosophical partner, a drug-addled gangster's moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their adventures unfurl in three stories that ingeniously trip back and forth in time.", 225 | "release_date": "1994-09-10" 226 | }, 227 | { 228 | "vote_count": 18378, 229 | "id": 155, 230 | "video": false, 231 | "vote_average": 8.4, 232 | "title": "The Dark Knight", 233 | "popularity": 36.151, 234 | "image_path": "/1hRoyzDtpgMU7Dz4JF22RANzQO7.jpg", 235 | "original_language": "en", 236 | "original_title": "The Dark Knight", 237 | "genre_ids": [ 238 | 18, 239 | 28, 240 | 80, 241 | 53 242 | ], 243 | "backdrop_path": "/hqkIcbrOHL86UncnHIsHVcVmzue.jpg", 244 | "overview": "Batman raises the stakes in his war on crime. With the help of Lt. Jim Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining criminal organizations that plague the streets. The partnership proves to be effective, but they soon find themselves prey to a reign of chaos unleashed by a rising criminal mastermind known to the terrified citizens of Gotham as the Joker.", 245 | "release_date": "2008-07-16" 246 | }, 247 | { 248 | "vote_count": 15820, 249 | "id": 550, 250 | "video": false, 251 | "vote_average": 8.4, 252 | "title": "Fight Club", 253 | "popularity": 26.349, 254 | "image_path": "/adw6Lq9FiC9zjYEpOqfq03ituwp.jpg", 255 | "original_language": "en", 256 | "original_title": "Fight Club", 257 | "genre_ids": [ 258 | 18 259 | ], 260 | "backdrop_path": "/52AfXWuXCHn3UjD17rBruA9f5qb.jpg", 261 | "overview": "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy. Their concept catches on, with underground \"fight clubs\" forming in every town, until an eccentric gets in the way and ignites an out-of-control spiral toward oblivion.", 262 | "release_date": "1999-10-15" 263 | }, 264 | { 265 | "vote_count": 4718, 266 | "id": 539, 267 | "video": false, 268 | "vote_average": 8.4, 269 | "title": "Psycho", 270 | "popularity": 20.62, 271 | "image_path": "/81d8oyEFgj7FlxJqSDXWr8JH8kV.jpg", 272 | "original_language": "en", 273 | "original_title": "Psycho", 274 | "genre_ids": [ 275 | 27 276 | ], 277 | "backdrop_path": "/3md49VBCeqY6MSNyAVY6d5eC6bA.jpg", 278 | "overview": "When larcenous real estate clerk Marion Crane goes on the lam with a wad of cash and hopes of starting a new life, she ends up at the notorious Bates Motel, where manager Norman Bates cares for his housebound mother. The place seems quirky, but fine… until Marion decides to take a shower.", 279 | "release_date": "1960-06-16" 280 | }, 281 | { 282 | "vote_count": 14267, 283 | "id": 13, 284 | "video": false, 285 | "vote_average": 8.4, 286 | "title": "Forrest Gump", 287 | "popularity": 25.594, 288 | "image_path": "/yE5d3BUhE8hCnkMUJOo1QDoOGNz.jpg", 289 | "original_language": "en", 290 | "original_title": "Forrest Gump", 291 | "genre_ids": [ 292 | 35, 293 | 18, 294 | 10749 295 | ], 296 | "backdrop_path": "/wMgbnUVS9wbRGAdki8fqxKU1O0N.jpg", 297 | "overview": "A man with a low IQ has accomplished great things in his life and been present during significant historic events—in each case, far exceeding what anyone imagined he could do. But despite all he has achieved, his one true love eludes him.", 298 | "release_date": "1994-07-06" 299 | }, 300 | { 301 | "vote_count": 224, 302 | "id": 517814, 303 | "video": false, 304 | "vote_average": 8.4, 305 | "title": "Capernaum", 306 | "popularity": 18.23, 307 | "image_path": "/dQWfLmt9aU6Xe6yNPmEZJoLOPxX.jpg", 308 | "original_language": "ar", 309 | "original_title": "کفرناحوم", 310 | "genre_ids": [ 311 | 18 312 | ], 313 | "backdrop_path": "/8e0ETQmrgcP6R8TaVjd7o9NCGj9.jpg", 314 | "overview": "Zain, a 12-year-old boy scrambling to survive on the streets of Beirut, sues his parents for having brought him into such an unjust world, where being a refugee with no documents means that your rights can easily be denied.", 315 | "release_date": "2018-10-06" 316 | }, 317 | { 318 | "vote_count": 12767, 319 | "id": 122, 320 | "video": false, 321 | "vote_average": 8.4, 322 | "title": "The Lord of the Rings: The Return of the King", 323 | "popularity": 37.957, 324 | "image_path": "/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg", 325 | "original_language": "en", 326 | "original_title": "The Lord of the Rings: The Return of the King", 327 | "genre_ids": [ 328 | 12, 329 | 14, 330 | 28 331 | ], 332 | "backdrop_path": "/8BPZO0Bf8TeAy8znF43z8soK3ys.jpg", 333 | "overview": "Aragorn is revealed as the heir to the ancient kings as he, Gandalf and the other members of the broken fellowship struggle to save Gondor from Sauron's forces. Meanwhile, Frodo and Sam bring the ring closer to the heart of Mordor, the dark lord's realm.", 334 | "release_date": "2003-12-01" 335 | }, 336 | { 337 | "vote_count": 3603, 338 | "id": 389, 339 | "video": false, 340 | "vote_average": 8.4, 341 | "title": "12 Angry Men", 342 | "popularity": 21.166, 343 | "image_path": "/3W0v956XxSG5xgm7LB6qu8ExYJ2.jpg", 344 | "original_language": "en", 345 | "original_title": "12 Angry Men", 346 | "genre_ids": [ 347 | 18 348 | ], 349 | "backdrop_path": "/lH2Ga8OzjU1XlxJ73shOlPx6cRw.jpg", 350 | "overview": "The defense and the prosecution have rested and the jury is filing into the jury room to decide if a young Spanish-American is guilty or innocent of murdering his father. What begins as an open and shut case soon becomes a mini-drama of each of the jurors' prejudices and preconceptions about the trial, the accused, and each other.", 351 | "release_date": "1957-03-25" 352 | }, 353 | { 354 | "vote_count": 1938, 355 | "id": 12477, 356 | "video": false, 357 | "vote_average": 8.4, 358 | "title": "Grave of the Fireflies", 359 | "popularity": 0.6, 360 | "image_path": "/4u1vptE8aXuzb5zauZTmikyectV.jpg", 361 | "original_language": "ja", 362 | "original_title": "火垂るの墓", 363 | "genre_ids": [ 364 | 16, 365 | 18, 366 | 10752 367 | ], 368 | "backdrop_path": "/fCUIuG7y4YKC3hofZ8wsj7zhCpR.jpg", 369 | "overview": "In the final months of World War II, 14-year-old Seita and his sister Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan. After a falling out with their aunt, they move into an abandoned bomb shelter. With no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle to survive.", 370 | "release_date": "1988-04-16" 371 | } 372 | ] 373 | -------------------------------------------------------------------------------- /MoshiReflectionSample/app/src/main/Assets/popular_movies_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "vote_count": 2026, 4 | "id": 19404, 5 | "video": false, 6 | "vote_average": 9, 7 | "title": "Dilwale Dulhania Le Jayenge", 8 | "popularity": 15.736, 9 | "image_path": "/uC6TTUhPpQCmgldGyYveKRAu8JN.jpg", 10 | "original_language": "hi", 11 | "original_title": "दिलवाले दुल्हनिया ले जायेंगे", 12 | "genre_ids": [ 13 | 35, 14 | 18, 15 | 10749 16 | ], 17 | "backdrop_path": "/nl79FQ8xWZkhL3rDr1v2RFFR6J0.jpg", 18 | "overview": "Raj is a rich, carefree, happy-go-lucky second generation NRI. Simran is the daughter of Chaudhary Baldev Singh, who in spite of being an NRI is very strict about adherence to Indian values. Simran has left for India to be married to her childhood fiancé. Raj leaves for India with a mission at his hands, to claim his lady love under the noses of her whole family. Thus begins a saga.", 19 | "release_date": "1995-10-20" 20 | }, 21 | { 22 | "vote_count": 12691, 23 | "id": 278, 24 | "video": false, 25 | "vote_average": 8.7, 26 | "title": "The Shawshank Redemption", 27 | "popularity": 35.447, 28 | "image_path": "/9O7gLzmreU0nGkIB6K3BsJbzvNv.jpg", 29 | "original_language": "en", 30 | "original_title": "The Shawshank Redemption", 31 | "genre_ids": [ 32 | 18, 33 | 80 34 | ], 35 | "backdrop_path": "/j9XKiZrVeViAixVRzCta7h1VU9W.jpg", 36 | "overview": "Framed in the 1940s for the double murder of his wife and her lover, upstanding banker Andy Dufresne begins a new life at the Shawshank prison, where he puts his accounting skills to work for an amoral warden. During his long stretch in prison, Dufresne comes to be admired by the other inmates -- including an older prisoner named Red -- for his integrity and unquenchable sense of hope.", 37 | "release_date": "1994-09-23" 38 | }, 39 | { 40 | "vote_count": 9714, 41 | "id": 238, 42 | "video": false, 43 | "vote_average": 8.6, 44 | "title": "The Godfather", 45 | "popularity": 31.951, 46 | "image_path": "/rPdtLWNsZmAtoZl9PK7S2wE3qiS.jpg", 47 | "original_language": "en", 48 | "original_title": "The Godfather", 49 | "genre_ids": [ 50 | 18, 51 | 80 52 | ], 53 | "backdrop_path": "/6xKCYgH16UuwEGAyroLU6p8HLIn.jpg", 54 | "overview": "Spanning the years 1945 to 1955, a chronicle of the fictional Italian-American Corleone crime family. When organized crime family patriarch, Vito Corleone barely survives an attempt on his life, his youngest son, Michael steps in to take care of the would-be killers, launching a campaign of bloody revenge.", 55 | "release_date": "1972-03-14" 56 | }, 57 | { 58 | "vote_count": 3887, 59 | "id": 372058, 60 | "video": false, 61 | "vote_average": 8.6, 62 | "title": "Your Name.", 63 | "popularity": 20.66, 64 | "image_path": "/xq1Ugd62d23K2knRUx6xxuALTZB.jpg", 65 | "original_language": "ja", 66 | "original_title": "君の名は。", 67 | "genre_ids": [ 68 | 10749, 69 | 16, 70 | 18 71 | ], 72 | "backdrop_path": "/7OMAfDJikBxItZBIug0NJig5DHD.jpg", 73 | "overview": "High schoolers Mitsuha and Taki are complete strangers living separate lives. But one night, they suddenly switch places. Mitsuha wakes up in Taki’s body, and he in hers. This bizarre occurrence continues to happen randomly, and the two must adjust their lives around each other.", 74 | "release_date": "2016-08-26" 75 | }, 76 | { 77 | "vote_count": 7721, 78 | "id": 424, 79 | "video": false, 80 | "vote_average": 8.5, 81 | "title": "Schindler's List", 82 | "popularity": 28.643, 83 | "image_path": "/yPisjyLweCl1tbgwgtzBCNCBle.jpg", 84 | "original_language": "en", 85 | "original_title": "Schindler's List", 86 | "genre_ids": [ 87 | 18, 88 | 36, 89 | 10752 90 | ], 91 | "backdrop_path": "/af98P1bc7lJsFjhHOVWXQgNNgSQ.jpg", 92 | "adult": false, 93 | "overview": "The true story of how businessman Oskar Schindler saved over a thousand Jewish lives from the Nazis while they worked as slaves in his factory during World War II.", 94 | "release_date": "1993-12-15" 95 | }, 96 | { 97 | "vote_count": 5667, 98 | "id": 240, 99 | "video": false, 100 | "vote_average": 8.5, 101 | "title": "The Godfather: Part II", 102 | "popularity": 17.785, 103 | "image_path": "/bVq65huQ8vHDd1a4Z37QtuyEvpA.jpg", 104 | "original_language": "en", 105 | "original_title": "The Godfather: Part II", 106 | "genre_ids": [ 107 | 18, 108 | 80 109 | ], 110 | "backdrop_path": "/gLbBRyS7MBrmVUNce91Hmx9vzqI.jpg", 111 | "overview": "In the continuing saga of the Corleone crime family, a young Vito Corleone grows up in Sicily and in 1910s New York. In the 1950s, Michael Corleone attempts to expand the family business into Las Vegas, Hollywood and Cuba.", 112 | "release_date": "1974-12-20" 113 | }, 114 | { 115 | "vote_count": 7147, 116 | "id": 129, 117 | "video": false, 118 | "vote_average": 8.5, 119 | "title": "Spirited Away", 120 | "popularity": 27.894, 121 | "image_path": "/oRvMaJOmapypFUcQqpgHMZA6qL9.jpg", 122 | "original_language": "ja", 123 | "original_title": "千と千尋の神隠し", 124 | "genre_ids": [ 125 | 16, 126 | 10751, 127 | 14 128 | ], 129 | "backdrop_path": "/mnpRKVSXBX6jb56nabvmGKA0Wig.jpg", 130 | "overview": "A young girl, Chihiro, becomes trapped in a strange new world of spirits. When her parents undergo a mysterious transformation, she must call upon the courage she never knew she had to free her family.", 131 | "release_date": "2001-07-20" 132 | }, 133 | { 134 | "vote_count": 3175, 135 | "id": 324857, 136 | "video": false, 137 | "vote_average": 8.5, 138 | "title": "Spider-Man: Into the Spider-Verse", 139 | "popularity": 94.663, 140 | "image_path": "/iiZZdoQBEYBv6id8su7ImL0oCbD.jpg", 141 | "original_language": "en", 142 | "original_title": "Spider-Man: Into the Spider-Verse", 143 | "genre_ids": [ 144 | 28, 145 | 12, 146 | 16, 147 | 878, 148 | 35 149 | ], 150 | "backdrop_path": "/uUiId6cG32JSRI6RyBQSvQtLjz2.jpg", 151 | "overview": "Miles Morales is juggling his life between being a high school student and being a spider-man. When Wilson \"Kingpin\" Fisk uses a super collider, others from across the Spider-Verse are transported to this dimension.", 152 | "release_date": "2018-12-07" 153 | }, 154 | { 155 | "vote_count": 7962, 156 | "id": 497, 157 | "video": false, 158 | "vote_average": 8.4, 159 | "title": "The Green Mile", 160 | "popularity": 21.303, 161 | "image_path": "/sOHqdY1RnSn6kcfAHKu28jvTebE.jpg", 162 | "original_language": "en", 163 | "original_title": "The Green Mile", 164 | "genre_ids": [ 165 | 14, 166 | 18, 167 | 80 168 | ], 169 | "backdrop_path": "/Rlt20sEbOQKPVjia7lUilFm49W.jpg", 170 | "overview": "A supernatural tale set on death row in a Southern prison, where gentle giant John Coffey possesses the mysterious power to heal people's ailments. When the cell block's head guard, Paul Edgecomb, recognizes Coffey's miraculous gift, he tries desperately to help stave off the condemned man's execution.", 171 | "release_date": "1999-12-10" 172 | }, 173 | { 174 | "vote_count": 7013, 175 | "id": 637, 176 | "video": false, 177 | "vote_average": 8.4, 178 | "title": "Life Is Beautiful", 179 | "popularity": 20.749, 180 | "image_path": "/f7DImXDebOs148U4uPjI61iDvaK.jpg", 181 | "original_language": "it", 182 | "original_title": "La vita è bella", 183 | "genre_ids": [ 184 | 35, 185 | 18 186 | ], 187 | "backdrop_path": "/bORe0eI72D874TMawOOFvqWS6Xe.jpg", 188 | "overview": "A touching story of an Italian book seller of Jewish ancestry who lives in his own little fairy tale. His creative and happy life would come to an abrupt halt when his entire family is deported to a concentration camp during World War II. While locked up he tries to convince his son that the whole thing is just a game.", 189 | "release_date": "1997-12-20" 190 | }, 191 | { 192 | "vote_count": 409, 193 | "id": 40096, 194 | "video": false, 195 | "vote_average": 8.4, 196 | "title": "A Dog's Will", 197 | "popularity": 9.927, 198 | "image_path": "/uHEmM49YphluJnGep8Ef1qwD2QX.jpg", 199 | "original_language": "pt", 200 | "original_title": "O Auto da Compadecida", 201 | "genre_ids": [ 202 | 12, 203 | 35 204 | ], 205 | "backdrop_path": "/alQqTpmEkxSLgajfEYTsTH6nAKB.jpg", 206 | "overview": "The lively João Grilo and the sly Chicó are poor guys living in the hinterland who cheat a bunch of people in a small Northeast Brazil town. But when they die, they have to be judged by Christ, the Devil and the Virgin Mary, before they are admitted to paradise.", 207 | "release_date": "2000-09-15" 208 | }, 209 | { 210 | "vote_count": 14727, 211 | "id": 680, 212 | "video": false, 213 | "vote_average": 8.4, 214 | "title": "Pulp Fiction", 215 | "popularity": 31.908, 216 | "image_path": "/dM2w364MScsjFf8pfMbaWUcWrR.jpg", 217 | "original_language": "en", 218 | "original_title": "Pulp Fiction", 219 | "genre_ids": [ 220 | 53, 221 | 80 222 | ], 223 | "backdrop_path": "/4cDFJr4HnXN5AdPw4AKrmLlMWdO.jpg", 224 | "overview": "A burger-loving hit man, his philosophical partner, a drug-addled gangster's moll and a washed-up boxer converge in this sprawling, comedic crime caper. Their adventures unfurl in three stories that ingeniously trip back and forth in time.", 225 | "release_date": "1994-09-10" 226 | }, 227 | { 228 | "vote_count": 18378, 229 | "id": 155, 230 | "video": false, 231 | "vote_average": 8.4, 232 | "title": "The Dark Knight", 233 | "popularity": 36.151, 234 | "image_path": "/1hRoyzDtpgMU7Dz4JF22RANzQO7.jpg", 235 | "original_language": "en", 236 | "original_title": "The Dark Knight", 237 | "genre_ids": [ 238 | 18, 239 | 28, 240 | 80, 241 | 53 242 | ], 243 | "backdrop_path": "/hqkIcbrOHL86UncnHIsHVcVmzue.jpg", 244 | "overview": "Batman raises the stakes in his war on crime. With the help of Lt. Jim Gordon and District Attorney Harvey Dent, Batman sets out to dismantle the remaining criminal organizations that plague the streets. The partnership proves to be effective, but they soon find themselves prey to a reign of chaos unleashed by a rising criminal mastermind known to the terrified citizens of Gotham as the Joker.", 245 | "release_date": "2008-07-16" 246 | }, 247 | { 248 | "vote_count": 15820, 249 | "id": 550, 250 | "video": false, 251 | "vote_average": 8.4, 252 | "title": "Fight Club", 253 | "popularity": 26.349, 254 | "image_path": "/adw6Lq9FiC9zjYEpOqfq03ituwp.jpg", 255 | "original_language": "en", 256 | "original_title": "Fight Club", 257 | "genre_ids": [ 258 | 18 259 | ], 260 | "backdrop_path": "/52AfXWuXCHn3UjD17rBruA9f5qb.jpg", 261 | "overview": "A ticking-time-bomb insomniac and a slippery soap salesman channel primal male aggression into a shocking new form of therapy. Their concept catches on, with underground \"fight clubs\" forming in every town, until an eccentric gets in the way and ignites an out-of-control spiral toward oblivion.", 262 | "release_date": "1999-10-15" 263 | }, 264 | { 265 | "vote_count": 4718, 266 | "id": 539, 267 | "video": false, 268 | "vote_average": 8.4, 269 | "title": "Psycho", 270 | "popularity": 20.62, 271 | "image_path": "/81d8oyEFgj7FlxJqSDXWr8JH8kV.jpg", 272 | "original_language": "en", 273 | "original_title": "Psycho", 274 | "genre_ids": [ 275 | 27 276 | ], 277 | "backdrop_path": "/3md49VBCeqY6MSNyAVY6d5eC6bA.jpg", 278 | "overview": "When larcenous real estate clerk Marion Crane goes on the lam with a wad of cash and hopes of starting a new life, she ends up at the notorious Bates Motel, where manager Norman Bates cares for his housebound mother. The place seems quirky, but fine… until Marion decides to take a shower.", 279 | "release_date": "1960-06-16" 280 | }, 281 | { 282 | "vote_count": 14267, 283 | "id": 13, 284 | "video": false, 285 | "vote_average": 8.4, 286 | "title": "Forrest Gump", 287 | "popularity": 25.594, 288 | "image_path": "/yE5d3BUhE8hCnkMUJOo1QDoOGNz.jpg", 289 | "original_language": "en", 290 | "original_title": "Forrest Gump", 291 | "genre_ids": [ 292 | 35, 293 | 18, 294 | 10749 295 | ], 296 | "backdrop_path": "/wMgbnUVS9wbRGAdki8fqxKU1O0N.jpg", 297 | "overview": "A man with a low IQ has accomplished great things in his life and been present during significant historic events—in each case, far exceeding what anyone imagined he could do. But despite all he has achieved, his one true love eludes him.", 298 | "release_date": "1994-07-06" 299 | }, 300 | { 301 | "vote_count": 224, 302 | "id": 517814, 303 | "video": false, 304 | "vote_average": 8.4, 305 | "title": "Capernaum", 306 | "popularity": 18.23, 307 | "image_path": "/dQWfLmt9aU6Xe6yNPmEZJoLOPxX.jpg", 308 | "original_language": "ar", 309 | "original_title": "کفرناحوم", 310 | "genre_ids": [ 311 | 18 312 | ], 313 | "backdrop_path": "/8e0ETQmrgcP6R8TaVjd7o9NCGj9.jpg", 314 | "overview": "Zain, a 12-year-old boy scrambling to survive on the streets of Beirut, sues his parents for having brought him into such an unjust world, where being a refugee with no documents means that your rights can easily be denied.", 315 | "release_date": "2018-10-06" 316 | }, 317 | { 318 | "vote_count": 12767, 319 | "id": 122, 320 | "video": false, 321 | "vote_average": 8.4, 322 | "title": "The Lord of the Rings: The Return of the King", 323 | "popularity": 37.957, 324 | "image_path": "/rCzpDGLbOoPwLjy3OAm5NUPOTrC.jpg", 325 | "original_language": "en", 326 | "original_title": "The Lord of the Rings: The Return of the King", 327 | "genre_ids": [ 328 | 12, 329 | 14, 330 | 28 331 | ], 332 | "backdrop_path": "/8BPZO0Bf8TeAy8znF43z8soK3ys.jpg", 333 | "overview": "Aragorn is revealed as the heir to the ancient kings as he, Gandalf and the other members of the broken fellowship struggle to save Gondor from Sauron's forces. Meanwhile, Frodo and Sam bring the ring closer to the heart of Mordor, the dark lord's realm.", 334 | "release_date": "2003-12-01" 335 | }, 336 | { 337 | "vote_count": 3603, 338 | "id": 389, 339 | "video": false, 340 | "vote_average": 8.4, 341 | "title": "12 Angry Men", 342 | "popularity": 21.166, 343 | "image_path": "/3W0v956XxSG5xgm7LB6qu8ExYJ2.jpg", 344 | "original_language": "en", 345 | "original_title": "12 Angry Men", 346 | "genre_ids": [ 347 | 18 348 | ], 349 | "backdrop_path": "/lH2Ga8OzjU1XlxJ73shOlPx6cRw.jpg", 350 | "overview": "The defense and the prosecution have rested and the jury is filing into the jury room to decide if a young Spanish-American is guilty or innocent of murdering his father. What begins as an open and shut case soon becomes a mini-drama of each of the jurors' prejudices and preconceptions about the trial, the accused, and each other.", 351 | "release_date": "1957-03-25" 352 | }, 353 | { 354 | "vote_count": 1938, 355 | "id": 12477, 356 | "video": false, 357 | "vote_average": 8.4, 358 | "title": "Grave of the Fireflies", 359 | "popularity": 0.6, 360 | "image_path": "/4u1vptE8aXuzb5zauZTmikyectV.jpg", 361 | "original_language": "ja", 362 | "original_title": "火垂るの墓", 363 | "genre_ids": [ 364 | 16, 365 | 18, 366 | 10752 367 | ], 368 | "backdrop_path": "/fCUIuG7y4YKC3hofZ8wsj7zhCpR.jpg", 369 | "overview": "In the final months of World War II, 14-year-old Seita and his sister Setsuko are orphaned when their mother is killed during an air raid in Kobe, Japan. After a falling out with their aunt, they move into an abandoned bomb shelter. With no surviving relatives and their emergency rations depleted, Seita and Setsuko struggle to survive.", 370 | "release_date": "1988-04-16" 371 | } 372 | ] 373 | --------------------------------------------------------------------------------