├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── ic_launcher_background.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── themes.xml
│ │ │ ├── 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-hdpi
│ │ │ │ └── outline_south_america.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── outline_south_america.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── outline_south_america.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── outline_south_america.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ └── outline_south_america.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_back.xml
│ │ │ │ ├── ic_baseline_more_vert_24.xml
│ │ │ │ ├── ic_bulb.xml
│ │ │ │ ├── ic_launcher_foreground.xml
│ │ │ │ └── ic_dog.xml
│ │ │ └── values-night
│ │ │ │ └── themes.xml
│ │ ├── ic_launcher-playstore.png
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── gowtham
│ │ │ │ └── ricknmorty
│ │ │ │ ├── MApplication.kt
│ │ │ │ ├── compose
│ │ │ │ ├── theme
│ │ │ │ │ ├── Color.kt
│ │ │ │ │ ├── Shape.kt
│ │ │ │ │ ├── Type.kt
│ │ │ │ │ └── Theme.kt
│ │ │ │ ├── episode
│ │ │ │ │ ├── EpisodeViewModel.kt
│ │ │ │ │ └── EpisodeDetailScreen.kt
│ │ │ │ ├── location
│ │ │ │ │ ├── LocationViewModel.kt
│ │ │ │ │ └── LocationDetailScreen.kt
│ │ │ │ ├── character
│ │ │ │ │ ├── CharacterViewModel.kt
│ │ │ │ │ └── CharacterDetailScreen.kt
│ │ │ │ ├── locations
│ │ │ │ │ ├── LocationsDataSource.kt
│ │ │ │ │ └── LocationsScreen.kt
│ │ │ │ ├── episodes
│ │ │ │ │ ├── EpisodesDataSource.kt
│ │ │ │ │ └── EpisodesScreen.kt
│ │ │ │ ├── characters
│ │ │ │ │ ├── CharactersDataSource.kt
│ │ │ │ │ └── CharactersScreen.kt
│ │ │ │ └── common
│ │ │ │ │ └── ReusableCompose.kt
│ │ │ │ ├── utils
│ │ │ │ ├── Exts.kt
│ │ │ │ ├── Resource.kt
│ │ │ │ ├── LogMessage.kt
│ │ │ │ └── Utils.kt
│ │ │ │ ├── di
│ │ │ │ ├── ApiModule.kt
│ │ │ │ └── AppModule.kt
│ │ │ │ ├── MainRepository.kt
│ │ │ │ ├── remote
│ │ │ │ ├── ApiHelper.kt
│ │ │ │ └── ApiHelperImpl.kt
│ │ │ │ ├── MainViewModel.kt
│ │ │ │ ├── models
│ │ │ │ └── DataMappers.kt
│ │ │ │ ├── navigation
│ │ │ │ ├── Screens.kt
│ │ │ │ └── Navigation.kt
│ │ │ │ └── MainActivity.kt
│ │ ├── AndroidManifest.xml
│ │ └── graphql
│ │ │ ├── AllCharactersQuery.graphql
│ │ │ └── schema.json
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── gowtham
│ │ │ └── ricknmorty
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── gowtham
│ │ └── ricknmorty
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle.kts
├── arts
├── banner.jpg
├── dark_1.jpg
├── dark_2.jpg
├── light_1.jpg
└── light_2.jpg
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── codeStyles
│ ├── codeStyleConfig.xml
│ └── Project.xml
├── vcs.xml
├── compiler.xml
├── gradle.xml
├── inspectionProfiles
│ └── Project_Default.xml
└── misc.xml
├── config
├── detekt-baseline.xml
└── detekt-config.yml
├── settings.gradle.kts
├── .github
├── ci-gradle.properties
└── workflows
│ └── android.yaml
├── .gitignore
├── gradle.properties
├── README.md
├── gradlew.bat
├── gradlew
└── LICENSE
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/arts/banner.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/arts/banner.jpg
--------------------------------------------------------------------------------
/arts/dark_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/arts/dark_1.jpg
--------------------------------------------------------------------------------
/arts/dark_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/arts/dark_2.jpg
--------------------------------------------------------------------------------
/arts/light_1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/arts/light_1.jpg
--------------------------------------------------------------------------------
/arts/light_2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/arts/light_2.jpg
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RickNMorty App
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-playstore.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/ic_launcher-playstore.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/outline_south_america.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/drawable-hdpi/outline_south_america.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/outline_south_america.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/drawable-mdpi/outline_south_america.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/outline_south_america.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/drawable-xhdpi/outline_south_america.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/outline_south_america.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/drawable-xxhdpi/outline_south_america.png
--------------------------------------------------------------------------------
/app/src/main/res/values/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3DDC84
4 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/outline_south_america.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a914-gowtham/RickNMortyCompose/HEAD/app/src/main/res/drawable-xxxhdpi/outline_south_america.png
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/MApplication.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class MApplication : Application()
8 |
--------------------------------------------------------------------------------
/config/detekt-baseline.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | LargeClass:UnusedPrivateMemberSpec.kt$UnusedPrivateMemberSpec$UnusedPrivateMemberSpec
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jun 29 00:27:12 IST 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/theme/Color.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.theme
2 |
3 | import androidx.compose.ui.graphics.Color
4 |
5 | val Purple200 = Color(0xFFBB86FC)
6 | val Purple500 = Color(0xFF6200EE)
7 | val Purple700 = Color(0xFF3700B3)
8 | val Teal200 = Color(0xFF03DAC5)
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/utils/Exts.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.utils
2 |
3 | fun String.formatToDate(): String {
4 | val startIndex = 0
5 | val endIndex = 3
6 | return this.substring(
7 | startIndex,
8 | endIndex
9 | ) + " " + this.substring(this.indexOfFirst { it.isDigit() })
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/utils/Resource.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.utils
2 |
3 | sealed class Resource(val data: T? = null, val message: String? = null) {
4 | class Success(data: T) : Resource(data)
5 | class Error(message: String, data: T? = null) : Resource(data, message)
6 | class Loading : Resource()
7 | }
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_back.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp)
11 | )
12 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | import java.net.URI
2 |
3 | dependencyResolutionManagement {
4 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
5 | repositories {
6 | google()
7 | mavenCentral()
8 | maven { url = URI("https://jitpack.io") }
9 | jcenter() // Warning: this repository is going to shut down soon
10 | }
11 | }
12 | rootProject.name = "RickNMortyCompose"
13 | include(":app")
14 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/gowtham/ricknmorty/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty
2 |
3 | import org.junit.Assert.assertEquals
4 | import org.junit.Test
5 |
6 | /**
7 | * Example local unit test, which will execute on the development machine (host).
8 | *
9 | * See [testing documentation](http://d.android.com/tools/testing).
10 | */
11 | class ExampleUnitTest {
12 | @Test
13 | fun addition_isCorrect() {
14 | assertEquals(4, 2 + 2)
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/utils/LogMessage.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.utils
2 |
3 | import android.util.Log
4 | import com.gowtham.ricknmorty.BuildConfig.DEBUG
5 |
6 | object LogMessage {
7 |
8 | private val logVisible = DEBUG
9 |
10 | internal fun v(msg: String) {
11 | if (logVisible) Log.v("RickNMortyApp:: ", msg)
12 | }
13 |
14 | internal fun e(msg: String) {
15 | if (logVisible) Log.e("RickNMortyApp:: ", msg)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/di/ApiModule.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.di
2 |
3 | import com.gowtham.ricknmorty.remote.ApiHelper
4 | import com.gowtham.ricknmorty.remote.ApiHelperImpl
5 | import dagger.Binds
6 | import dagger.Module
7 | import dagger.hilt.InstallIn
8 | import dagger.hilt.components.SingletonComponent
9 |
10 | @Module
11 | @InstallIn(SingletonComponent::class)
12 | abstract class ApiModule {
13 |
14 | @Binds
15 | abstract fun bindAnalyticsService(
16 | analyticsServiceImpl: ApiHelperImpl
17 | ): ApiHelper
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_baseline_more_vert_24.xml:
--------------------------------------------------------------------------------
1 |
7 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_bulb.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/MainRepository.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty
2 |
3 | import com.gowtham.ricknmorty.remote.ApiHelper
4 | import javax.inject.Inject
5 |
6 | class MainRepository @Inject constructor(
7 | private val apiHelper: ApiHelper // injects by hilt
8 | ) {
9 |
10 | fun getCharacterFlow() = apiHelper.getCharacters()
11 |
12 | fun getEpisodeFlow() = apiHelper.getEpisodes()
13 |
14 | fun getLocationFlow() = apiHelper.getLocations()
15 |
16 | suspend fun getCharacter(characterId: String) = apiHelper.getCharacter(characterId)
17 |
18 | suspend fun getEpisode(episodeId: String) = apiHelper.getEpisode(episodeId)
19 |
20 | suspend fun getLocation(locationId: String) = apiHelper.getLocation(locationId)
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/remote/ApiHelper.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.remote
2 |
3 | import androidx.paging.PagingData
4 | import com.gowtham.ricknmorty.utils.Resource
5 | import fragment.CharacterDetail
6 | import fragment.EpisodeDetail
7 | import fragment.LocationDetail
8 | import kotlinx.coroutines.flow.Flow
9 |
10 | interface ApiHelper {
11 |
12 | fun getCharacters(): Flow>
13 |
14 | fun getEpisodes(): Flow>
15 |
16 | fun getLocations(): Flow>
17 |
18 | suspend fun getCharacter(characterId: String): Resource
19 |
20 | suspend fun getEpisode(episodeId: String): Resource
21 |
22 | suspend fun getLocation(locationId: String): Resource
23 | }
24 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/gowtham/ricknmorty/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty
2 |
3 | import androidx.test.ext.junit.runners.AndroidJUnit4
4 | import androidx.test.platform.app.InstrumentationRegistry
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | /**
10 | * Instrumented test, which will execute on an Android device.
11 | *
12 | * See [testing documentation](http://d.android.com/tools/testing).
13 | */
14 | @RunWith(AndroidJUnit4::class)
15 | class ExampleInstrumentedTest {
16 | @Test
17 | fun useAppContext() {
18 | // Context of the app under test.
19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
20 | assertEquals("com.compose.template", appContext.packageName)
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/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
--------------------------------------------------------------------------------
/.github/ci-gradle.properties:
--------------------------------------------------------------------------------
1 |
2 | #
3 | # Copyright 2020 The Android Open Source Project
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 | #
17 |
18 | org.gradle.daemon=false
19 | org.gradle.parallel=true
20 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
21 | org.gradle.workers.max=2
22 | kotlin.incremental=false
23 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
11 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.theme
2 |
3 | import androidx.compose.material.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | body1 = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp
15 | ),
16 | button = TextStyle(
17 | fontFamily = FontFamily.Default,
18 | fontWeight = FontWeight.W500,
19 | fontSize = 14.sp
20 | ),
21 | caption = TextStyle(
22 | fontFamily = FontFamily.Default,
23 | fontWeight = FontWeight.Normal,
24 | fontSize = 12.sp
25 | )
26 | )
27 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | /.idea
18 | .gradle/
19 | build/
20 | /build
21 | # Local configuration file (sdk path, etc)
22 | local.properties
23 |
24 | # Proguard folder generated by Eclipse
25 | proguard/
26 |
27 | # Log Files
28 | *.log
29 |
30 | # Android Studio Navigation editor temp files
31 | .navigation/
32 |
33 | # Android Studio captures folder
34 | captures/
35 |
36 | # Intellij
37 | *.iml
38 | .idea/workspace.xml
39 | .idea/tasks.xml
40 | .idea/gradle.xml
41 | .idea/dictionaries
42 | .idea/libraries
43 |
44 | # Keystore files
45 | *.jks
46 |
47 | # External native build folder generated in Android Studio 2.2 and later
48 | .externalNativeBuild
49 |
50 | # Google Services (e.g. APIs or Firebase)
51 | google-services.json
52 |
53 | # Freeline
54 | freeline.py
55 | freeline/
56 | freeline_project_description.json
57 |
58 | #signing
59 | /signing
60 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_dog.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
16 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/episode/EpisodeViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.episode
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import com.gowtham.ricknmorty.MainRepository
6 | import com.gowtham.ricknmorty.utils.Resource
7 | import dagger.hilt.android.lifecycle.HiltViewModel
8 | import fragment.EpisodeDetail
9 | import kotlinx.coroutines.flow.MutableStateFlow
10 | import kotlinx.coroutines.flow.StateFlow
11 | import kotlinx.coroutines.launch
12 | import javax.inject.Inject
13 |
14 | @HiltViewModel
15 | class EpisodeViewModel @Inject constructor(
16 | private val mainRepository: MainRepository
17 | ) : ViewModel() {
18 |
19 | private val _episodeDetail = MutableStateFlow>(Resource.Loading())
20 | val state: StateFlow>
21 | get() = _episodeDetail
22 |
23 | fun setEpisodeId(episodeId: String) {
24 | if (_episodeDetail.value is Resource.Success)
25 | return
26 | _episodeDetail.value = Resource.Loading()
27 | viewModelScope.launch {
28 | _episodeDetail.value = mainRepository.getEpisode(episodeId)
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/location/LocationViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.location
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import com.gowtham.ricknmorty.MainRepository
6 | import com.gowtham.ricknmorty.utils.Resource
7 | import dagger.hilt.android.lifecycle.HiltViewModel
8 | import fragment.LocationDetail
9 | import kotlinx.coroutines.flow.MutableStateFlow
10 | import kotlinx.coroutines.flow.StateFlow
11 | import kotlinx.coroutines.launch
12 | import javax.inject.Inject
13 |
14 | @HiltViewModel
15 | class LocationViewModel @Inject constructor(
16 | private val mainRepository: MainRepository
17 | ) : ViewModel() {
18 |
19 | private val _locationDetail = MutableStateFlow>(Resource.Loading())
20 | val state: StateFlow>
21 | get() = _locationDetail
22 |
23 | fun setLocation(locationId: String) {
24 | if (_locationDetail.value is Resource.Success)
25 | return
26 | _locationDetail.value = Resource.Loading()
27 | viewModelScope.launch {
28 | _locationDetail.value = mainRepository.getLocation(locationId)
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/MainViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import androidx.paging.cachedIn
6 | import dagger.hilt.android.lifecycle.HiltViewModel
7 | import kotlinx.coroutines.delay
8 | import kotlinx.coroutines.flow.MutableStateFlow
9 | import kotlinx.coroutines.flow.StateFlow
10 | import kotlinx.coroutines.launch
11 | import javax.inject.Inject
12 |
13 | @HiltViewModel
14 | class MainViewModel @Inject constructor(
15 | mainRepository: MainRepository
16 | ) :
17 | ViewModel() {
18 |
19 | companion object {
20 | const val DURATION = 2000L
21 | }
22 |
23 | private val _splashState = MutableStateFlow(true)
24 | val splash: StateFlow
25 | get() = _splashState
26 |
27 | init {
28 | viewModelScope.launch {
29 | delay(DURATION)
30 | _splashState.value = false
31 | }
32 | }
33 |
34 | val characters = mainRepository.getCharacterFlow().cachedIn(viewModelScope)
35 |
36 | val episodes = mainRepository.getEpisodeFlow().cachedIn(viewModelScope)
37 |
38 | val locations = mainRepository.getLocationFlow().cachedIn(viewModelScope)
39 | }
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/utils/Utils.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.utils
2 |
3 | import android.content.Context
4 | import android.net.ConnectivityManager
5 | import android.net.NetworkCapabilities.TRANSPORT_CELLULAR
6 | import android.net.NetworkCapabilities.TRANSPORT_ETHERNET
7 | import android.net.NetworkCapabilities.TRANSPORT_WIFI
8 | import androidx.navigation.NavBackStackEntry
9 |
10 | object Utils {
11 |
12 | fun isNetConnected(context: Context): Boolean {
13 | val connectivityManager = context.getSystemService(
14 | Context.CONNECTIVITY_SERVICE
15 | ) as ConnectivityManager
16 | val activeNetwork = connectivityManager.activeNetwork ?: return false
17 | val capabilities =
18 | connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
19 | return when {
20 | capabilities.hasTransport(TRANSPORT_WIFI) -> true
21 | capabilities.hasTransport(TRANSPORT_CELLULAR) -> true
22 | capabilities.hasTransport(TRANSPORT_ETHERNET) -> true
23 | else -> false
24 | }
25 | }
26 |
27 | fun getStringArg(key: String, entry: NavBackStackEntry) =
28 | entry.arguments?.getString(key).toString()
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/character/CharacterViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.character
2 |
3 | import androidx.lifecycle.ViewModel
4 | import androidx.lifecycle.viewModelScope
5 | import com.gowtham.ricknmorty.MainRepository
6 | import com.gowtham.ricknmorty.utils.Resource
7 | import dagger.hilt.android.lifecycle.HiltViewModel
8 | import fragment.CharacterDetail
9 | import kotlinx.coroutines.flow.MutableStateFlow
10 | import kotlinx.coroutines.flow.StateFlow
11 | import kotlinx.coroutines.launch
12 | import javax.inject.Inject
13 |
14 | @HiltViewModel
15 | class CharacterViewModel @Inject constructor(
16 | private val mainRepository: MainRepository
17 | ) : ViewModel() {
18 |
19 | private val _characterDetail = MutableStateFlow>(Resource.Loading())
20 | val state: StateFlow>
21 | get() = _characterDetail
22 |
23 | fun setCharacter(characterId: String) {
24 | if (_characterDetail.value is Resource.Success)
25 | return
26 | _characterDetail.value = Resource.Loading()
27 | viewModelScope.launch {
28 | _characterDetail.value = mainRepository.getCharacter(characterId)
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/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=-Xmx2048m -Dfile.encoding=UTF-8
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 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
--------------------------------------------------------------------------------
/.github/workflows/android.yaml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 |
8 | jobs:
9 | build:
10 | runs-on: macos-latest
11 | steps:
12 | - uses: actions/checkout@v1
13 | - name: set up JDK 11
14 | uses: actions/setup-java@v1
15 | with:
16 | java-version: 11
17 | - name: Build android app
18 | run: ./gradlew assembleDebug
19 |
20 | spotless-check:
21 | runs-on: macos-latest
22 | timeout-minutes: 20
23 |
24 | steps:
25 | - name: Checkout
26 | uses: actions/checkout@v2
27 |
28 | - name: Copy CI gradle.properties
29 | run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
30 |
31 | - name: Set up JDK 11
32 | uses: actions/setup-java@v1
33 | with:
34 | java-version: 11
35 |
36 | - name: Build project
37 | run: ./gradlew spotlessCheck
38 | detekt-check:
39 | runs-on: macos-latest
40 | timeout-minutes: 20
41 |
42 | steps:
43 | - name: Checkout
44 | uses: actions/checkout@v2
45 |
46 | - name: Set up JDK 11
47 | uses: actions/setup-java@v1
48 | with:
49 | java-version: 1.11
50 |
51 | - name: Build project
52 | run: ./gradlew detektAll
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.theme
2 |
3 | import androidx.compose.foundation.isSystemInDarkTheme
4 | import androidx.compose.material.MaterialTheme
5 | import androidx.compose.material.darkColors
6 | import androidx.compose.material.lightColors
7 | import androidx.compose.runtime.Composable
8 |
9 | private val DarkColorPalette = darkColors(
10 | primary = Purple200,
11 | primaryVariant = Purple700,
12 | secondary = Teal200
13 | )
14 |
15 | private val LightColorPalette = lightColors(
16 | primary = Purple500,
17 | primaryVariant = Purple700,
18 | secondary = Teal200
19 |
20 | /* Other default colors to override
21 | background = Color.White,
22 | surface = Color.White,
23 | onPrimary = Color.White,
24 | onSecondary = Color.Black,
25 | onBackground = Color.Black,
26 | onSurface = Color.Black,
27 | */
28 | )
29 |
30 | @Composable
31 | fun TAppTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable() () -> Unit) {
32 | val colors = if (darkTheme) {
33 | DarkColorPalette
34 | } else {
35 | LightColorPalette
36 | }
37 |
38 | MaterialTheme(
39 | colors = colors,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content
43 | )
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/models/DataMappers.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.models
2 |
3 | /*
4 | fun GetCharactersQuery.Characters.toDomain(): List {
5 |
6 | return results?.map {
7 | val character=it?.fragments!!.characterDetail
8 | character.toDomain()
9 | }
10 | ?: emptyList()
11 | }
12 |
13 | fun CharacterDetail.toDomain(): Character{
14 | return Character(id = id,
15 | gender = gender,
16 | origin = origin,
17 | location = location,
18 | episodes = episode,
19 | image = image,
20 | name = name,
21 | species = species,
22 | status = status,
23 | type = type)
24 | }
25 |
26 | fun GetLocationsQuery.Locations.toDomain(): List {
27 |
28 | return results?.map {
29 | val location=it?.fragments!!.locationDetail
30 | location.toDomain()
31 | }
32 | ?: emptyList()
33 | }
34 |
35 | fun LocationDetail.toDomain(): Location{
36 | return Location(id = id,
37 | name = name,
38 | type = type,
39 | dimension = dimension,
40 | residents = residents)
41 | }
42 |
43 | fun GetEpisodesQuery.Episodes.toDomain(): List {
44 |
45 | return results?.map {
46 | val episode=it?.fragments!!.episodeDetail
47 | episode.toDomain()
48 | }
49 | ?: emptyList()
50 | }
51 |
52 | fun EpisodeDetail.toDomain(): Episode{
53 | return Episode(id = id,
54 | name = name,
55 | airTime = air_date,
56 | episode = episode,
57 | characters = characters?.map { it } ?: emptyList())
58 | }*/
59 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/graphql/AllCharactersQuery.graphql:
--------------------------------------------------------------------------------
1 | query GetCharacters($page: Int) {
2 | characters(page: $page) {
3 | info {
4 | pages, count, next
5 | }
6 | results {
7 | ...CharacterDetail
8 | }
9 | }
10 | }
11 |
12 | query GetCharacter($id: ID!){
13 | character(id: $id) {
14 | ...CharacterDetail
15 | }
16 | }
17 |
18 | query GetEpisodes($page: Int){
19 | episodes(page: $page) {
20 | info {
21 | count, pages, next
22 | }
23 | results {
24 | ...EpisodeDetail
25 | }
26 | }
27 | }
28 |
29 | query GetEpisode($id: ID!) {
30 | episode(id: $id) {
31 | ...EpisodeDetail
32 | }
33 | }
34 |
35 | query GetLocations($page: Int) {
36 | locations(page: $page) {
37 | info {
38 | count, pages, next
39 | }
40 | results {
41 | ...LocationDetail
42 | }
43 | }
44 | }
45 |
46 | query GetLocation($id: ID!) {
47 | location(id: $id) {
48 | ...LocationDetail
49 | }
50 | }
51 |
52 |
53 | fragment CharacterDetail on Character {
54 | id, name, image, status, species, type, gender
55 | episode {
56 | id, name, air_date
57 | }
58 | location {
59 | id, name
60 | }
61 | origin {
62 | name
63 | }
64 | }
65 |
66 |
67 | fragment EpisodeDetail on Episode {
68 | id, name, created, air_date, episode
69 | characters {
70 | id, name, image
71 | }
72 | }
73 |
74 | fragment LocationDetail on Location {
75 | id, name, type, dimension,
76 | residents {
77 | id, name, image
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/navigation/Screens.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.navigation
2 |
3 | import androidx.compose.material.icons.Icons
4 | import androidx.compose.material.icons.filled.Map
5 | import androidx.compose.material.icons.filled.OndemandVideo
6 | import androidx.compose.material.icons.filled.Person
7 | import androidx.compose.ui.graphics.vector.ImageVector
8 |
9 | sealed class Screens(val route: String, val label: String, val icon: ImageVector? = null) {
10 | object CharactersScreen : Screens("Characters", "Characters", Icons.Default.Person)
11 | object EpisodesScreen : Screens("Episodes", "Episodes", Icons.Default.OndemandVideo)
12 | object LocationsScreen : Screens("Locations", "Locations", Icons.Default.Map)
13 | object CharacterDetailScreen : Screens("CharacterDetail", "CharacterDetail")
14 | object EpisodeDetailScreen : Screens("EpisodeDetail", "EpisodeDetail")
15 | object LocationDetailScreen : Screens("LocationDetail", "LocationDetail")
16 |
17 | fun withArgs(vararg args: String): String {
18 | return buildString {
19 | append(route)
20 | args.forEach {
21 | append("/$it")
22 | }
23 | }
24 | }
25 |
26 | fun withArgs(args: Map): String {
27 | return buildString {
28 | append(route)
29 | append("?")
30 | val iterator = args.iterator()
31 | while (iterator.hasNext()) {
32 | val map = iterator.next()
33 | append(map.key + "=" + map.value)
34 | if (iterator.hasNext())
35 | append("&")
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RickNMortyCompose
2 |
3 |
4 |
5 | 
6 |
7 | Update: implemented clean architecture in the clean_arch branch
8 |
9 | An android app to demo. Graphql + Jetpack compose + Hilt / Koin(koin branch).
10 | based on https://github.com/Dimillian/MortyUI SwiftUI project and https://github.com/joreilly/MortyComposeKMM Kotlin multiplatform mobile project
11 |
12 | ## 🛠 Built with
13 | * Jetpack compose
14 | * Apollo graphql
15 | * Accompanist
16 | * Paging compose
17 | * DI with Hilt/Koin
18 |
19 |
20 | ## 📱 Install
21 |
22 | [](https://github.com/a914-gowtham/RickNMortyCompose/releases/tag/v1.0.0)
23 |
24 | 
25 |
26 |
27 | ## License
28 | ```
29 | Licensed under the Apache License, Version 2.0 (the "License");
30 | you may not use this file except in compliance with the License.
31 | You may obtain a copy of the License at
32 |
33 | https://www.apache.org/licenses/LICENSE-2.0
34 |
35 | Unless required by applicable law or agreed to in writing, software
36 | distributed under the License is distributed on an "AS IS" BASIS,
37 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38 | See the License for the specific language governing permissions and
39 | limitations under the License.
40 | ```
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/di/AppModule.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.di
2 |
3 | import android.content.Context
4 | import com.apollographql.apollo.ApolloClient
5 | import com.gowtham.ricknmorty.BuildConfig
6 | import com.gowtham.ricknmorty.remote.ApiHelperImpl
7 | import dagger.Module
8 | import dagger.Provides
9 | import dagger.hilt.InstallIn
10 | import dagger.hilt.android.qualifiers.ApplicationContext
11 | import dagger.hilt.components.SingletonComponent
12 | import okhttp3.OkHttpClient
13 | import okhttp3.logging.HttpLoggingInterceptor
14 | import java.util.concurrent.TimeUnit
15 | import javax.inject.Singleton
16 |
17 | @Module
18 | @InstallIn(SingletonComponent::class)
19 | object AppModule {
20 |
21 | private const val BASE_URL = "https://rickandmortyapi.com/graphql/"
22 | private const val TIMEOUT = 60L
23 |
24 | @Singleton
25 | @Provides
26 | fun provideHttpClient(): OkHttpClient {
27 | val okHttp = OkHttpClient().newBuilder()
28 | .callTimeout(TIMEOUT, TimeUnit.SECONDS)
29 | .readTimeout(TIMEOUT, TimeUnit.SECONDS)
30 | .connectTimeout(TIMEOUT, TimeUnit.SECONDS)
31 | .retryOnConnectionFailure(true)
32 |
33 | if (BuildConfig.DEBUG) {
34 | okHttp.addInterceptor(
35 | HttpLoggingInterceptor().apply {
36 | level = HttpLoggingInterceptor.Level.BODY
37 | }
38 | )
39 | }
40 | return okHttp.build()
41 | }
42 |
43 | @Singleton
44 | @Provides
45 | fun provideApolloClient(okHttpClient: OkHttpClient): ApolloClient {
46 | return ApolloClient.builder()
47 | .okHttpClient(okHttpClient)
48 | .serverUrl(BASE_URL)
49 | .build()
50 | }
51 |
52 | @Singleton
53 | @Provides
54 | fun provideApiHelper(
55 | apollo: ApolloClient,
56 | @ApplicationContext context: Context
57 | ): ApiHelperImpl {
58 | return ApiHelperImpl(
59 | appContext = context,
60 | apolloClient = apollo
61 | )
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/locations/LocationsDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.locations
2 |
3 | import GetLocationsQuery
4 | import android.content.Context
5 | import androidx.paging.PagingSource
6 | import androidx.paging.PagingState
7 | import com.apollographql.apollo.ApolloClient
8 | import com.apollographql.apollo.api.Input
9 | import com.apollographql.apollo.coroutines.await
10 | import com.gowtham.ricknmorty.utils.Utils
11 | import fragment.LocationDetail
12 |
13 | private const val START_OFFSET = 0
14 |
15 | class LocationsDataSource(
16 | private val context: Context,
17 | private val apollo: ApolloClient
18 | ) :
19 | PagingSource() {
20 |
21 | override suspend fun load(params: LoadParams): LoadResult {
22 | val pageNumber = params.key ?: START_OFFSET
23 |
24 | if (!Utils.isNetConnected(context)) {
25 | return LoadResult.Error(Throwable(message = "No internet connected"))
26 | }
27 |
28 | return try {
29 | val locationsResponse =
30 | apollo.query(GetLocationsQuery(page = Input.optional(pageNumber))).await()
31 | val locationData = locationsResponse.data?.locations
32 | if (locationsResponse.errors != null) {
33 | LoadResult.Error(Throwable(message = "${locationsResponse.errors?.first()}"))
34 | } else {
35 | val locations =
36 | locationData?.results?.filterNotNull()?.map { it.fragments.locationDetail }
37 | val prevKey = if (pageNumber > START_OFFSET) pageNumber - 1 else null
38 | val nextKey = locationData?.info?.next
39 | LoadResult.Page(
40 | data = locations ?: emptyList(),
41 | prevKey = prevKey,
42 | nextKey = nextKey
43 | )
44 | }
45 | } catch (e: Exception) {
46 | LoadResult.Error(Throwable(message = e.localizedMessage ?: "Unexpected error occurred"))
47 | }
48 | }
49 |
50 | override fun getRefreshKey(state: PagingState): Int? {
51 | return null
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/episodes/EpisodesDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.episodes
2 |
3 | import GetEpisodesQuery
4 | import android.content.Context
5 | import androidx.paging.PagingSource
6 | import androidx.paging.PagingState
7 | import com.apollographql.apollo.ApolloClient
8 | import com.apollographql.apollo.api.Input
9 | import com.apollographql.apollo.coroutines.await
10 | import com.gowtham.ricknmorty.utils.Utils
11 | import fragment.EpisodeDetail
12 |
13 | private const val START_OFFSET = 0
14 |
15 | class EpisodesDataSource(
16 | private val context: Context,
17 | private val apollo: ApolloClient
18 | ) :
19 | PagingSource() {
20 |
21 | override suspend fun load(params: LoadParams): LoadResult {
22 | val pageNumber = params.key ?: START_OFFSET
23 |
24 | if (!Utils.isNetConnected(context)) {
25 | return LoadResult.Error(Throwable(message = "No internet connected"))
26 | }
27 |
28 | return try {
29 | val episodesResponse =
30 | apollo.query(GetEpisodesQuery(page = Input.optional(pageNumber))).await()
31 | val episodeData = episodesResponse.data?.episodes
32 | if (episodesResponse.errors != null) {
33 | LoadResult.Error(Throwable(message = "${episodesResponse.errors?.first()}"))
34 | } else {
35 | val episodes =
36 | episodeData?.results?.filterNotNull()?.map { it.fragments.episodeDetail }
37 | // val prevKey = if (pageNumber == START_OFFSET) null else pageNumber - 1
38 | val prevKey = if (pageNumber > START_OFFSET) pageNumber - 1 else null
39 | val nextKey = episodeData?.info?.next
40 | LoadResult.Page(
41 | data = episodes ?: emptyList(),
42 | prevKey = prevKey,
43 | nextKey = nextKey
44 | )
45 | }
46 | } catch (e: Exception) {
47 | LoadResult.Error(Throwable(message = e.localizedMessage ?: "Unexpected error occurred"))
48 | }
49 | }
50 |
51 | override fun getRefreshKey(state: PagingState): Int? {
52 | return null
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/characters/CharactersDataSource.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.characters
2 |
3 | import GetCharactersQuery
4 | import android.content.Context
5 | import androidx.paging.PagingSource
6 | import androidx.paging.PagingState
7 | import com.apollographql.apollo.ApolloClient
8 | import com.apollographql.apollo.api.Input
9 | import com.apollographql.apollo.coroutines.await
10 | import com.gowtham.ricknmorty.utils.Utils
11 | import fragment.CharacterDetail
12 |
13 | private const val START_OFFSET = 0
14 |
15 | class CharactersDataSource(
16 | private val context: Context,
17 | private val apollo: ApolloClient
18 | ) :
19 | PagingSource() {
20 |
21 | override suspend fun load(params: LoadParams): LoadResult {
22 | val pageNumber = params.key ?: START_OFFSET
23 |
24 | if (!Utils.isNetConnected(context)) {
25 | return LoadResult.Error(Throwable(message = "No internet connected"))
26 | }
27 |
28 | return try {
29 | val charactersResponse =
30 | apollo.query(GetCharactersQuery(page = Input.optional(pageNumber))).await()
31 | val characterData = charactersResponse.data?.characters
32 | if (charactersResponse.errors != null) {
33 | LoadResult.Error(Throwable(message = "${charactersResponse.errors?.first()}"))
34 | } else {
35 | val characters =
36 | characterData?.results?.filterNotNull()?.map { it.fragments.characterDetail }
37 | // val prevKey = if (pageNumber == START_OFFSET) null else pageNumber - 1
38 | val prevKey = if (pageNumber > START_OFFSET) pageNumber - 1 else null
39 | val nextKey = characterData?.info?.next
40 | LoadResult.Page(
41 | data = characters ?: emptyList(),
42 | prevKey = prevKey,
43 | nextKey = nextKey
44 | )
45 | }
46 | } catch (e: Exception) {
47 | LoadResult.Error(Throwable(message = e.localizedMessage ?: "Unexpected error occurred"))
48 | }
49 | }
50 |
51 | override fun getRefreshKey(state: PagingState): Int? {
52 | return null
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/common/ReusableCompose.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.common
2 |
3 | import androidx.compose.foundation.background
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Column
6 | import androidx.compose.foundation.layout.Row
7 | import androidx.compose.foundation.layout.Spacer
8 | import androidx.compose.foundation.layout.fillMaxSize
9 | import androidx.compose.foundation.layout.fillMaxWidth
10 | import androidx.compose.foundation.layout.height
11 | import androidx.compose.foundation.layout.padding
12 | import androidx.compose.foundation.layout.size
13 | import androidx.compose.foundation.layout.width
14 | import androidx.compose.material.Button
15 | import androidx.compose.material.Icon
16 | import androidx.compose.material.MaterialTheme
17 | import androidx.compose.material.Text
18 | import androidx.compose.runtime.Composable
19 | import androidx.compose.ui.Alignment
20 | import androidx.compose.ui.Modifier
21 | import androidx.compose.ui.graphics.Color
22 | import androidx.compose.ui.graphics.vector.ImageVector
23 | import androidx.compose.ui.text.style.TextAlign
24 | import androidx.compose.ui.unit.dp
25 |
26 | @Composable
27 | fun CharacterTitle(title: String) {
28 | val txtBgColor = if (MaterialTheme.colors.isLight) Color.LightGray else Color.Black
29 | Text(
30 | text = title, style = MaterialTheme.typography.subtitle1,
31 | modifier = Modifier
32 | .fillMaxWidth()
33 | .background(txtBgColor.copy(alpha = 0.6f))
34 | .padding(start = 12.dp, top = 18.dp, bottom = 8.dp),
35 | )
36 | }
37 |
38 | @Composable
39 | fun InfoRow(imageVector: ImageVector, title: String, subTitle: String) {
40 | Row(
41 | modifier = Modifier
42 | .fillMaxWidth()
43 | .padding(12.dp),
44 | verticalAlignment = Alignment.CenterVertically
45 | ) {
46 | Icon(
47 | imageVector, contentDescription = title,
48 | modifier = Modifier.size(26.dp),
49 | tint = MaterialTheme.colors.primary
50 | )
51 | Spacer(modifier = Modifier.width(10.dp))
52 | Text(
53 | text = title,
54 | style = MaterialTheme.typography.body1
55 | )
56 | Spacer(modifier = Modifier.width(40.dp))
57 | Text(
58 | text = subTitle,
59 | style = MaterialTheme.typography.body1,
60 | modifier = Modifier.weight(1f),
61 | textAlign = TextAlign.End
62 | )
63 | }
64 | }
65 |
66 | @Composable
67 | fun FailedComposable(errorMessage: String, retry: () -> Unit) {
68 | Column(
69 | modifier = Modifier.fillMaxSize(),
70 | verticalArrangement = Arrangement.Center,
71 | horizontalAlignment = Alignment.CenterHorizontally
72 | ) {
73 | Text(text = errorMessage, textAlign = TextAlign.Center)
74 | Spacer(modifier = Modifier.height(8.dp))
75 | Button(onClick = retry) {
76 | Text(text = "Retry")
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/remote/ApiHelperImpl.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.remote
2 |
3 | import GetCharacterQuery
4 | import GetEpisodeQuery
5 | import GetLocationQuery
6 | import android.content.Context
7 | import androidx.paging.Pager
8 | import androidx.paging.PagingConfig
9 | import com.apollographql.apollo.ApolloClient
10 | import com.apollographql.apollo.coroutines.await
11 | import com.gowtham.ricknmorty.compose.characters.CharactersDataSource
12 | import com.gowtham.ricknmorty.compose.episodes.EpisodesDataSource
13 | import com.gowtham.ricknmorty.compose.locations.LocationsDataSource
14 | import com.gowtham.ricknmorty.utils.Resource
15 | import com.gowtham.ricknmorty.utils.Utils
16 | import fragment.CharacterDetail
17 | import fragment.EpisodeDetail
18 | import fragment.LocationDetail
19 |
20 | class ApiHelperImpl(
21 | private val appContext: Context,
22 | private val apolloClient: ApolloClient
23 | ) : ApiHelper {
24 |
25 | override fun getCharacters() = Pager(PagingConfig(pageSize = 20)) {
26 | CharactersDataSource(context = appContext, apollo = apolloClient)
27 | }.flow
28 |
29 | override fun getEpisodes() = Pager(PagingConfig(pageSize = 20)) {
30 | EpisodesDataSource(context = appContext, apollo = apolloClient)
31 | }.flow
32 |
33 | override fun getLocations() = Pager(PagingConfig(pageSize = 20)) {
34 | LocationsDataSource(context = appContext, apollo = apolloClient)
35 | }.flow
36 |
37 | override suspend fun getCharacter(characterId: String): Resource {
38 | if (!Utils.isNetConnected(appContext))
39 | return Resource.Error("Internet is not connected")
40 | return try {
41 | val response = apolloClient.query(GetCharacterQuery(characterId)).await()
42 | response.data?.character?.fragments?.characterDetail?.let {
43 | Resource.Success(it)
44 | } ?: Resource.Error("Character detail is unavailable")
45 | } catch (ex: Exception) {
46 | print(ex)
47 | Resource.Error(ex.localizedMessage ?: "Unknown error occurred")
48 | }
49 | }
50 |
51 | override suspend fun getEpisode(episodeId: String): Resource {
52 | if (!Utils.isNetConnected(appContext))
53 | return Resource.Error("Internet is not connected")
54 | return try {
55 | val response = apolloClient.query(GetEpisodeQuery(episodeId)).await()
56 | response.data?.episode?.fragments?.episodeDetail?.let {
57 | Resource.Success(it)
58 | } ?: Resource.Error("Episode detail is unavailable")
59 | } catch (ex: Exception) {
60 | print(ex)
61 | Resource.Error(ex.localizedMessage ?: "Unknown error occurred")
62 | }
63 | }
64 |
65 | override suspend fun getLocation(locationId: String): Resource {
66 | if (!Utils.isNetConnected(appContext))
67 | return Resource.Error("Internet is not connected")
68 | return try {
69 | val response = apolloClient.query(GetLocationQuery(locationId)).await()
70 | response.data?.location?.fragments?.locationDetail?.let {
71 | Resource.Success(it)
72 | } ?: Resource.Error("Location detail is unavailable")
73 | } catch (ex: Exception) {
74 | print(ex)
75 | Resource.Error(ex.localizedMessage ?: "Unknown error occurred")
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id(Plugins.androidApplication)
3 | id(Plugins.kotlinAndroid)
4 | id(Plugins.kotlinKapt)
5 | id(Plugins.Apollo.plugin).version(Plugins.Apollo.version)
6 | id(Plugins.hilt)
7 | }
8 |
9 | android {
10 | compileSdk = Config.compileSdkVersion
11 | buildToolsVersion = Config.buildToolsVersion
12 | defaultConfig {
13 | applicationId = Config.applicationId
14 | minSdk = Config.minSdkVersion
15 | targetSdk = Config.targetSdkVersion
16 | versionCode = Config.versionCode
17 | versionName = Config.versionName
18 |
19 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
20 | vectorDrawables {
21 | useSupportLibrary = true
22 | }
23 | }
24 |
25 | buildTypes {
26 | release {
27 | isMinifyEnabled = false
28 | proguardFiles(
29 | getDefaultProguardFile("proguard-android-optimize.txt"),
30 | "proguard-rules.pro"
31 | )
32 | }
33 | }
34 | compileOptions {
35 | sourceCompatibility = JavaVersion.VERSION_11
36 | targetCompatibility = JavaVersion.VERSION_11
37 | }
38 | kotlinOptions {
39 | jvmTarget = "11"
40 | useIR = true
41 | }
42 | buildFeatures {
43 | compose = true
44 | // Disable unused AGP features
45 | aidl = false
46 | renderScript = false
47 | resValues = false
48 | shaders = false
49 | }
50 | composeOptions {
51 | kotlinCompilerExtensionVersion = Dependencies.Compose.version
52 | }
53 |
54 | packagingOptions {
55 | // Multiple dependency bring these files in. Exclude them to enable
56 | // our test APK to build (has no effect on our AARs)
57 | resources.excludes.add("/META-INF/AL2.0")
58 | resources.excludes.add("/META-INF/LGPL2.1")
59 | resources.excludes.add("META-INF/gradle/incremental.annotation.processors")
60 | }
61 | }
62 |
63 | dependencies {
64 |
65 | // Android
66 | implementation(Dependencies.Android.ktx)
67 | implementation(Dependencies.Android.appCompat)
68 | implementation(Dependencies.Android.material)
69 | implementation(Dependencies.Android.splashScreen)
70 |
71 | // Navigation
72 | implementation(Dependencies.Navigation.dependency)
73 | implementation(Dependencies.Navigation.hilt)
74 |
75 | // Compose
76 | implementation(Dependencies.Compose.ui)
77 | implementation(Dependencies.Compose.material)
78 | implementation(Dependencies.Compose.tooling)
79 | implementation(Dependencies.Compose.activity)
80 | implementation(Dependencies.Compose.paging)
81 | implementation(Dependencies.Compose.iconsExtended)
82 |
83 | // Lifecycle
84 | implementation(Dependencies.Lifecycle.runtime)
85 |
86 | // Hilt
87 | implementation(Dependencies.Hilt.dependency)
88 | kapt(Dependencies.Hilt.compiler)
89 |
90 | // Apollo graphql
91 | implementation(Dependencies.Apollo.runtime)
92 | implementation(Dependencies.Apollo.coroutine)
93 | implementation(Dependencies.OkHttp.bom)
94 | implementation(Dependencies.OkHttp.dependency)
95 | implementation(Dependencies.OkHttp.loggingInterceptor)
96 |
97 | // Accompanist
98 | implementation(Dependencies.Accompanist.coil)
99 | // Hilt
100 | implementation(Dependencies.Hilt.dependency)
101 | kapt(Dependencies.Hilt.compiler)
102 | // Testing
103 | testImplementation(Dependencies.Testing.junit)
104 | androidTestImplementation(Dependencies.Testing.junitAndroid)
105 | androidTestImplementation(Dependencies.Testing.espresso)
106 | androidTestImplementation(Dependencies.Testing.junitCompose)
107 | }
108 |
109 | apollo {
110 | // instruct the compiler to generate Kotlin models
111 | generateKotlinModels.set(true)
112 | }
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | xmlns:android
18 |
19 | ^$
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | xmlns:.*
29 |
30 | ^$
31 |
32 |
33 | BY_NAME
34 |
35 |
36 |
37 |
38 |
39 |
40 | .*:id
41 |
42 | http://schemas.android.com/apk/res/android
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | .*:name
52 |
53 | http://schemas.android.com/apk/res/android
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | name
63 |
64 | ^$
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | style
74 |
75 | ^$
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | .*
85 |
86 | ^$
87 |
88 |
89 | BY_NAME
90 |
91 |
92 |
93 |
94 |
95 |
96 | .*
97 |
98 | http://schemas.android.com/apk/res/android
99 |
100 |
101 | ANDROID_ATTRIBUTE_ORDER
102 |
103 |
104 |
105 |
106 |
107 |
108 | .*
109 |
110 | .*
111 |
112 |
113 | BY_NAME
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/config/detekt-config.yml:
--------------------------------------------------------------------------------
1 | build:
2 | maxIssues: 10
3 |
4 | comments:
5 | CommentOverPrivateProperty:
6 | active: true
7 | UndocumentedPublicClass:
8 | active: true
9 | excludes: [ '**/*.kt' ]
10 | includes: [ '**/detekt-api/src/main/**/api/*.kt' ]
11 | UndocumentedPublicFunction:
12 | active: true
13 | excludes: [ '**/*.kt' ]
14 | includes: [ '**/detekt-api/src/main/**/api/*.kt' ]
15 |
16 | complexity:
17 | StringLiteralDuplication:
18 | active: true
19 | excludes: [ '**/test/**', '**/*.Test.kt', '**/*.Spec.kt' ]
20 | threshold: 5
21 | ignoreAnnotation: true
22 | excludeStringsWithLessThan5Characters: true
23 | ignoreStringsRegex: '$^'
24 | ComplexInterface:
25 | active: true
26 | threshold: 30
27 | includeStaticDeclarations: false
28 | includePrivateDeclarations: false
29 | ComplexMethod:
30 | active: true
31 | ignoreSingleWhenExpression: true
32 | MethodOverloading:
33 | active: true
34 | TooManyFunctions:
35 | thresholdInFiles: 30
36 | thresholdInClasses: 30
37 | thresholdInInterfaces: 30
38 | ignorePrivate: true
39 |
40 | exceptions:
41 | NotImplementedDeclaration:
42 | active: true
43 | InstanceOfCheckForException:
44 | active: true
45 | RethrowCaughtException:
46 | active: true
47 | ReturnFromFinally:
48 | active: true
49 | SwallowedException:
50 | active: false
51 | ThrowingExceptionFromFinally:
52 | active: true
53 | ThrowingExceptionsWithoutMessageOrCause:
54 | active: true
55 | ThrowingNewInstanceOfSameException:
56 | active: true
57 | TooGenericExceptionCaught:
58 | active: false
59 |
60 | formatting:
61 | active: true
62 | android: false
63 | autoCorrect: true
64 | MaximumLineLength:
65 | active: false
66 | MultiLineIfElse:
67 | active: false
68 |
69 | naming:
70 | MemberNameEqualsClassName:
71 | active: true
72 | VariableNaming:
73 | active: true
74 | variablePattern: '[a-z][A-Za-z0-9]*'
75 | privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
76 | excludeClassPattern: '$^'
77 |
78 | performance:
79 | ArrayPrimitive:
80 | active: true
81 |
82 | potential-bugs:
83 | EqualsAlwaysReturnsTrueOrFalse:
84 | active: true
85 | InvalidRange:
86 | active: true
87 | IteratorHasNextCallsNextMethod:
88 | active: true
89 | IteratorNotThrowingNoSuchElementException:
90 | active: true
91 | MissingWhenCase:
92 | active: true
93 | RedundantElseInWhen:
94 | active: true
95 | UnsafeCallOnNullableType:
96 | active: true
97 | UnsafeCast:
98 | active: true
99 | excludes: [ '**/test/**', '**/*.Test.kt', '**/*.Spec.kt' ]
100 | UselessPostfixExpression:
101 | active: true
102 | WrongEqualsTypeParameter:
103 | active: true
104 |
105 | style:
106 | CollapsibleIfStatements:
107 | active: true
108 | EqualsNullCall:
109 | active: true
110 | ForbiddenComment:
111 | active: true
112 | values: [ 'TODO:', 'FIXME:', 'STOPSHIP:', '@author' ]
113 | FunctionOnlyReturningConstant:
114 | active: true
115 | LoopWithTooManyJumpStatements:
116 | active: true
117 | LibraryCodeMustSpecifyReturnType:
118 | active: true
119 | excludes: [ '**/*.kt' ]
120 | includes: [ '**/detekt-api/src/main/**/api/*.kt' ]
121 | MaxLineLength:
122 | excludes: [ '**/test/**', '**/*.Test.kt', '**/*.Spec.kt' ]
123 | excludeCommentStatements: true
124 | MagicNumber:
125 | ignoreHashCodeFunction: true
126 | ignorePropertyDeclaration: true
127 | ignoreLocalVariableDeclaration: true
128 | ignoreAnnotation: true
129 | ignoreEnums: true
130 | ignoreNumbers: [ '-1', '0', '1', '2', '100', '1000', '8080' ]
131 | MayBeConst:
132 | active: true
133 | ReturnCount:
134 | max: 4
135 | NestedClassesVisibility:
136 | active: true
137 | ProtectedMemberInFinalClass:
138 | active: true
139 | SpacingBetweenPackageAndImports:
140 | active: true
141 | UnnecessaryAbstractClass:
142 | active: true
143 | UnnecessaryInheritance:
144 | active: true
145 | UnusedPrivateClass:
146 | active: true
147 | UnusedPrivateMember:
148 | active: true
149 | allowedNames: '(_|ignored|expected)'
150 | UseCheckOrError:
151 | active: true
152 | UselessCallOnNotNull:
153 | active: true
154 | UtilityClassWithPublicConstructor:
155 | active: true
156 | NewLineAtEndOfFile:
157 | active: false
158 | WildcardImport:
159 | active: false
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.activity.viewModels
7 | import androidx.compose.material.BottomNavigation
8 | import androidx.compose.material.BottomNavigationItem
9 | import androidx.compose.material.Icon
10 | import androidx.compose.material.Text
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.runtime.getValue
13 | import androidx.compose.ui.tooling.preview.Preview
14 | import androidx.core.splashscreen.SplashScreen
15 | import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
16 | import androidx.navigation.NavHostController
17 | import androidx.navigation.compose.currentBackStackEntryAsState
18 | import androidx.navigation.compose.rememberNavController
19 | import com.gowtham.ricknmorty.compose.characters.CharactersScreen
20 | import com.gowtham.ricknmorty.compose.episodes.EpisodesScreen
21 | import com.gowtham.ricknmorty.compose.locations.LocationsScreen
22 | import com.gowtham.ricknmorty.compose.theme.TAppTheme
23 | import com.gowtham.ricknmorty.navigation.AppNavigation
24 | import com.gowtham.ricknmorty.navigation.Screens
25 | import dagger.hilt.android.AndroidEntryPoint
26 |
27 | @AndroidEntryPoint
28 | class MainActivity : ComponentActivity() {
29 |
30 | private val viewModel: MainViewModel by viewModels()
31 |
32 | private lateinit var splashScreen: SplashScreen
33 |
34 | companion object {
35 | const val CHARACTER_ID = "character_id"
36 | const val EPISODE_ID = "episode_id"
37 | const val LOCATION_ID = "location_id"
38 | const val CHARACTER_NAME = "character_name"
39 | const val EPISODE_NAME = "episode_name"
40 | const val LOCATION_NAME = "location_name"
41 | }
42 |
43 | override fun onCreate(savedInstanceState: Bundle?) {
44 | super.onCreate(savedInstanceState)
45 | splashScreen = installSplashScreen()
46 | setContent {
47 | AppContent {
48 | splashScreen.setKeepVisibleCondition(it)
49 | }
50 | }
51 | }
52 |
53 | @Composable
54 | fun AppContent(splashScreenVisibleCondition: (SplashScreen.KeepOnScreenCondition) -> Unit) {
55 | TAppTheme {
56 | RickNMortyApp(splashScreenVisibleCondition, viewModel)
57 | }
58 | }
59 | }
60 |
61 | @Composable
62 | fun RickNMortyApp(
63 | splashScreenVisibleCondition: (SplashScreen.KeepOnScreenCondition) -> Unit,
64 | viewModel: MainViewModel
65 | ) {
66 | splashScreenVisibleCondition {
67 | viewModel.splash.value
68 | }
69 | val navController = rememberNavController()
70 | val bottomNavigationItems =
71 | listOf(Screens.CharactersScreen, Screens.EpisodesScreen, Screens.LocationsScreen)
72 | val bottomBar: @Composable () -> Unit =
73 | { MortyBottomNavigation(navController, bottomNavigationItems) }
74 | AppNavigation(viewModel, navController, bottomBar,)
75 | }
76 |
77 | @Composable
78 | fun MortyBottomNavigation(navController: NavHostController, items: List) {
79 | BottomNavigation {
80 | val currentRoute = currentRoute(navController = navController)
81 | items.forEach { screen ->
82 | BottomNavigationItem(
83 | selected = currentRoute == screen.route,
84 | onClick = {
85 | if (currentRoute != screen.route) {
86 | navController.navigate(screen.route) {
87 | popUpTo(navController.graph.startDestinationId)
88 | launchSingleTop = true
89 | }
90 | }
91 | },
92 | icon = {
93 | screen.icon?.let {
94 | Icon(
95 | screen.icon,
96 | contentDescription = screen.label
97 | )
98 | }
99 | },
100 | label = { Text(screen.label) },
101 | )
102 | }
103 | }
104 | }
105 |
106 | @Composable
107 | private fun currentRoute(navController: NavHostController): String? {
108 | val navBackStackEntry by navController.currentBackStackEntryAsState()
109 | return navBackStackEntry?.destination?.route
110 | }
111 |
112 | @Composable
113 | fun Greeting(name: String) {
114 | Text(text = "Hello $name!")
115 | }
116 |
117 | @Preview(showBackground = true)
118 | @Composable
119 | fun DefaultPreview() {
120 | TAppTheme {
121 | Greeting("Android")
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/locations/LocationsScreen.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.locations
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.Spacer
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.layout.fillMaxWidth
8 | import androidx.compose.foundation.layout.padding
9 | import androidx.compose.foundation.layout.requiredHeight
10 | import androidx.compose.foundation.layout.size
11 | import androidx.compose.foundation.layout.wrapContentHeight
12 | import androidx.compose.foundation.layout.wrapContentSize
13 | import androidx.compose.foundation.layout.wrapContentWidth
14 | import androidx.compose.foundation.lazy.LazyColumn
15 | import androidx.compose.material.CircularProgressIndicator
16 | import androidx.compose.material.ContentAlpha
17 | import androidx.compose.material.Divider
18 | import androidx.compose.material.LocalContentAlpha
19 | import androidx.compose.material.MaterialTheme
20 | import androidx.compose.material.Scaffold
21 | import androidx.compose.material.Text
22 | import androidx.compose.material.TopAppBar
23 | import androidx.compose.runtime.Composable
24 | import androidx.compose.runtime.CompositionLocalProvider
25 | import androidx.compose.ui.Alignment
26 | import androidx.compose.ui.Modifier
27 | import androidx.compose.ui.text.style.TextOverflow
28 | import androidx.compose.ui.unit.dp
29 | import androidx.paging.LoadState
30 | import androidx.paging.compose.collectAsLazyPagingItems
31 | import androidx.paging.compose.items
32 | import com.gowtham.ricknmorty.MainViewModel
33 | import com.gowtham.ricknmorty.compose.characters.ErrorView
34 | import fragment.LocationDetail
35 |
36 | @Composable
37 | fun LocationsScreen(
38 | viewModel: MainViewModel,
39 | bottomBar: @Composable () -> Unit,
40 | onItemClickListener: (character: LocationDetail) -> Unit
41 | ) {
42 | val lazyLocationList = viewModel.locations.collectAsLazyPagingItems()
43 |
44 | Scaffold(
45 | topBar = { TopAppBar(title = { Text("Locations") }) },
46 | bottomBar = bottomBar,
47 | modifier = Modifier.fillMaxSize()
48 | ) {
49 | if (lazyLocationList.loadState.refresh is LoadState.Loading) {
50 | CircularProgressIndicator(
51 | modifier = Modifier
52 | .fillMaxSize()
53 | .padding(12.dp)
54 | .size(35.dp)
55 | .wrapContentSize(Alignment.Center),
56 | strokeWidth = 5.dp
57 | )
58 | }
59 | LazyColumn(contentPadding = it) {
60 | items(lazyLocationList) { location ->
61 | location?.let {
62 | LocationRow(location, onItemClickListener)
63 | }
64 | }
65 | if (lazyLocationList.loadState.append is LoadState.Loading) {
66 | item {
67 | CircularProgressIndicator(
68 | modifier = Modifier
69 | .fillMaxWidth()
70 | .requiredHeight(80.dp)
71 | .padding(16.dp)
72 | .wrapContentHeight()
73 | .wrapContentWidth(Alignment.CenterHorizontally),
74 | strokeWidth = 4.5.dp
75 | )
76 | }
77 | }
78 | if (lazyLocationList.loadState.append is LoadState.Error) {
79 | val state = lazyLocationList.loadState.append as LoadState.Error
80 | val errorMessage = state.error.localizedMessage ?: "unknown error occurred"
81 | item {
82 | ErrorView(errorMessage) {
83 | lazyLocationList.retry()
84 | }
85 | }
86 | }
87 | }
88 | if (lazyLocationList.loadState.refresh is LoadState.Error) {
89 | val state = lazyLocationList.loadState.refresh as LoadState.Error
90 | val errorMessage = state.error.localizedMessage ?: "unknown error occurred"
91 | ErrorView(errorMessage) {
92 | lazyLocationList.retry()
93 | }
94 | }
95 | }
96 | }
97 |
98 | @Composable
99 | fun LocationRow(
100 | location: LocationDetail,
101 | onItemClickListener: (character: LocationDetail) -> Unit
102 | ) {
103 | Column(
104 | modifier = Modifier
105 | .fillMaxWidth()
106 | .clickable { onItemClickListener(location) }
107 | .padding(start = 12.dp, end = 12.dp, top = 12.dp)
108 | ) {
109 | Text(
110 | text = location.name ?: "Location name unavailable",
111 | style = MaterialTheme.typography.h6,
112 | maxLines = 1, overflow = TextOverflow.Ellipsis
113 | )
114 | CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
115 | Text(
116 | text = "${location.residents.size} resident(s)",
117 | style = MaterialTheme.typography.body2
118 | )
119 | }
120 | Spacer(modifier = Modifier.size(12.dp))
121 | Divider()
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/episode/EpisodeDetailScreen.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.episode
2 |
3 | import androidx.compose.foundation.layout.Row
4 | import androidx.compose.foundation.layout.fillMaxSize
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.foundation.layout.size
8 | import androidx.compose.foundation.layout.wrapContentSize
9 | import androidx.compose.foundation.lazy.LazyColumn
10 | import androidx.compose.material.CircularProgressIndicator
11 | import androidx.compose.material.Divider
12 | import androidx.compose.material.Icon
13 | import androidx.compose.material.IconButton
14 | import androidx.compose.material.MaterialTheme
15 | import androidx.compose.material.Scaffold
16 | import androidx.compose.material.Surface
17 | import androidx.compose.material.Text
18 | import androidx.compose.material.TopAppBar
19 | import androidx.compose.material.icons.Icons
20 | import androidx.compose.material.icons.filled.ArrowBack
21 | import androidx.compose.material.icons.outlined.Info
22 | import androidx.compose.material.icons.outlined.Tag
23 | import androidx.compose.material.icons.outlined.Today
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.runtime.LaunchedEffect
26 | import androidx.compose.runtime.collectAsState
27 | import androidx.compose.runtime.rememberCoroutineScope
28 | import androidx.compose.ui.Alignment
29 | import androidx.compose.ui.Modifier
30 | import androidx.compose.ui.unit.dp
31 | import androidx.hilt.navigation.compose.hiltViewModel
32 | import com.gowtham.ricknmorty.compose.characters.CharacterAvatar
33 | import com.gowtham.ricknmorty.compose.common.CharacterTitle
34 | import com.gowtham.ricknmorty.compose.common.FailedComposable
35 | import com.gowtham.ricknmorty.compose.common.InfoRow
36 | import com.gowtham.ricknmorty.utils.Resource
37 | import fragment.EpisodeDetail
38 | import kotlinx.coroutines.launch
39 |
40 | @Composable
41 | fun EpisodeDetailScreen(
42 | episodeId: String,
43 | episodeName: String,
44 | viewModel: EpisodeViewModel = hiltViewModel(),
45 | popBack: () -> Unit
46 | ) {
47 |
48 | val coroutineScope = rememberCoroutineScope()
49 |
50 | val episodeState = viewModel.state.collectAsState()
51 |
52 | LaunchedEffect(episodeId) {
53 | viewModel.setEpisodeId(episodeId)
54 | }
55 |
56 | val retry: () -> Unit = {
57 | coroutineScope.launch {
58 | viewModel.setEpisodeId(episodeId)
59 | }
60 | }
61 |
62 | Scaffold(
63 | topBar = {
64 | TopAppBar(
65 | title = { Text(episodeName) },
66 | navigationIcon = {
67 | IconButton(onClick = { popBack() }) {
68 | Icon(Icons.Filled.ArrowBack, contentDescription = "Back")
69 | }
70 | }
71 | )
72 | }
73 | ) {
74 | when (episodeState.value) {
75 | is Resource.Success -> EpisodeDetail(episodeState.value.data)
76 | is Resource.Error -> FailedComposable(
77 | errorMessage = episodeState.value.message.toString(), retry = retry
78 | )
79 | else -> CircularProgressIndicator(
80 | modifier = Modifier
81 | .fillMaxSize()
82 | .padding(12.dp)
83 | .size(35.dp)
84 | .wrapContentSize(Alignment.Center)
85 | )
86 | }
87 | }
88 | }
89 |
90 | @Composable
91 | fun EpisodeDetail(episode: EpisodeDetail?) {
92 | val listInfoTitle = listOf("Name", "Air time", "Code")
93 | val listInfo = listOf(
94 | episode?.name.toString(),
95 | episode?.air_date.toString(),
96 | episode?.episode.toString(),
97 | )
98 | val listInfoIcon = listOf(
99 | Icons.Outlined.Info, Icons.Outlined.Today,
100 | Icons.Outlined.Tag
101 | )
102 |
103 | Surface {
104 | LazyColumn {
105 | episode?.let { episodeDetail ->
106 | item {
107 | CharacterTitle("INFO")
108 | }
109 | items(listInfoTitle.size) { index ->
110 | InfoRow(
111 | imageVector = listInfoIcon[index],
112 | title = listInfoTitle[index],
113 | subTitle = listInfo[index]
114 | )
115 | if (index != listInfoTitle.lastIndex)
116 | Divider()
117 | }
118 | item {
119 | CharacterTitle("CHARACTERS")
120 | }
121 | items(episodeDetail.characters.size) { index ->
122 | val character = episodeDetail.characters[index]
123 | character?.let {
124 | CharacterRow(character)
125 | if (index < episode.characters.lastIndex)
126 | Divider(modifier = Modifier.padding(horizontal = 12.dp))
127 | }
128 | }
129 | }
130 | }
131 | }
132 | }
133 |
134 | @Composable
135 | fun CharacterRow(character: EpisodeDetail.Character) {
136 | Row(
137 | modifier = Modifier
138 | .fillMaxWidth()
139 | .padding(12.dp),
140 | verticalAlignment = Alignment.CenterVertically
141 | ) {
142 | CharacterAvatar(
143 | name = character.name.toString(),
144 | url = character.image,
145 | size = 40.dp
146 | )
147 | Text(
148 | character.name.toString(),
149 | modifier = Modifier
150 | .weight(1f)
151 | .padding(start = 8.dp),
152 | style = MaterialTheme.typography.subtitle1,
153 | )
154 | }
155 | }
156 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/location/LocationDetailScreen.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.location
2 |
3 | import androidx.compose.foundation.layout.Row
4 | import androidx.compose.foundation.layout.fillMaxSize
5 | import androidx.compose.foundation.layout.fillMaxWidth
6 | import androidx.compose.foundation.layout.padding
7 | import androidx.compose.foundation.layout.size
8 | import androidx.compose.foundation.layout.wrapContentSize
9 | import androidx.compose.foundation.lazy.LazyColumn
10 | import androidx.compose.material.CircularProgressIndicator
11 | import androidx.compose.material.Divider
12 | import androidx.compose.material.Icon
13 | import androidx.compose.material.IconButton
14 | import androidx.compose.material.MaterialTheme
15 | import androidx.compose.material.Scaffold
16 | import androidx.compose.material.Surface
17 | import androidx.compose.material.Text
18 | import androidx.compose.material.TopAppBar
19 | import androidx.compose.material.icons.Icons
20 | import androidx.compose.material.icons.filled.ArrowBack
21 | import androidx.compose.material.icons.outlined.Info
22 | import androidx.compose.material.icons.outlined.Public
23 | import androidx.compose.material.icons.outlined.Stream
24 | import androidx.compose.runtime.Composable
25 | import androidx.compose.runtime.LaunchedEffect
26 | import androidx.compose.runtime.collectAsState
27 | import androidx.compose.runtime.rememberCoroutineScope
28 | import androidx.compose.ui.Alignment
29 | import androidx.compose.ui.Modifier
30 | import androidx.compose.ui.unit.dp
31 | import androidx.hilt.navigation.compose.hiltViewModel
32 | import com.gowtham.ricknmorty.compose.characters.CharacterAvatar
33 | import com.gowtham.ricknmorty.compose.common.CharacterTitle
34 | import com.gowtham.ricknmorty.compose.common.FailedComposable
35 | import com.gowtham.ricknmorty.compose.common.InfoRow
36 | import com.gowtham.ricknmorty.utils.Resource
37 | import fragment.LocationDetail
38 | import kotlinx.coroutines.launch
39 |
40 | @Composable
41 | fun LocationDetailScreen(
42 | locationId: String,
43 | locationName: String,
44 | viewModel: LocationViewModel = hiltViewModel(),
45 | popBack: () -> Unit
46 | ) {
47 |
48 | val coroutineScope = rememberCoroutineScope()
49 |
50 | val locationState = viewModel.state.collectAsState()
51 |
52 | LaunchedEffect(locationId) {
53 | viewModel.setLocation(locationId)
54 | }
55 |
56 | val retry: () -> Unit = {
57 | coroutineScope.launch {
58 | viewModel.setLocation(locationId)
59 | }
60 | }
61 |
62 | Scaffold(
63 | topBar = {
64 | TopAppBar(
65 | title = { Text(locationName) },
66 | navigationIcon = {
67 | IconButton(onClick = { popBack() }) {
68 | Icon(Icons.Filled.ArrowBack, contentDescription = "Back")
69 | }
70 | }
71 | )
72 | }
73 | ) {
74 | when (locationState.value) {
75 | is Resource.Success -> LocationDetail(locationState.value.data)
76 | is Resource.Error -> FailedComposable(
77 | errorMessage = locationState.value.message.toString(), retry = retry
78 | )
79 | else -> CircularProgressIndicator(
80 | modifier = Modifier
81 | .fillMaxSize()
82 | .padding(12.dp)
83 | .size(35.dp)
84 | .wrapContentSize(Alignment.Center)
85 | )
86 | }
87 | }
88 | }
89 |
90 | @Composable
91 | fun LocationDetail(location: LocationDetail?) {
92 | val listInfoTitle = listOf(
93 | "Name", "Type",
94 | "Dimension"
95 | )
96 | val listInfo = listOf(
97 | location?.name.toString(),
98 | location?.type.toString(),
99 | location?.dimension.toString(),
100 | )
101 | val listInfoIcon = listOf(
102 | Icons.Outlined.Info, Icons.Outlined.Public,
103 | Icons.Outlined.Stream
104 | )
105 |
106 | Surface {
107 | LazyColumn {
108 | location?.let { locationDetail ->
109 | item {
110 | CharacterTitle("INFO")
111 | }
112 | items(listInfoTitle.size) { index ->
113 | InfoRow(
114 | imageVector = listInfoIcon[index],
115 | title = listInfoTitle[index],
116 | subTitle = listInfo[index]
117 | )
118 | if (index != listInfoTitle.lastIndex)
119 | Divider()
120 | }
121 | item {
122 | CharacterTitle("RESIDENTS")
123 | }
124 | items(locationDetail.residents.size) { index ->
125 | val resident = locationDetail.residents[index]
126 | resident?.let {
127 | ResidentsRow(resident)
128 | if (index < locationDetail.residents.lastIndex)
129 | Divider(modifier = Modifier.padding(horizontal = 12.dp))
130 | }
131 | }
132 | }
133 | }
134 | }
135 | }
136 |
137 | @Composable
138 | fun ResidentsRow(resident: LocationDetail.Resident) {
139 | Row(
140 | modifier = Modifier
141 | .fillMaxWidth()
142 | .padding(12.dp),
143 | verticalAlignment = Alignment.CenterVertically
144 | ) {
145 | CharacterAvatar(
146 | name = resident.name.toString(),
147 | url = resident.image,
148 | size = 40.dp
149 | )
150 | Text(
151 | resident.name.toString(),
152 | modifier = Modifier
153 | .weight(1f)
154 | .padding(start = 8.dp),
155 | style = MaterialTheme.typography.subtitle1,
156 | )
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/episodes/EpisodesScreen.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.episodes
2 |
3 | import androidx.compose.foundation.clickable
4 | import androidx.compose.foundation.layout.Column
5 | import androidx.compose.foundation.layout.Row
6 | import androidx.compose.foundation.layout.fillMaxSize
7 | import androidx.compose.foundation.layout.fillMaxWidth
8 | import androidx.compose.foundation.layout.padding
9 | import androidx.compose.foundation.layout.requiredHeight
10 | import androidx.compose.foundation.layout.size
11 | import androidx.compose.foundation.layout.wrapContentHeight
12 | import androidx.compose.foundation.layout.wrapContentSize
13 | import androidx.compose.foundation.layout.wrapContentWidth
14 | import androidx.compose.foundation.lazy.LazyColumn
15 | import androidx.compose.material.CircularProgressIndicator
16 | import androidx.compose.material.ContentAlpha
17 | import androidx.compose.material.Divider
18 | import androidx.compose.material.LocalContentAlpha
19 | import androidx.compose.material.MaterialTheme
20 | import androidx.compose.material.Scaffold
21 | import androidx.compose.material.Text
22 | import androidx.compose.material.TopAppBar
23 | import androidx.compose.runtime.Composable
24 | import androidx.compose.runtime.CompositionLocalProvider
25 | import androidx.compose.ui.Alignment
26 | import androidx.compose.ui.Modifier
27 | import androidx.compose.ui.text.style.TextOverflow
28 | import androidx.compose.ui.unit.dp
29 | import androidx.paging.LoadState
30 | import androidx.paging.compose.collectAsLazyPagingItems
31 | import androidx.paging.compose.items
32 | import com.gowtham.ricknmorty.MainViewModel
33 | import com.gowtham.ricknmorty.compose.characters.ErrorView
34 | import com.gowtham.ricknmorty.utils.formatToDate
35 | import fragment.EpisodeDetail
36 |
37 | @Composable
38 | fun EpisodesScreen(
39 | viewModel: MainViewModel,
40 | bottomBar: @Composable () -> Unit,
41 | onItemClickListener: (character: EpisodeDetail) -> Unit
42 | ) {
43 | val lazyEpisodeList = viewModel.episodes.collectAsLazyPagingItems()
44 |
45 | Scaffold(
46 | topBar = { TopAppBar(title = { Text("Episodes") }) },
47 | bottomBar = bottomBar,
48 | modifier = Modifier.fillMaxSize()
49 | ) {
50 | if (lazyEpisodeList.loadState.refresh is LoadState.Loading) {
51 | CircularProgressIndicator(
52 | modifier = Modifier
53 | .fillMaxSize()
54 | .padding(12.dp)
55 | .size(35.dp)
56 | .wrapContentSize(Alignment.Center),
57 | strokeWidth = 5.dp
58 | )
59 | }
60 | LazyColumn(contentPadding = it) {
61 | items(lazyEpisodeList) { episode ->
62 | episode?.let {
63 | EpisodeRow(episode, onItemClickListener)
64 | }
65 | }
66 | if (lazyEpisodeList.loadState.append is LoadState.Loading) {
67 | item {
68 | CircularProgressIndicator(
69 | modifier = Modifier
70 | .fillMaxWidth()
71 | .requiredHeight(80.dp)
72 | .padding(16.dp)
73 | .wrapContentHeight()
74 | .wrapContentWidth(Alignment.CenterHorizontally),
75 | strokeWidth = 4.5.dp
76 | )
77 | }
78 | }
79 | if (lazyEpisodeList.loadState.append is LoadState.Error) {
80 | val state = lazyEpisodeList.loadState.append as LoadState.Error
81 | val errorMessage = state.error.localizedMessage ?: "unknown error occurred"
82 | item {
83 | ErrorView(errorMessage) {
84 | lazyEpisodeList.retry()
85 | }
86 | }
87 | }
88 | }
89 | if (lazyEpisodeList.loadState.refresh is LoadState.Error) {
90 | val state = lazyEpisodeList.loadState.refresh as LoadState.Error
91 | val errorMessage = state.error.localizedMessage ?: "unknown error occurred"
92 | ErrorView(errorMessage) {
93 | lazyEpisodeList.retry()
94 | }
95 | }
96 | }
97 | }
98 |
99 | @Composable
100 | fun EpisodeRow(episode: EpisodeDetail, onItemClickListener: (character: EpisodeDetail) -> Unit) {
101 | Column(modifier = Modifier.fillMaxWidth()) {
102 | Row(
103 | modifier = Modifier
104 | .fillMaxWidth()
105 | .clickable { onItemClickListener(episode) }
106 | .padding(12.dp),
107 | verticalAlignment = Alignment.CenterVertically
108 | ) {
109 | Column(
110 | Modifier
111 | .weight(1f, fill = true)
112 | .padding(
113 | end = 8.dp
114 | )
115 | ) {
116 | Text(
117 | text = episode.name ?: "Episode name unavailable",
118 | style = MaterialTheme.typography.h6,
119 | maxLines = 1, overflow = TextOverflow.Ellipsis
120 | )
121 | CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
122 | Text(
123 | text = episode.episode ?: "Code unavailable",
124 | style = MaterialTheme.typography.body2
125 | )
126 | }
127 | }
128 | Text(
129 | text = episode.air_date?.formatToDate() ?: "No airtime",
130 | style = MaterialTheme.typography.subtitle1
131 | )
132 | }
133 | Divider(modifier = Modifier.padding(horizontal = 6.dp))
134 | }
135 | }
136 |
137 | /*
138 | @Preview(showBackground = true)
139 | @Composable
140 | fun DefaultPreview() {
141 | }
142 | */
143 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/navigation/Navigation.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.navigation
2 |
3 | import androidx.compose.animation.EnterTransition
4 | import androidx.compose.animation.ExitTransition
5 | import androidx.compose.animation.ExperimentalAnimationApi
6 | import androidx.compose.animation.core.tween
7 | import androidx.compose.animation.fadeIn
8 | import androidx.compose.animation.fadeOut
9 | import androidx.compose.animation.slideInHorizontally
10 | import androidx.compose.animation.slideOutHorizontally
11 | import androidx.compose.runtime.Composable
12 | import androidx.navigation.NavBackStackEntry
13 | import androidx.navigation.NavHostController
14 | import androidx.navigation.compose.NavHost
15 | import androidx.navigation.compose.composable
16 | import androidx.navigation.compose.navArgument
17 | import com.gowtham.ricknmorty.MainActivity
18 | import com.gowtham.ricknmorty.MainViewModel
19 | import com.gowtham.ricknmorty.compose.character.CharacterDetailScreen
20 | import com.gowtham.ricknmorty.compose.characters.CharactersScreen
21 | import com.gowtham.ricknmorty.compose.episode.EpisodeDetailScreen
22 | import com.gowtham.ricknmorty.compose.episodes.EpisodesScreen
23 | import com.gowtham.ricknmorty.compose.location.LocationDetailScreen
24 | import com.gowtham.ricknmorty.compose.locations.LocationsScreen
25 | import com.gowtham.ricknmorty.utils.Utils
26 |
27 | @Composable
28 | fun AppNavigation(
29 | viewModel: MainViewModel,
30 | navController: NavHostController,
31 | bottomBar: @Composable () -> Unit
32 | ) {
33 |
34 | NavHost(
35 | navController = navController,
36 | startDestination = Screens.CharactersScreen.route
37 | ) {
38 |
39 | composable(
40 | Screens.CharactersScreen.route,
41 | ) {
42 | CharactersScreen(viewModel, bottomBar) { character ->
43 | navController.navigate(
44 | Screens.CharacterDetailScreen.withArgs(
45 | args = mapOf(
46 | MainActivity.CHARACTER_ID to character.id.toString(),
47 | MainActivity.CHARACTER_NAME to character.name.toString(),
48 | )
49 | )
50 | )
51 | }
52 | }
53 | composable(
54 | Screens.CharacterDetailScreen.route +
55 | "?${MainActivity.CHARACTER_ID}={id}&${MainActivity.CHARACTER_NAME}={name}",
56 | arguments = listOf(
57 | navArgument(MainActivity.CHARACTER_ID) { nullable = true },
58 | navArgument(MainActivity.CHARACTER_NAME) { nullable = true }
59 | ),
60 | ) {
61 | CharacterDetailScreen(
62 | characterName = Utils.getStringArg("name", it),
63 | characterId = Utils.getStringArg("id", it),
64 | ) {
65 | navController.popBackStack()
66 | }
67 | }
68 | composable(Screens.EpisodesScreen.route) {
69 | EpisodesScreen(viewModel, bottomBar) { episode ->
70 | navController.navigate(
71 | Screens.EpisodeDetailScreen.withArgs(
72 | args = mapOf(
73 | MainActivity.EPISODE_ID to episode.id.toString(),
74 | MainActivity.EPISODE_NAME to episode.name.toString(),
75 | )
76 | )
77 | )
78 | }
79 | }
80 | composable(
81 | Screens.EpisodeDetailScreen.route +
82 | "?${MainActivity.EPISODE_ID}={id}&${MainActivity.EPISODE_NAME}={name}",
83 | arguments = listOf(
84 | navArgument(MainActivity.EPISODE_ID) { nullable = true },
85 | navArgument(MainActivity.EPISODE_NAME) { nullable = true }
86 | )
87 | ) {
88 | EpisodeDetailScreen(
89 | episodeName = Utils.getStringArg("name", it),
90 | episodeId = Utils.getStringArg("id", it),
91 | ) {
92 | navController.popBackStack()
93 | }
94 | }
95 | composable(Screens.LocationsScreen.route) {
96 | LocationsScreen(viewModel, bottomBar) { location ->
97 | navController.navigate(
98 | Screens.LocationDetailScreen.withArgs(
99 | args = mapOf(
100 | MainActivity.LOCATION_ID to location.id.toString(),
101 | MainActivity.LOCATION_NAME to location.name.toString(),
102 | )
103 | )
104 | )
105 | }
106 | }
107 | composable(
108 | Screens.LocationDetailScreen.route +
109 | "?${MainActivity.LOCATION_ID}={id}&${MainActivity.LOCATION_NAME}={name}",
110 | arguments = listOf(
111 | navArgument(MainActivity.LOCATION_ID) { nullable = true },
112 | navArgument(MainActivity.LOCATION_NAME) { nullable = true }
113 | )
114 | ) {
115 | LocationDetailScreen(
116 | locationName = Utils.getStringArg("name", it),
117 | locationId = Utils.getStringArg("id", it),
118 | ) {
119 | navController.popBackStack()
120 | }
121 | }
122 | }
123 | }
124 |
125 | const val ANIMATION_DURATION = 300
126 | @ExperimentalAnimationApi
127 | fun enterTransition(desRoute: String, initial: NavBackStackEntry): EnterTransition? {
128 | return when (initial.destination.route) {
129 | desRoute ->
130 | slideInHorizontally(
131 | initialOffsetX = { ANIMATION_DURATION },
132 | animationSpec = tween(ANIMATION_DURATION)
133 | ) + fadeIn(animationSpec = tween(ANIMATION_DURATION))
134 | else -> null
135 | }
136 | }
137 |
138 | @ExperimentalAnimationApi
139 | fun exitTransition(desRoute: String, target: NavBackStackEntry): ExitTransition? {
140 | return when (target.destination.route) {
141 | desRoute ->
142 | slideOutHorizontally(
143 | targetOffsetX = { -ANIMATION_DURATION },
144 | animationSpec = tween(ANIMATION_DURATION)
145 | ) + fadeOut(animationSpec = tween(ANIMATION_DURATION))
146 | else -> null
147 | }
148 | }
149 |
150 | @ExperimentalAnimationApi
151 | fun popEnterTransition(desRoute: String, initial: NavBackStackEntry): EnterTransition? {
152 | return when (initial.destination.route) {
153 | desRoute ->
154 | slideInHorizontally(
155 | initialOffsetX = { -ANIMATION_DURATION },
156 | animationSpec = tween(ANIMATION_DURATION)
157 | ) + fadeIn(animationSpec = tween(ANIMATION_DURATION))
158 | else -> null
159 | }
160 | }
161 |
162 | @ExperimentalAnimationApi
163 | fun popExitAnimation(desRoute: String, target: NavBackStackEntry): ExitTransition? {
164 | return when (target.destination.route) {
165 | desRoute ->
166 | slideOutHorizontally(
167 | targetOffsetX = { ANIMATION_DURATION },
168 | animationSpec = tween(ANIMATION_DURATION)
169 | ) + fadeOut(animationSpec = tween(ANIMATION_DURATION))
170 | else -> null
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/characters/CharactersScreen.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.characters
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.clickable
5 | import androidx.compose.foundation.layout.Arrangement
6 | import androidx.compose.foundation.layout.Column
7 | import androidx.compose.foundation.layout.Row
8 | import androidx.compose.foundation.layout.Spacer
9 | import androidx.compose.foundation.layout.fillMaxSize
10 | import androidx.compose.foundation.layout.fillMaxWidth
11 | import androidx.compose.foundation.layout.height
12 | import androidx.compose.foundation.layout.padding
13 | import androidx.compose.foundation.layout.requiredHeight
14 | import androidx.compose.foundation.layout.size
15 | import androidx.compose.foundation.layout.wrapContentHeight
16 | import androidx.compose.foundation.layout.wrapContentSize
17 | import androidx.compose.foundation.layout.wrapContentWidth
18 | import androidx.compose.foundation.lazy.LazyColumn
19 | import androidx.compose.foundation.shape.CircleShape
20 | import androidx.compose.material.Button
21 | import androidx.compose.material.CircularProgressIndicator
22 | import androidx.compose.material.ContentAlpha
23 | import androidx.compose.material.Divider
24 | import androidx.compose.material.LocalContentAlpha
25 | import androidx.compose.material.MaterialTheme
26 | import androidx.compose.material.Scaffold
27 | import androidx.compose.material.Surface
28 | import androidx.compose.material.Text
29 | import androidx.compose.material.TopAppBar
30 | import androidx.compose.runtime.Composable
31 | import androidx.compose.runtime.CompositionLocalProvider
32 | import androidx.compose.ui.Alignment
33 | import androidx.compose.ui.Modifier
34 | import androidx.compose.ui.text.style.TextAlign
35 | import androidx.compose.ui.text.style.TextOverflow
36 | import androidx.compose.ui.unit.Dp
37 | import androidx.compose.ui.unit.dp
38 | import androidx.compose.ui.unit.sp
39 | import androidx.paging.LoadState
40 | import androidx.paging.compose.collectAsLazyPagingItems
41 | import androidx.paging.compose.items
42 | import coil.compose.LocalImageLoader
43 | import coil.compose.rememberImagePainter
44 | import com.gowtham.ricknmorty.MainViewModel
45 | import fragment.CharacterDetail
46 |
47 | @Composable
48 | fun CharactersScreen(
49 | viewModel: MainViewModel,
50 | bottomBar: @Composable () -> Unit,
51 | onClickListener: (character: CharacterDetail) -> Unit
52 | ) {
53 | val lazyCharacterList = viewModel.characters.collectAsLazyPagingItems()
54 | Scaffold(
55 | topBar = { TopAppBar(title = { Text("Characters") }) },
56 | bottomBar = bottomBar,
57 | modifier = Modifier.fillMaxSize()
58 | ) {
59 | if (lazyCharacterList.loadState.refresh is LoadState.Loading) {
60 | CircularProgressIndicator(
61 | modifier = Modifier
62 | .fillMaxSize()
63 | .padding(12.dp)
64 | .size(35.dp)
65 | .wrapContentSize(Alignment.Center),
66 | strokeWidth = 5.dp
67 | )
68 | }
69 | LazyColumn(contentPadding = it) {
70 | items(lazyCharacterList) { character ->
71 | character?.let {
72 | CharactersListRowView(character, onClickListener)
73 | }
74 | }
75 | if (lazyCharacterList.loadState.append is LoadState.Loading) {
76 | item {
77 | CircularProgressIndicator(
78 | modifier = Modifier
79 | .fillMaxWidth()
80 | .requiredHeight(80.dp)
81 | .padding(16.dp)
82 | .wrapContentHeight()
83 | .wrapContentWidth(Alignment.CenterHorizontally),
84 | strokeWidth = 4.5.dp
85 | )
86 | }
87 | }
88 | if (lazyCharacterList.loadState.append is LoadState.Error) {
89 | val state = lazyCharacterList.loadState.append as LoadState.Error
90 | val errorMessage = state.error.localizedMessage ?: "unknown error occurred"
91 | item {
92 | ErrorView(errorMessage) {
93 | lazyCharacterList.retry()
94 | }
95 | }
96 | }
97 | }
98 | if (lazyCharacterList.loadState.refresh is LoadState.Error) {
99 | val state = lazyCharacterList.loadState.refresh as LoadState.Error
100 | val errorMessage = state.error.localizedMessage ?: "unknown error occurred"
101 | ErrorView(errorMessage) {
102 | lazyCharacterList.retry()
103 | }
104 | }
105 | }
106 | }
107 |
108 | @Composable
109 | fun ErrorView(errorMessage: String, onBtnClick: () -> Unit) {
110 | Column(
111 | modifier = Modifier
112 | .fillMaxSize()
113 | .padding(8.dp)
114 | .requiredHeight(80.dp),
115 | verticalArrangement = Arrangement.Center,
116 | horizontalAlignment = Alignment.CenterHorizontally
117 | ) {
118 | Text(
119 | errorMessage, style = MaterialTheme.typography.button,
120 | textAlign = TextAlign.Center, fontSize = 16.sp
121 | )
122 | Spacer(modifier = Modifier.height(6.dp))
123 | Button(
124 | onClick = onBtnClick
125 | ) {
126 | Text("Retry")
127 | }
128 | }
129 | }
130 |
131 | @Composable
132 | fun CharactersListRowView(
133 | character: CharacterDetail,
134 | onClickListener: (character: CharacterDetail) -> Unit
135 | ) {
136 | Row(
137 | modifier = Modifier
138 | .fillMaxWidth()
139 | .clickable(
140 | onClick = {
141 | onClickListener(character)
142 | }
143 | )
144 | .padding(12.dp),
145 | verticalAlignment = Alignment.CenterVertically
146 | ) {
147 |
148 | CharacterAvatar(name = character.name.toString(), url = character.image, size = 55.dp)
149 |
150 | Column(modifier = Modifier.padding(horizontal = 8.dp)) {
151 | Text(
152 | character.name ?: "Name unavailable",
153 | style = MaterialTheme.typography.h6, maxLines = 1, overflow = TextOverflow.Ellipsis
154 | )
155 | CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
156 | Text(
157 | "${character.episode.size} episode(s)",
158 | style = MaterialTheme.typography.body2
159 | )
160 | }
161 | }
162 | }
163 | Divider(modifier = Modifier.padding(horizontal = 6.dp))
164 | }
165 |
166 | @Composable
167 | fun CharacterAvatar(name: String, url: String?, size: Dp) {
168 | Surface(
169 | modifier = Modifier.size(size),
170 | shape = CircleShape,
171 | color = MaterialTheme.colors.onSurface.copy(alpha = 0.2f)
172 | ) {
173 | url?.let {
174 | Image(
175 | painter = rememberImagePainter(
176 | data = it,
177 | imageLoader = LocalImageLoader.current,
178 | builder = {
179 | crossfade(durationMillis = 400)
180 | placeholder(0)
181 | }
182 | ),
183 | modifier = Modifier.size(size),
184 | contentDescription = name
185 | )
186 | }
187 | }
188 | }
189 |
--------------------------------------------------------------------------------
/app/src/main/java/com/gowtham/ricknmorty/compose/character/CharacterDetailScreen.kt:
--------------------------------------------------------------------------------
1 | package com.gowtham.ricknmorty.compose.character
2 |
3 | import androidx.compose.foundation.Image
4 | import androidx.compose.foundation.layout.Arrangement
5 | import androidx.compose.foundation.layout.Row
6 | import androidx.compose.foundation.layout.Spacer
7 | import androidx.compose.foundation.layout.fillMaxSize
8 | import androidx.compose.foundation.layout.fillMaxWidth
9 | import androidx.compose.foundation.layout.padding
10 | import androidx.compose.foundation.layout.size
11 | import androidx.compose.foundation.layout.width
12 | import androidx.compose.foundation.layout.wrapContentSize
13 | import androidx.compose.foundation.lazy.LazyColumn
14 | import androidx.compose.foundation.shape.RoundedCornerShape
15 | import androidx.compose.material.Card
16 | import androidx.compose.material.CircularProgressIndicator
17 | import androidx.compose.material.ContentAlpha
18 | import androidx.compose.material.Divider
19 | import androidx.compose.material.Icon
20 | import androidx.compose.material.IconButton
21 | import androidx.compose.material.LocalContentAlpha
22 | import androidx.compose.material.MaterialTheme
23 | import androidx.compose.material.Scaffold
24 | import androidx.compose.material.Surface
25 | import androidx.compose.material.Text
26 | import androidx.compose.material.TopAppBar
27 | import androidx.compose.material.icons.Icons
28 | import androidx.compose.material.icons.filled.ArrowBack
29 | import androidx.compose.material.icons.outlined.Map
30 | import androidx.compose.material.icons.outlined.NearMe
31 | import androidx.compose.material.icons.outlined.SmartToy
32 | import androidx.compose.material.icons.outlined.StackedLineChart
33 | import androidx.compose.material.icons.outlined.Wc
34 | import androidx.compose.runtime.Composable
35 | import androidx.compose.runtime.CompositionLocalProvider
36 | import androidx.compose.runtime.LaunchedEffect
37 | import androidx.compose.runtime.collectAsState
38 | import androidx.compose.runtime.rememberCoroutineScope
39 | import androidx.compose.ui.Alignment
40 | import androidx.compose.ui.Modifier
41 | import androidx.compose.ui.unit.dp
42 | import androidx.hilt.navigation.compose.hiltViewModel
43 | import coil.compose.LocalImageLoader
44 | import coil.compose.rememberImagePainter
45 | import com.gowtham.ricknmorty.compose.common.CharacterTitle
46 | import com.gowtham.ricknmorty.compose.common.FailedComposable
47 | import com.gowtham.ricknmorty.compose.common.InfoRow
48 | import com.gowtham.ricknmorty.utils.Resource
49 | import fragment.CharacterDetail
50 | import kotlinx.coroutines.launch
51 |
52 | @Composable
53 | fun CharacterDetailScreen(
54 | characterId: String,
55 | characterName: String,
56 | viewModel: CharacterViewModel = hiltViewModel(),
57 | popBack: () -> Unit
58 | ) {
59 |
60 | val coroutineScope = rememberCoroutineScope()
61 |
62 | val characterState = viewModel.state.collectAsState()
63 |
64 | LaunchedEffect(characterId) {
65 | viewModel.setCharacter(characterId)
66 | }
67 |
68 | val retry: () -> Unit = {
69 | coroutineScope.launch {
70 | viewModel.setCharacter(characterId)
71 | }
72 | }
73 |
74 | Scaffold(
75 | topBar = {
76 | TopAppBar(
77 | title = { Text(characterName) },
78 | navigationIcon = {
79 | IconButton(onClick = { popBack() }) {
80 | Icon(Icons.Filled.ArrowBack, contentDescription = "Back")
81 | }
82 | }
83 | )
84 | }
85 | ) {
86 | when (characterState.value) {
87 | is Resource.Success -> DetailData(characterState.value.data)
88 | is Resource.Error -> FailedComposable(
89 | errorMessage = characterState.value.message.toString(), retry = retry
90 | )
91 | else -> CircularProgressIndicator(
92 | modifier = Modifier
93 | .fillMaxSize()
94 | .padding(12.dp)
95 | .size(35.dp)
96 | .wrapContentSize(Alignment.Center)
97 | )
98 | }
99 | }
100 | }
101 |
102 | @Composable
103 | fun DetailData(character: CharacterDetail?) {
104 | val listInfoTitle = listOf("Species", "Gender", "Status", "Location", "Origin")
105 | val listInfo = listOf(
106 | character?.species.toString(),
107 | character?.gender.toString(),
108 | character?.status.toString(),
109 | character?.location?.name.toString(),
110 | character?.origin?.name.toString()
111 | )
112 | val listInfoIcon = listOf(
113 | Icons.Outlined.SmartToy, Icons.Outlined.Wc, Icons.Outlined.StackedLineChart,
114 | Icons.Outlined.Map, Icons.Outlined.NearMe
115 | )
116 |
117 | Surface {
118 | LazyColumn {
119 | character?.let {
120 | item {
121 | CharacterTitle("MUGSHOT")
122 | }
123 | item {
124 | CharacterImage(character)
125 | }
126 | item {
127 | CharacterTitle("INFO")
128 | }
129 | items(listInfoTitle.size) { index ->
130 | InfoRow(
131 | imageVector = listInfoIcon[index],
132 | title = listInfoTitle[index],
133 | subTitle = listInfo[index]
134 | )
135 | if (index != listInfoTitle.lastIndex)
136 | Divider()
137 | }
138 | item {
139 | CharacterTitle("EPISODES")
140 | }
141 | items(character.episode.size) { index ->
142 | val episode = it.episode[index]
143 | episode?.let {
144 | EpisodeRow(episode)
145 | if (index < character.episode.lastIndex)
146 | Divider(modifier = Modifier.padding(horizontal = 12.dp))
147 | }
148 | }
149 | }
150 | }
151 | }
152 | }
153 |
154 | @Composable
155 | fun CharacterImage(character: CharacterDetail) {
156 | Row(
157 | modifier = Modifier
158 | .fillMaxWidth()
159 | .padding(vertical = 8.dp),
160 | horizontalArrangement = Arrangement.Center
161 | ) {
162 | Surface {
163 | Card(
164 | modifier = Modifier.size(140.dp),
165 | shape = RoundedCornerShape(22.dp)
166 | ) {
167 | Image(
168 | painter = rememberImagePainter(
169 | data = character.image,
170 | imageLoader = LocalImageLoader.current,
171 | builder = {
172 | crossfade(
173 | durationMillis = 400
174 | )
175 | placeholder(0)
176 | }
177 | ),
178 | contentDescription = character.name,
179 | )
180 | }
181 | }
182 | }
183 | }
184 |
185 | @Composable
186 | fun EpisodeRow(episode: CharacterDetail.Episode) {
187 | Row(
188 | modifier = Modifier
189 | .fillMaxWidth()
190 | .padding(12.dp),
191 | verticalAlignment = Alignment.CenterVertically
192 | ) {
193 | Text(
194 | episode.name.toString(),
195 | modifier = Modifier.weight(1f),
196 | style = MaterialTheme.typography.subtitle1,
197 | )
198 | Spacer(modifier = Modifier.width(12.dp))
199 | CompositionLocalProvider(LocalContentAlpha provides ContentAlpha.medium) {
200 | Text(
201 | episode.air_date.toString(),
202 | style = MaterialTheme.typography.body2
203 | )
204 | }
205 | }
206 | }
207 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/app/src/main/graphql/schema.json:
--------------------------------------------------------------------------------
1 | {
2 | "data": {
3 | "__schema": {
4 | "queryType": {
5 | "name": "Query"
6 | },
7 | "mutationType": null,
8 | "subscriptionType": null,
9 | "types": [
10 | {
11 | "kind": "OBJECT",
12 | "name": "Query",
13 | "description": "",
14 | "fields": [
15 | {
16 | "name": "character",
17 | "description": "Get a specific character by ID",
18 | "args": [
19 | {
20 | "name": "id",
21 | "description": "",
22 | "type": {
23 | "kind": "NON_NULL",
24 | "name": null,
25 | "ofType": {
26 | "kind": "SCALAR",
27 | "name": "ID",
28 | "ofType": null
29 | }
30 | },
31 | "defaultValue": null
32 | }
33 | ],
34 | "type": {
35 | "kind": "OBJECT",
36 | "name": "Character",
37 | "ofType": null
38 | },
39 | "isDeprecated": false,
40 | "deprecationReason": null
41 | },
42 | {
43 | "name": "characters",
44 | "description": "Get the list of all characters",
45 | "args": [
46 | {
47 | "name": "page",
48 | "description": "",
49 | "type": {
50 | "kind": "SCALAR",
51 | "name": "Int",
52 | "ofType": null
53 | },
54 | "defaultValue": null
55 | },
56 | {
57 | "name": "filter",
58 | "description": "",
59 | "type": {
60 | "kind": "INPUT_OBJECT",
61 | "name": "FilterCharacter",
62 | "ofType": null
63 | },
64 | "defaultValue": null
65 | }
66 | ],
67 | "type": {
68 | "kind": "OBJECT",
69 | "name": "Characters",
70 | "ofType": null
71 | },
72 | "isDeprecated": false,
73 | "deprecationReason": null
74 | },
75 | {
76 | "name": "charactersByIds",
77 | "description": "Get a list of characters selected by ids",
78 | "args": [
79 | {
80 | "name": "ids",
81 | "description": "",
82 | "type": {
83 | "kind": "NON_NULL",
84 | "name": null,
85 | "ofType": {
86 | "kind": "LIST",
87 | "name": null,
88 | "ofType": {
89 | "kind": "NON_NULL",
90 | "name": null,
91 | "ofType": {
92 | "kind": "SCALAR",
93 | "name": "ID",
94 | "ofType": null
95 | }
96 | }
97 | }
98 | },
99 | "defaultValue": null
100 | }
101 | ],
102 | "type": {
103 | "kind": "LIST",
104 | "name": null,
105 | "ofType": {
106 | "kind": "OBJECT",
107 | "name": "Character",
108 | "ofType": null
109 | }
110 | },
111 | "isDeprecated": false,
112 | "deprecationReason": null
113 | },
114 | {
115 | "name": "location",
116 | "description": "Get a specific locations by ID",
117 | "args": [
118 | {
119 | "name": "id",
120 | "description": "",
121 | "type": {
122 | "kind": "NON_NULL",
123 | "name": null,
124 | "ofType": {
125 | "kind": "SCALAR",
126 | "name": "ID",
127 | "ofType": null
128 | }
129 | },
130 | "defaultValue": null
131 | }
132 | ],
133 | "type": {
134 | "kind": "OBJECT",
135 | "name": "Location",
136 | "ofType": null
137 | },
138 | "isDeprecated": false,
139 | "deprecationReason": null
140 | },
141 | {
142 | "name": "locations",
143 | "description": "Get the list of all locations",
144 | "args": [
145 | {
146 | "name": "page",
147 | "description": "",
148 | "type": {
149 | "kind": "SCALAR",
150 | "name": "Int",
151 | "ofType": null
152 | },
153 | "defaultValue": null
154 | },
155 | {
156 | "name": "filter",
157 | "description": "",
158 | "type": {
159 | "kind": "INPUT_OBJECT",
160 | "name": "FilterLocation",
161 | "ofType": null
162 | },
163 | "defaultValue": null
164 | }
165 | ],
166 | "type": {
167 | "kind": "OBJECT",
168 | "name": "Locations",
169 | "ofType": null
170 | },
171 | "isDeprecated": false,
172 | "deprecationReason": null
173 | },
174 | {
175 | "name": "locationsByIds",
176 | "description": "Get a list of locations selected by ids",
177 | "args": [
178 | {
179 | "name": "ids",
180 | "description": "",
181 | "type": {
182 | "kind": "NON_NULL",
183 | "name": null,
184 | "ofType": {
185 | "kind": "LIST",
186 | "name": null,
187 | "ofType": {
188 | "kind": "NON_NULL",
189 | "name": null,
190 | "ofType": {
191 | "kind": "SCALAR",
192 | "name": "ID",
193 | "ofType": null
194 | }
195 | }
196 | }
197 | },
198 | "defaultValue": null
199 | }
200 | ],
201 | "type": {
202 | "kind": "LIST",
203 | "name": null,
204 | "ofType": {
205 | "kind": "OBJECT",
206 | "name": "Location",
207 | "ofType": null
208 | }
209 | },
210 | "isDeprecated": false,
211 | "deprecationReason": null
212 | },
213 | {
214 | "name": "episode",
215 | "description": "Get a specific episode by ID",
216 | "args": [
217 | {
218 | "name": "id",
219 | "description": "",
220 | "type": {
221 | "kind": "NON_NULL",
222 | "name": null,
223 | "ofType": {
224 | "kind": "SCALAR",
225 | "name": "ID",
226 | "ofType": null
227 | }
228 | },
229 | "defaultValue": null
230 | }
231 | ],
232 | "type": {
233 | "kind": "OBJECT",
234 | "name": "Episode",
235 | "ofType": null
236 | },
237 | "isDeprecated": false,
238 | "deprecationReason": null
239 | },
240 | {
241 | "name": "episodes",
242 | "description": "Get the list of all episodes",
243 | "args": [
244 | {
245 | "name": "page",
246 | "description": "",
247 | "type": {
248 | "kind": "SCALAR",
249 | "name": "Int",
250 | "ofType": null
251 | },
252 | "defaultValue": null
253 | },
254 | {
255 | "name": "filter",
256 | "description": "",
257 | "type": {
258 | "kind": "INPUT_OBJECT",
259 | "name": "FilterEpisode",
260 | "ofType": null
261 | },
262 | "defaultValue": null
263 | }
264 | ],
265 | "type": {
266 | "kind": "OBJECT",
267 | "name": "Episodes",
268 | "ofType": null
269 | },
270 | "isDeprecated": false,
271 | "deprecationReason": null
272 | },
273 | {
274 | "name": "episodesByIds",
275 | "description": "Get a list of episodes selected by ids",
276 | "args": [
277 | {
278 | "name": "ids",
279 | "description": "",
280 | "type": {
281 | "kind": "NON_NULL",
282 | "name": null,
283 | "ofType": {
284 | "kind": "LIST",
285 | "name": null,
286 | "ofType": {
287 | "kind": "NON_NULL",
288 | "name": null,
289 | "ofType": {
290 | "kind": "SCALAR",
291 | "name": "ID",
292 | "ofType": null
293 | }
294 | }
295 | }
296 | },
297 | "defaultValue": null
298 | }
299 | ],
300 | "type": {
301 | "kind": "LIST",
302 | "name": null,
303 | "ofType": {
304 | "kind": "OBJECT",
305 | "name": "Episode",
306 | "ofType": null
307 | }
308 | },
309 | "isDeprecated": false,
310 | "deprecationReason": null
311 | }
312 | ],
313 | "inputFields": null,
314 | "interfaces": [],
315 | "enumValues": null,
316 | "possibleTypes": null
317 | },
318 | {
319 | "kind": "SCALAR",
320 | "name": "ID",
321 | "description": "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.",
322 | "fields": null,
323 | "inputFields": null,
324 | "interfaces": null,
325 | "enumValues": null,
326 | "possibleTypes": null
327 | },
328 | {
329 | "kind": "OBJECT",
330 | "name": "Character",
331 | "description": "",
332 | "fields": [
333 | {
334 | "name": "id",
335 | "description": "The id of the character.",
336 | "args": [],
337 | "type": {
338 | "kind": "SCALAR",
339 | "name": "ID",
340 | "ofType": null
341 | },
342 | "isDeprecated": false,
343 | "deprecationReason": null
344 | },
345 | {
346 | "name": "name",
347 | "description": "The name of the character.",
348 | "args": [],
349 | "type": {
350 | "kind": "SCALAR",
351 | "name": "String",
352 | "ofType": null
353 | },
354 | "isDeprecated": false,
355 | "deprecationReason": null
356 | },
357 | {
358 | "name": "status",
359 | "description": "The status of the character ('Alive', 'Dead' or 'unknown').",
360 | "args": [],
361 | "type": {
362 | "kind": "SCALAR",
363 | "name": "String",
364 | "ofType": null
365 | },
366 | "isDeprecated": false,
367 | "deprecationReason": null
368 | },
369 | {
370 | "name": "species",
371 | "description": "The species of the character.",
372 | "args": [],
373 | "type": {
374 | "kind": "SCALAR",
375 | "name": "String",
376 | "ofType": null
377 | },
378 | "isDeprecated": false,
379 | "deprecationReason": null
380 | },
381 | {
382 | "name": "type",
383 | "description": "The type or subspecies of the character.",
384 | "args": [],
385 | "type": {
386 | "kind": "SCALAR",
387 | "name": "String",
388 | "ofType": null
389 | },
390 | "isDeprecated": false,
391 | "deprecationReason": null
392 | },
393 | {
394 | "name": "gender",
395 | "description": "The gender of the character ('Female', 'Male', 'Genderless' or 'unknown').",
396 | "args": [],
397 | "type": {
398 | "kind": "SCALAR",
399 | "name": "String",
400 | "ofType": null
401 | },
402 | "isDeprecated": false,
403 | "deprecationReason": null
404 | },
405 | {
406 | "name": "origin",
407 | "description": "The character's origin location",
408 | "args": [],
409 | "type": {
410 | "kind": "OBJECT",
411 | "name": "Location",
412 | "ofType": null
413 | },
414 | "isDeprecated": false,
415 | "deprecationReason": null
416 | },
417 | {
418 | "name": "location",
419 | "description": "The character's last known location",
420 | "args": [],
421 | "type": {
422 | "kind": "OBJECT",
423 | "name": "Location",
424 | "ofType": null
425 | },
426 | "isDeprecated": false,
427 | "deprecationReason": null
428 | },
429 | {
430 | "name": "image",
431 | "description": "Link to the character's image.\nAll images are 300x300px and most are medium shots or portraits since they are intended to be used as avatars.",
432 | "args": [],
433 | "type": {
434 | "kind": "SCALAR",
435 | "name": "String",
436 | "ofType": null
437 | },
438 | "isDeprecated": false,
439 | "deprecationReason": null
440 | },
441 | {
442 | "name": "episode",
443 | "description": "Episodes in which this character appeared.",
444 | "args": [],
445 | "type": {
446 | "kind": "NON_NULL",
447 | "name": null,
448 | "ofType": {
449 | "kind": "LIST",
450 | "name": null,
451 | "ofType": {
452 | "kind": "OBJECT",
453 | "name": "Episode",
454 | "ofType": null
455 | }
456 | }
457 | },
458 | "isDeprecated": false,
459 | "deprecationReason": null
460 | },
461 | {
462 | "name": "created",
463 | "description": "Time at which the character was created in the database.",
464 | "args": [],
465 | "type": {
466 | "kind": "SCALAR",
467 | "name": "String",
468 | "ofType": null
469 | },
470 | "isDeprecated": false,
471 | "deprecationReason": null
472 | }
473 | ],
474 | "inputFields": null,
475 | "interfaces": [],
476 | "enumValues": null,
477 | "possibleTypes": null
478 | },
479 | {
480 | "kind": "SCALAR",
481 | "name": "String",
482 | "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.",
483 | "fields": null,
484 | "inputFields": null,
485 | "interfaces": null,
486 | "enumValues": null,
487 | "possibleTypes": null
488 | },
489 | {
490 | "kind": "OBJECT",
491 | "name": "Location",
492 | "description": "",
493 | "fields": [
494 | {
495 | "name": "id",
496 | "description": "The id of the location.",
497 | "args": [],
498 | "type": {
499 | "kind": "SCALAR",
500 | "name": "ID",
501 | "ofType": null
502 | },
503 | "isDeprecated": false,
504 | "deprecationReason": null
505 | },
506 | {
507 | "name": "name",
508 | "description": "The name of the location.",
509 | "args": [],
510 | "type": {
511 | "kind": "SCALAR",
512 | "name": "String",
513 | "ofType": null
514 | },
515 | "isDeprecated": false,
516 | "deprecationReason": null
517 | },
518 | {
519 | "name": "type",
520 | "description": "The type of the location.",
521 | "args": [],
522 | "type": {
523 | "kind": "SCALAR",
524 | "name": "String",
525 | "ofType": null
526 | },
527 | "isDeprecated": false,
528 | "deprecationReason": null
529 | },
530 | {
531 | "name": "dimension",
532 | "description": "The dimension in which the location is located.",
533 | "args": [],
534 | "type": {
535 | "kind": "SCALAR",
536 | "name": "String",
537 | "ofType": null
538 | },
539 | "isDeprecated": false,
540 | "deprecationReason": null
541 | },
542 | {
543 | "name": "residents",
544 | "description": "List of characters who have been last seen in the location.",
545 | "args": [],
546 | "type": {
547 | "kind": "NON_NULL",
548 | "name": null,
549 | "ofType": {
550 | "kind": "LIST",
551 | "name": null,
552 | "ofType": {
553 | "kind": "OBJECT",
554 | "name": "Character",
555 | "ofType": null
556 | }
557 | }
558 | },
559 | "isDeprecated": false,
560 | "deprecationReason": null
561 | },
562 | {
563 | "name": "created",
564 | "description": "Time at which the location was created in the database.",
565 | "args": [],
566 | "type": {
567 | "kind": "SCALAR",
568 | "name": "String",
569 | "ofType": null
570 | },
571 | "isDeprecated": false,
572 | "deprecationReason": null
573 | }
574 | ],
575 | "inputFields": null,
576 | "interfaces": [],
577 | "enumValues": null,
578 | "possibleTypes": null
579 | },
580 | {
581 | "kind": "OBJECT",
582 | "name": "Episode",
583 | "description": "",
584 | "fields": [
585 | {
586 | "name": "id",
587 | "description": "The id of the episode.",
588 | "args": [],
589 | "type": {
590 | "kind": "SCALAR",
591 | "name": "ID",
592 | "ofType": null
593 | },
594 | "isDeprecated": false,
595 | "deprecationReason": null
596 | },
597 | {
598 | "name": "name",
599 | "description": "The name of the episode.",
600 | "args": [],
601 | "type": {
602 | "kind": "SCALAR",
603 | "name": "String",
604 | "ofType": null
605 | },
606 | "isDeprecated": false,
607 | "deprecationReason": null
608 | },
609 | {
610 | "name": "air_date",
611 | "description": "The air date of the episode.",
612 | "args": [],
613 | "type": {
614 | "kind": "SCALAR",
615 | "name": "String",
616 | "ofType": null
617 | },
618 | "isDeprecated": false,
619 | "deprecationReason": null
620 | },
621 | {
622 | "name": "episode",
623 | "description": "The code of the episode.",
624 | "args": [],
625 | "type": {
626 | "kind": "SCALAR",
627 | "name": "String",
628 | "ofType": null
629 | },
630 | "isDeprecated": false,
631 | "deprecationReason": null
632 | },
633 | {
634 | "name": "characters",
635 | "description": "List of characters who have been seen in the episode.",
636 | "args": [],
637 | "type": {
638 | "kind": "NON_NULL",
639 | "name": null,
640 | "ofType": {
641 | "kind": "LIST",
642 | "name": null,
643 | "ofType": {
644 | "kind": "OBJECT",
645 | "name": "Character",
646 | "ofType": null
647 | }
648 | }
649 | },
650 | "isDeprecated": false,
651 | "deprecationReason": null
652 | },
653 | {
654 | "name": "created",
655 | "description": "Time at which the episode was created in the database.",
656 | "args": [],
657 | "type": {
658 | "kind": "SCALAR",
659 | "name": "String",
660 | "ofType": null
661 | },
662 | "isDeprecated": false,
663 | "deprecationReason": null
664 | }
665 | ],
666 | "inputFields": null,
667 | "interfaces": [],
668 | "enumValues": null,
669 | "possibleTypes": null
670 | },
671 | {
672 | "kind": "SCALAR",
673 | "name": "Int",
674 | "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",
675 | "fields": null,
676 | "inputFields": null,
677 | "interfaces": null,
678 | "enumValues": null,
679 | "possibleTypes": null
680 | },
681 | {
682 | "kind": "INPUT_OBJECT",
683 | "name": "FilterCharacter",
684 | "description": "",
685 | "fields": null,
686 | "inputFields": [
687 | {
688 | "name": "name",
689 | "description": "",
690 | "type": {
691 | "kind": "SCALAR",
692 | "name": "String",
693 | "ofType": null
694 | },
695 | "defaultValue": null
696 | },
697 | {
698 | "name": "status",
699 | "description": "",
700 | "type": {
701 | "kind": "SCALAR",
702 | "name": "String",
703 | "ofType": null
704 | },
705 | "defaultValue": null
706 | },
707 | {
708 | "name": "species",
709 | "description": "",
710 | "type": {
711 | "kind": "SCALAR",
712 | "name": "String",
713 | "ofType": null
714 | },
715 | "defaultValue": null
716 | },
717 | {
718 | "name": "type",
719 | "description": "",
720 | "type": {
721 | "kind": "SCALAR",
722 | "name": "String",
723 | "ofType": null
724 | },
725 | "defaultValue": null
726 | },
727 | {
728 | "name": "gender",
729 | "description": "",
730 | "type": {
731 | "kind": "SCALAR",
732 | "name": "String",
733 | "ofType": null
734 | },
735 | "defaultValue": null
736 | }
737 | ],
738 | "interfaces": null,
739 | "enumValues": null,
740 | "possibleTypes": null
741 | },
742 | {
743 | "kind": "OBJECT",
744 | "name": "Characters",
745 | "description": "",
746 | "fields": [
747 | {
748 | "name": "info",
749 | "description": "",
750 | "args": [],
751 | "type": {
752 | "kind": "OBJECT",
753 | "name": "Info",
754 | "ofType": null
755 | },
756 | "isDeprecated": false,
757 | "deprecationReason": null
758 | },
759 | {
760 | "name": "results",
761 | "description": "",
762 | "args": [],
763 | "type": {
764 | "kind": "LIST",
765 | "name": null,
766 | "ofType": {
767 | "kind": "OBJECT",
768 | "name": "Character",
769 | "ofType": null
770 | }
771 | },
772 | "isDeprecated": false,
773 | "deprecationReason": null
774 | }
775 | ],
776 | "inputFields": null,
777 | "interfaces": [],
778 | "enumValues": null,
779 | "possibleTypes": null
780 | },
781 | {
782 | "kind": "OBJECT",
783 | "name": "Info",
784 | "description": "",
785 | "fields": [
786 | {
787 | "name": "count",
788 | "description": "The length of the response.",
789 | "args": [],
790 | "type": {
791 | "kind": "SCALAR",
792 | "name": "Int",
793 | "ofType": null
794 | },
795 | "isDeprecated": false,
796 | "deprecationReason": null
797 | },
798 | {
799 | "name": "pages",
800 | "description": "The amount of pages.",
801 | "args": [],
802 | "type": {
803 | "kind": "SCALAR",
804 | "name": "Int",
805 | "ofType": null
806 | },
807 | "isDeprecated": false,
808 | "deprecationReason": null
809 | },
810 | {
811 | "name": "next",
812 | "description": "Number of the next page (if it exists)",
813 | "args": [],
814 | "type": {
815 | "kind": "SCALAR",
816 | "name": "Int",
817 | "ofType": null
818 | },
819 | "isDeprecated": false,
820 | "deprecationReason": null
821 | },
822 | {
823 | "name": "prev",
824 | "description": "Number of the previous page (if it exists)",
825 | "args": [],
826 | "type": {
827 | "kind": "SCALAR",
828 | "name": "Int",
829 | "ofType": null
830 | },
831 | "isDeprecated": false,
832 | "deprecationReason": null
833 | }
834 | ],
835 | "inputFields": null,
836 | "interfaces": [],
837 | "enumValues": null,
838 | "possibleTypes": null
839 | },
840 | {
841 | "kind": "INPUT_OBJECT",
842 | "name": "FilterLocation",
843 | "description": "",
844 | "fields": null,
845 | "inputFields": [
846 | {
847 | "name": "name",
848 | "description": "",
849 | "type": {
850 | "kind": "SCALAR",
851 | "name": "String",
852 | "ofType": null
853 | },
854 | "defaultValue": null
855 | },
856 | {
857 | "name": "type",
858 | "description": "",
859 | "type": {
860 | "kind": "SCALAR",
861 | "name": "String",
862 | "ofType": null
863 | },
864 | "defaultValue": null
865 | },
866 | {
867 | "name": "dimension",
868 | "description": "",
869 | "type": {
870 | "kind": "SCALAR",
871 | "name": "String",
872 | "ofType": null
873 | },
874 | "defaultValue": null
875 | }
876 | ],
877 | "interfaces": null,
878 | "enumValues": null,
879 | "possibleTypes": null
880 | },
881 | {
882 | "kind": "OBJECT",
883 | "name": "Locations",
884 | "description": "",
885 | "fields": [
886 | {
887 | "name": "info",
888 | "description": "",
889 | "args": [],
890 | "type": {
891 | "kind": "OBJECT",
892 | "name": "Info",
893 | "ofType": null
894 | },
895 | "isDeprecated": false,
896 | "deprecationReason": null
897 | },
898 | {
899 | "name": "results",
900 | "description": "",
901 | "args": [],
902 | "type": {
903 | "kind": "LIST",
904 | "name": null,
905 | "ofType": {
906 | "kind": "OBJECT",
907 | "name": "Location",
908 | "ofType": null
909 | }
910 | },
911 | "isDeprecated": false,
912 | "deprecationReason": null
913 | }
914 | ],
915 | "inputFields": null,
916 | "interfaces": [],
917 | "enumValues": null,
918 | "possibleTypes": null
919 | },
920 | {
921 | "kind": "INPUT_OBJECT",
922 | "name": "FilterEpisode",
923 | "description": "",
924 | "fields": null,
925 | "inputFields": [
926 | {
927 | "name": "name",
928 | "description": "",
929 | "type": {
930 | "kind": "SCALAR",
931 | "name": "String",
932 | "ofType": null
933 | },
934 | "defaultValue": null
935 | },
936 | {
937 | "name": "episode",
938 | "description": "",
939 | "type": {
940 | "kind": "SCALAR",
941 | "name": "String",
942 | "ofType": null
943 | },
944 | "defaultValue": null
945 | }
946 | ],
947 | "interfaces": null,
948 | "enumValues": null,
949 | "possibleTypes": null
950 | },
951 | {
952 | "kind": "OBJECT",
953 | "name": "Episodes",
954 | "description": "",
955 | "fields": [
956 | {
957 | "name": "info",
958 | "description": "",
959 | "args": [],
960 | "type": {
961 | "kind": "OBJECT",
962 | "name": "Info",
963 | "ofType": null
964 | },
965 | "isDeprecated": false,
966 | "deprecationReason": null
967 | },
968 | {
969 | "name": "results",
970 | "description": "",
971 | "args": [],
972 | "type": {
973 | "kind": "LIST",
974 | "name": null,
975 | "ofType": {
976 | "kind": "OBJECT",
977 | "name": "Episode",
978 | "ofType": null
979 | }
980 | },
981 | "isDeprecated": false,
982 | "deprecationReason": null
983 | }
984 | ],
985 | "inputFields": null,
986 | "interfaces": [],
987 | "enumValues": null,
988 | "possibleTypes": null
989 | },
990 | {
991 | "kind": "OBJECT",
992 | "name": "__Schema",
993 | "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",
994 | "fields": [
995 | {
996 | "name": "types",
997 | "description": "A list of all types supported by this server.",
998 | "args": [],
999 | "type": {
1000 | "kind": "NON_NULL",
1001 | "name": null,
1002 | "ofType": {
1003 | "kind": "LIST",
1004 | "name": null,
1005 | "ofType": {
1006 | "kind": "NON_NULL",
1007 | "name": null,
1008 | "ofType": {
1009 | "kind": "OBJECT",
1010 | "name": "__Type",
1011 | "ofType": null
1012 | }
1013 | }
1014 | }
1015 | },
1016 | "isDeprecated": false,
1017 | "deprecationReason": null
1018 | },
1019 | {
1020 | "name": "queryType",
1021 | "description": "The type that query operations will be rooted at.",
1022 | "args": [],
1023 | "type": {
1024 | "kind": "NON_NULL",
1025 | "name": null,
1026 | "ofType": {
1027 | "kind": "OBJECT",
1028 | "name": "__Type",
1029 | "ofType": null
1030 | }
1031 | },
1032 | "isDeprecated": false,
1033 | "deprecationReason": null
1034 | },
1035 | {
1036 | "name": "mutationType",
1037 | "description": "If this server supports mutation, the type that mutation operations will be rooted at.",
1038 | "args": [],
1039 | "type": {
1040 | "kind": "OBJECT",
1041 | "name": "__Type",
1042 | "ofType": null
1043 | },
1044 | "isDeprecated": false,
1045 | "deprecationReason": null
1046 | },
1047 | {
1048 | "name": "subscriptionType",
1049 | "description": "If this server support subscription, the type that subscription operations will be rooted at.",
1050 | "args": [],
1051 | "type": {
1052 | "kind": "OBJECT",
1053 | "name": "__Type",
1054 | "ofType": null
1055 | },
1056 | "isDeprecated": false,
1057 | "deprecationReason": null
1058 | },
1059 | {
1060 | "name": "directives",
1061 | "description": "A list of all directives supported by this server.",
1062 | "args": [],
1063 | "type": {
1064 | "kind": "NON_NULL",
1065 | "name": null,
1066 | "ofType": {
1067 | "kind": "LIST",
1068 | "name": null,
1069 | "ofType": {
1070 | "kind": "NON_NULL",
1071 | "name": null,
1072 | "ofType": {
1073 | "kind": "OBJECT",
1074 | "name": "__Directive",
1075 | "ofType": null
1076 | }
1077 | }
1078 | }
1079 | },
1080 | "isDeprecated": false,
1081 | "deprecationReason": null
1082 | }
1083 | ],
1084 | "inputFields": null,
1085 | "interfaces": [],
1086 | "enumValues": null,
1087 | "possibleTypes": null
1088 | },
1089 | {
1090 | "kind": "OBJECT",
1091 | "name": "__Type",
1092 | "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.",
1093 | "fields": [
1094 | {
1095 | "name": "kind",
1096 | "description": null,
1097 | "args": [],
1098 | "type": {
1099 | "kind": "NON_NULL",
1100 | "name": null,
1101 | "ofType": {
1102 | "kind": "ENUM",
1103 | "name": "__TypeKind",
1104 | "ofType": null
1105 | }
1106 | },
1107 | "isDeprecated": false,
1108 | "deprecationReason": null
1109 | },
1110 | {
1111 | "name": "name",
1112 | "description": null,
1113 | "args": [],
1114 | "type": {
1115 | "kind": "SCALAR",
1116 | "name": "String",
1117 | "ofType": null
1118 | },
1119 | "isDeprecated": false,
1120 | "deprecationReason": null
1121 | },
1122 | {
1123 | "name": "description",
1124 | "description": null,
1125 | "args": [],
1126 | "type": {
1127 | "kind": "SCALAR",
1128 | "name": "String",
1129 | "ofType": null
1130 | },
1131 | "isDeprecated": false,
1132 | "deprecationReason": null
1133 | },
1134 | {
1135 | "name": "fields",
1136 | "description": null,
1137 | "args": [
1138 | {
1139 | "name": "includeDeprecated",
1140 | "description": null,
1141 | "type": {
1142 | "kind": "SCALAR",
1143 | "name": "Boolean",
1144 | "ofType": null
1145 | },
1146 | "defaultValue": "false"
1147 | }
1148 | ],
1149 | "type": {
1150 | "kind": "LIST",
1151 | "name": null,
1152 | "ofType": {
1153 | "kind": "NON_NULL",
1154 | "name": null,
1155 | "ofType": {
1156 | "kind": "OBJECT",
1157 | "name": "__Field",
1158 | "ofType": null
1159 | }
1160 | }
1161 | },
1162 | "isDeprecated": false,
1163 | "deprecationReason": null
1164 | },
1165 | {
1166 | "name": "interfaces",
1167 | "description": null,
1168 | "args": [],
1169 | "type": {
1170 | "kind": "LIST",
1171 | "name": null,
1172 | "ofType": {
1173 | "kind": "NON_NULL",
1174 | "name": null,
1175 | "ofType": {
1176 | "kind": "OBJECT",
1177 | "name": "__Type",
1178 | "ofType": null
1179 | }
1180 | }
1181 | },
1182 | "isDeprecated": false,
1183 | "deprecationReason": null
1184 | },
1185 | {
1186 | "name": "possibleTypes",
1187 | "description": null,
1188 | "args": [],
1189 | "type": {
1190 | "kind": "LIST",
1191 | "name": null,
1192 | "ofType": {
1193 | "kind": "NON_NULL",
1194 | "name": null,
1195 | "ofType": {
1196 | "kind": "OBJECT",
1197 | "name": "__Type",
1198 | "ofType": null
1199 | }
1200 | }
1201 | },
1202 | "isDeprecated": false,
1203 | "deprecationReason": null
1204 | },
1205 | {
1206 | "name": "enumValues",
1207 | "description": null,
1208 | "args": [
1209 | {
1210 | "name": "includeDeprecated",
1211 | "description": null,
1212 | "type": {
1213 | "kind": "SCALAR",
1214 | "name": "Boolean",
1215 | "ofType": null
1216 | },
1217 | "defaultValue": "false"
1218 | }
1219 | ],
1220 | "type": {
1221 | "kind": "LIST",
1222 | "name": null,
1223 | "ofType": {
1224 | "kind": "NON_NULL",
1225 | "name": null,
1226 | "ofType": {
1227 | "kind": "OBJECT",
1228 | "name": "__EnumValue",
1229 | "ofType": null
1230 | }
1231 | }
1232 | },
1233 | "isDeprecated": false,
1234 | "deprecationReason": null
1235 | },
1236 | {
1237 | "name": "inputFields",
1238 | "description": null,
1239 | "args": [],
1240 | "type": {
1241 | "kind": "LIST",
1242 | "name": null,
1243 | "ofType": {
1244 | "kind": "NON_NULL",
1245 | "name": null,
1246 | "ofType": {
1247 | "kind": "OBJECT",
1248 | "name": "__InputValue",
1249 | "ofType": null
1250 | }
1251 | }
1252 | },
1253 | "isDeprecated": false,
1254 | "deprecationReason": null
1255 | },
1256 | {
1257 | "name": "ofType",
1258 | "description": null,
1259 | "args": [],
1260 | "type": {
1261 | "kind": "OBJECT",
1262 | "name": "__Type",
1263 | "ofType": null
1264 | },
1265 | "isDeprecated": false,
1266 | "deprecationReason": null
1267 | }
1268 | ],
1269 | "inputFields": null,
1270 | "interfaces": [],
1271 | "enumValues": null,
1272 | "possibleTypes": null
1273 | },
1274 | {
1275 | "kind": "ENUM",
1276 | "name": "__TypeKind",
1277 | "description": "An enum describing what kind of type a given `__Type` is.",
1278 | "fields": null,
1279 | "inputFields": null,
1280 | "interfaces": null,
1281 | "enumValues": [
1282 | {
1283 | "name": "SCALAR",
1284 | "description": "Indicates this type is a scalar.",
1285 | "isDeprecated": false,
1286 | "deprecationReason": null
1287 | },
1288 | {
1289 | "name": "OBJECT",
1290 | "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.",
1291 | "isDeprecated": false,
1292 | "deprecationReason": null
1293 | },
1294 | {
1295 | "name": "INTERFACE",
1296 | "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.",
1297 | "isDeprecated": false,
1298 | "deprecationReason": null
1299 | },
1300 | {
1301 | "name": "UNION",
1302 | "description": "Indicates this type is a union. `possibleTypes` is a valid field.",
1303 | "isDeprecated": false,
1304 | "deprecationReason": null
1305 | },
1306 | {
1307 | "name": "ENUM",
1308 | "description": "Indicates this type is an enum. `enumValues` is a valid field.",
1309 | "isDeprecated": false,
1310 | "deprecationReason": null
1311 | },
1312 | {
1313 | "name": "INPUT_OBJECT",
1314 | "description": "Indicates this type is an input object. `inputFields` is a valid field.",
1315 | "isDeprecated": false,
1316 | "deprecationReason": null
1317 | },
1318 | {
1319 | "name": "LIST",
1320 | "description": "Indicates this type is a list. `ofType` is a valid field.",
1321 | "isDeprecated": false,
1322 | "deprecationReason": null
1323 | },
1324 | {
1325 | "name": "NON_NULL",
1326 | "description": "Indicates this type is a non-null. `ofType` is a valid field.",
1327 | "isDeprecated": false,
1328 | "deprecationReason": null
1329 | }
1330 | ],
1331 | "possibleTypes": null
1332 | },
1333 | {
1334 | "kind": "SCALAR",
1335 | "name": "Boolean",
1336 | "description": "The `Boolean` scalar type represents `true` or `false`.",
1337 | "fields": null,
1338 | "inputFields": null,
1339 | "interfaces": null,
1340 | "enumValues": null,
1341 | "possibleTypes": null
1342 | },
1343 | {
1344 | "kind": "OBJECT",
1345 | "name": "__Field",
1346 | "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.",
1347 | "fields": [
1348 | {
1349 | "name": "name",
1350 | "description": null,
1351 | "args": [],
1352 | "type": {
1353 | "kind": "NON_NULL",
1354 | "name": null,
1355 | "ofType": {
1356 | "kind": "SCALAR",
1357 | "name": "String",
1358 | "ofType": null
1359 | }
1360 | },
1361 | "isDeprecated": false,
1362 | "deprecationReason": null
1363 | },
1364 | {
1365 | "name": "description",
1366 | "description": null,
1367 | "args": [],
1368 | "type": {
1369 | "kind": "SCALAR",
1370 | "name": "String",
1371 | "ofType": null
1372 | },
1373 | "isDeprecated": false,
1374 | "deprecationReason": null
1375 | },
1376 | {
1377 | "name": "args",
1378 | "description": null,
1379 | "args": [],
1380 | "type": {
1381 | "kind": "NON_NULL",
1382 | "name": null,
1383 | "ofType": {
1384 | "kind": "LIST",
1385 | "name": null,
1386 | "ofType": {
1387 | "kind": "NON_NULL",
1388 | "name": null,
1389 | "ofType": {
1390 | "kind": "OBJECT",
1391 | "name": "__InputValue",
1392 | "ofType": null
1393 | }
1394 | }
1395 | }
1396 | },
1397 | "isDeprecated": false,
1398 | "deprecationReason": null
1399 | },
1400 | {
1401 | "name": "type",
1402 | "description": null,
1403 | "args": [],
1404 | "type": {
1405 | "kind": "NON_NULL",
1406 | "name": null,
1407 | "ofType": {
1408 | "kind": "OBJECT",
1409 | "name": "__Type",
1410 | "ofType": null
1411 | }
1412 | },
1413 | "isDeprecated": false,
1414 | "deprecationReason": null
1415 | },
1416 | {
1417 | "name": "isDeprecated",
1418 | "description": null,
1419 | "args": [],
1420 | "type": {
1421 | "kind": "NON_NULL",
1422 | "name": null,
1423 | "ofType": {
1424 | "kind": "SCALAR",
1425 | "name": "Boolean",
1426 | "ofType": null
1427 | }
1428 | },
1429 | "isDeprecated": false,
1430 | "deprecationReason": null
1431 | },
1432 | {
1433 | "name": "deprecationReason",
1434 | "description": null,
1435 | "args": [],
1436 | "type": {
1437 | "kind": "SCALAR",
1438 | "name": "String",
1439 | "ofType": null
1440 | },
1441 | "isDeprecated": false,
1442 | "deprecationReason": null
1443 | }
1444 | ],
1445 | "inputFields": null,
1446 | "interfaces": [],
1447 | "enumValues": null,
1448 | "possibleTypes": null
1449 | },
1450 | {
1451 | "kind": "OBJECT",
1452 | "name": "__InputValue",
1453 | "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.",
1454 | "fields": [
1455 | {
1456 | "name": "name",
1457 | "description": null,
1458 | "args": [],
1459 | "type": {
1460 | "kind": "NON_NULL",
1461 | "name": null,
1462 | "ofType": {
1463 | "kind": "SCALAR",
1464 | "name": "String",
1465 | "ofType": null
1466 | }
1467 | },
1468 | "isDeprecated": false,
1469 | "deprecationReason": null
1470 | },
1471 | {
1472 | "name": "description",
1473 | "description": null,
1474 | "args": [],
1475 | "type": {
1476 | "kind": "SCALAR",
1477 | "name": "String",
1478 | "ofType": null
1479 | },
1480 | "isDeprecated": false,
1481 | "deprecationReason": null
1482 | },
1483 | {
1484 | "name": "type",
1485 | "description": null,
1486 | "args": [],
1487 | "type": {
1488 | "kind": "NON_NULL",
1489 | "name": null,
1490 | "ofType": {
1491 | "kind": "OBJECT",
1492 | "name": "__Type",
1493 | "ofType": null
1494 | }
1495 | },
1496 | "isDeprecated": false,
1497 | "deprecationReason": null
1498 | },
1499 | {
1500 | "name": "defaultValue",
1501 | "description": "A GraphQL-formatted string representing the default value for this input value.",
1502 | "args": [],
1503 | "type": {
1504 | "kind": "SCALAR",
1505 | "name": "String",
1506 | "ofType": null
1507 | },
1508 | "isDeprecated": false,
1509 | "deprecationReason": null
1510 | }
1511 | ],
1512 | "inputFields": null,
1513 | "interfaces": [],
1514 | "enumValues": null,
1515 | "possibleTypes": null
1516 | },
1517 | {
1518 | "kind": "OBJECT",
1519 | "name": "__EnumValue",
1520 | "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.",
1521 | "fields": [
1522 | {
1523 | "name": "name",
1524 | "description": null,
1525 | "args": [],
1526 | "type": {
1527 | "kind": "NON_NULL",
1528 | "name": null,
1529 | "ofType": {
1530 | "kind": "SCALAR",
1531 | "name": "String",
1532 | "ofType": null
1533 | }
1534 | },
1535 | "isDeprecated": false,
1536 | "deprecationReason": null
1537 | },
1538 | {
1539 | "name": "description",
1540 | "description": null,
1541 | "args": [],
1542 | "type": {
1543 | "kind": "SCALAR",
1544 | "name": "String",
1545 | "ofType": null
1546 | },
1547 | "isDeprecated": false,
1548 | "deprecationReason": null
1549 | },
1550 | {
1551 | "name": "isDeprecated",
1552 | "description": null,
1553 | "args": [],
1554 | "type": {
1555 | "kind": "NON_NULL",
1556 | "name": null,
1557 | "ofType": {
1558 | "kind": "SCALAR",
1559 | "name": "Boolean",
1560 | "ofType": null
1561 | }
1562 | },
1563 | "isDeprecated": false,
1564 | "deprecationReason": null
1565 | },
1566 | {
1567 | "name": "deprecationReason",
1568 | "description": null,
1569 | "args": [],
1570 | "type": {
1571 | "kind": "SCALAR",
1572 | "name": "String",
1573 | "ofType": null
1574 | },
1575 | "isDeprecated": false,
1576 | "deprecationReason": null
1577 | }
1578 | ],
1579 | "inputFields": null,
1580 | "interfaces": [],
1581 | "enumValues": null,
1582 | "possibleTypes": null
1583 | },
1584 | {
1585 | "kind": "OBJECT",
1586 | "name": "__Directive",
1587 | "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.",
1588 | "fields": [
1589 | {
1590 | "name": "name",
1591 | "description": null,
1592 | "args": [],
1593 | "type": {
1594 | "kind": "NON_NULL",
1595 | "name": null,
1596 | "ofType": {
1597 | "kind": "SCALAR",
1598 | "name": "String",
1599 | "ofType": null
1600 | }
1601 | },
1602 | "isDeprecated": false,
1603 | "deprecationReason": null
1604 | },
1605 | {
1606 | "name": "description",
1607 | "description": null,
1608 | "args": [],
1609 | "type": {
1610 | "kind": "SCALAR",
1611 | "name": "String",
1612 | "ofType": null
1613 | },
1614 | "isDeprecated": false,
1615 | "deprecationReason": null
1616 | },
1617 | {
1618 | "name": "locations",
1619 | "description": null,
1620 | "args": [],
1621 | "type": {
1622 | "kind": "NON_NULL",
1623 | "name": null,
1624 | "ofType": {
1625 | "kind": "LIST",
1626 | "name": null,
1627 | "ofType": {
1628 | "kind": "NON_NULL",
1629 | "name": null,
1630 | "ofType": {
1631 | "kind": "ENUM",
1632 | "name": "__DirectiveLocation",
1633 | "ofType": null
1634 | }
1635 | }
1636 | }
1637 | },
1638 | "isDeprecated": false,
1639 | "deprecationReason": null
1640 | },
1641 | {
1642 | "name": "args",
1643 | "description": null,
1644 | "args": [],
1645 | "type": {
1646 | "kind": "NON_NULL",
1647 | "name": null,
1648 | "ofType": {
1649 | "kind": "LIST",
1650 | "name": null,
1651 | "ofType": {
1652 | "kind": "NON_NULL",
1653 | "name": null,
1654 | "ofType": {
1655 | "kind": "OBJECT",
1656 | "name": "__InputValue",
1657 | "ofType": null
1658 | }
1659 | }
1660 | }
1661 | },
1662 | "isDeprecated": false,
1663 | "deprecationReason": null
1664 | }
1665 | ],
1666 | "inputFields": null,
1667 | "interfaces": [],
1668 | "enumValues": null,
1669 | "possibleTypes": null
1670 | },
1671 | {
1672 | "kind": "ENUM",
1673 | "name": "__DirectiveLocation",
1674 | "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.",
1675 | "fields": null,
1676 | "inputFields": null,
1677 | "interfaces": null,
1678 | "enumValues": [
1679 | {
1680 | "name": "QUERY",
1681 | "description": "Location adjacent to a query operation.",
1682 | "isDeprecated": false,
1683 | "deprecationReason": null
1684 | },
1685 | {
1686 | "name": "MUTATION",
1687 | "description": "Location adjacent to a mutation operation.",
1688 | "isDeprecated": false,
1689 | "deprecationReason": null
1690 | },
1691 | {
1692 | "name": "SUBSCRIPTION",
1693 | "description": "Location adjacent to a subscription operation.",
1694 | "isDeprecated": false,
1695 | "deprecationReason": null
1696 | },
1697 | {
1698 | "name": "FIELD",
1699 | "description": "Location adjacent to a field.",
1700 | "isDeprecated": false,
1701 | "deprecationReason": null
1702 | },
1703 | {
1704 | "name": "FRAGMENT_DEFINITION",
1705 | "description": "Location adjacent to a fragment definition.",
1706 | "isDeprecated": false,
1707 | "deprecationReason": null
1708 | },
1709 | {
1710 | "name": "FRAGMENT_SPREAD",
1711 | "description": "Location adjacent to a fragment spread.",
1712 | "isDeprecated": false,
1713 | "deprecationReason": null
1714 | },
1715 | {
1716 | "name": "INLINE_FRAGMENT",
1717 | "description": "Location adjacent to an inline fragment.",
1718 | "isDeprecated": false,
1719 | "deprecationReason": null
1720 | },
1721 | {
1722 | "name": "VARIABLE_DEFINITION",
1723 | "description": "Location adjacent to a variable definition.",
1724 | "isDeprecated": false,
1725 | "deprecationReason": null
1726 | },
1727 | {
1728 | "name": "SCHEMA",
1729 | "description": "Location adjacent to a schema definition.",
1730 | "isDeprecated": false,
1731 | "deprecationReason": null
1732 | },
1733 | {
1734 | "name": "SCALAR",
1735 | "description": "Location adjacent to a scalar definition.",
1736 | "isDeprecated": false,
1737 | "deprecationReason": null
1738 | },
1739 | {
1740 | "name": "OBJECT",
1741 | "description": "Location adjacent to an object type definition.",
1742 | "isDeprecated": false,
1743 | "deprecationReason": null
1744 | },
1745 | {
1746 | "name": "FIELD_DEFINITION",
1747 | "description": "Location adjacent to a field definition.",
1748 | "isDeprecated": false,
1749 | "deprecationReason": null
1750 | },
1751 | {
1752 | "name": "ARGUMENT_DEFINITION",
1753 | "description": "Location adjacent to an argument definition.",
1754 | "isDeprecated": false,
1755 | "deprecationReason": null
1756 | },
1757 | {
1758 | "name": "INTERFACE",
1759 | "description": "Location adjacent to an interface definition.",
1760 | "isDeprecated": false,
1761 | "deprecationReason": null
1762 | },
1763 | {
1764 | "name": "UNION",
1765 | "description": "Location adjacent to a union definition.",
1766 | "isDeprecated": false,
1767 | "deprecationReason": null
1768 | },
1769 | {
1770 | "name": "ENUM",
1771 | "description": "Location adjacent to an enum definition.",
1772 | "isDeprecated": false,
1773 | "deprecationReason": null
1774 | },
1775 | {
1776 | "name": "ENUM_VALUE",
1777 | "description": "Location adjacent to an enum value definition.",
1778 | "isDeprecated": false,
1779 | "deprecationReason": null
1780 | },
1781 | {
1782 | "name": "INPUT_OBJECT",
1783 | "description": "Location adjacent to an input object type definition.",
1784 | "isDeprecated": false,
1785 | "deprecationReason": null
1786 | },
1787 | {
1788 | "name": "INPUT_FIELD_DEFINITION",
1789 | "description": "Location adjacent to an input object field definition.",
1790 | "isDeprecated": false,
1791 | "deprecationReason": null
1792 | }
1793 | ],
1794 | "possibleTypes": null
1795 | },
1796 | {
1797 | "kind": "ENUM",
1798 | "name": "CacheControlScope",
1799 | "description": "",
1800 | "fields": null,
1801 | "inputFields": null,
1802 | "interfaces": null,
1803 | "enumValues": [
1804 | {
1805 | "name": "PUBLIC",
1806 | "description": "",
1807 | "isDeprecated": false,
1808 | "deprecationReason": null
1809 | },
1810 | {
1811 | "name": "PRIVATE",
1812 | "description": "",
1813 | "isDeprecated": false,
1814 | "deprecationReason": null
1815 | }
1816 | ],
1817 | "possibleTypes": null
1818 | },
1819 | {
1820 | "kind": "SCALAR",
1821 | "name": "Upload",
1822 | "description": "The `Upload` scalar type represents a file upload.",
1823 | "fields": null,
1824 | "inputFields": null,
1825 | "interfaces": null,
1826 | "enumValues": null,
1827 | "possibleTypes": null
1828 | }
1829 | ],
1830 | "directives": [
1831 | {
1832 | "name": "cacheControl",
1833 | "description": "",
1834 | "locations": [
1835 | "FIELD_DEFINITION",
1836 | "OBJECT",
1837 | "INTERFACE"
1838 | ],
1839 | "args": [
1840 | {
1841 | "name": "maxAge",
1842 | "description": "",
1843 | "type": {
1844 | "kind": "SCALAR",
1845 | "name": "Int",
1846 | "ofType": null
1847 | },
1848 | "defaultValue": null
1849 | },
1850 | {
1851 | "name": "scope",
1852 | "description": "",
1853 | "type": {
1854 | "kind": "ENUM",
1855 | "name": "CacheControlScope",
1856 | "ofType": null
1857 | },
1858 | "defaultValue": null
1859 | }
1860 | ]
1861 | },
1862 | {
1863 | "name": "skip",
1864 | "description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
1865 | "locations": [
1866 | "FIELD",
1867 | "FRAGMENT_SPREAD",
1868 | "INLINE_FRAGMENT"
1869 | ],
1870 | "args": [
1871 | {
1872 | "name": "if",
1873 | "description": "Skipped when true.",
1874 | "type": {
1875 | "kind": "NON_NULL",
1876 | "name": null,
1877 | "ofType": {
1878 | "kind": "SCALAR",
1879 | "name": "Boolean",
1880 | "ofType": null
1881 | }
1882 | },
1883 | "defaultValue": null
1884 | }
1885 | ]
1886 | },
1887 | {
1888 | "name": "include",
1889 | "description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
1890 | "locations": [
1891 | "FIELD",
1892 | "FRAGMENT_SPREAD",
1893 | "INLINE_FRAGMENT"
1894 | ],
1895 | "args": [
1896 | {
1897 | "name": "if",
1898 | "description": "Included when true.",
1899 | "type": {
1900 | "kind": "NON_NULL",
1901 | "name": null,
1902 | "ofType": {
1903 | "kind": "SCALAR",
1904 | "name": "Boolean",
1905 | "ofType": null
1906 | }
1907 | },
1908 | "defaultValue": null
1909 | }
1910 | ]
1911 | },
1912 | {
1913 | "name": "deprecated",
1914 | "description": "Marks an element of a GraphQL schema as no longer supported.",
1915 | "locations": [
1916 | "FIELD_DEFINITION",
1917 | "ENUM_VALUE"
1918 | ],
1919 | "args": [
1920 | {
1921 | "name": "reason",
1922 | "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax (as specified by [CommonMark](https://commonmark.org/).",
1923 | "type": {
1924 | "kind": "SCALAR",
1925 | "name": "String",
1926 | "ofType": null
1927 | },
1928 | "defaultValue": "\"No longer supported\""
1929 | }
1930 | ]
1931 | }
1932 | ]
1933 | }
1934 | }
1935 | }
1936 |
--------------------------------------------------------------------------------