├── 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 | 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 | 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 |