├── .idea ├── .name ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml ├── compiler.xml ├── google-java-format.xml ├── deploymentTargetDropDown.xml ├── misc.xml └── jarRepositories.xml ├── app ├── .gitignore ├── src │ ├── main │ │ ├── ic_launcher-web.png │ │ ├── java │ │ │ └── dev │ │ │ │ └── marcosfarias │ │ │ │ └── pokedex │ │ │ │ ├── model │ │ │ │ ├── News.kt │ │ │ │ ├── Menu.kt │ │ │ │ ├── Generation.kt │ │ │ │ └── Pokemon.kt │ │ │ │ ├── di │ │ │ │ ├── AppComponent.kt │ │ │ │ ├── DatabaseModule.kt │ │ │ │ ├── ViewModelsModule.kt │ │ │ │ └── NetworkModule.kt │ │ │ │ ├── PokedexGlideModule.kt │ │ │ │ ├── repository │ │ │ │ └── PokemonService.kt │ │ │ │ ├── MainActivity.kt │ │ │ │ ├── database │ │ │ │ ├── AppDatabase.kt │ │ │ │ └── dao │ │ │ │ │ └── PokemonDAO.kt │ │ │ │ ├── App.kt │ │ │ │ ├── ui │ │ │ │ ├── dashboard │ │ │ │ │ ├── moves │ │ │ │ │ │ └── MovesFragment.kt │ │ │ │ │ ├── DashboardViewModel.kt │ │ │ │ │ ├── ViewPagerAdapter.kt │ │ │ │ │ ├── about │ │ │ │ │ │ └── AboutFragment.kt │ │ │ │ │ ├── evolution │ │ │ │ │ │ ├── EvolutionFragment.kt │ │ │ │ │ │ └── EvolutionAdapter.kt │ │ │ │ │ ├── stats │ │ │ │ │ │ └── StatsFragment.kt │ │ │ │ │ └── DashboardFragment.kt │ │ │ │ ├── search │ │ │ │ │ └── SearchFragment.kt │ │ │ │ ├── newsdetail │ │ │ │ │ └── NewsDetailFragment.kt │ │ │ │ ├── generation │ │ │ │ │ ├── GenerationViewModel.kt │ │ │ │ │ ├── GenerationAdapter.kt │ │ │ │ │ └── GenerationFragment.kt │ │ │ │ ├── pokedex │ │ │ │ │ ├── PokedexViewModel.kt │ │ │ │ │ ├── PokemonAdapter.kt │ │ │ │ │ └── PokedexFragment.kt │ │ │ │ └── home │ │ │ │ │ ├── NewsAdapter.kt │ │ │ │ │ ├── HomeViewModel.kt │ │ │ │ │ ├── MenuAdapter.kt │ │ │ │ │ └── HomeFragment.kt │ │ │ │ └── utils │ │ │ │ ├── ListStringConverter.kt │ │ │ │ ├── ImageLoadingListener.kt │ │ │ │ └── PokemonColorUtil.kt │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── gen1.png │ │ │ │ ├── gen2.png │ │ │ │ ├── gen3.png │ │ │ │ ├── gen4.png │ │ │ │ ├── gen5.png │ │ │ │ ├── gen6.png │ │ │ │ ├── gen7.png │ │ │ │ ├── gen8.png │ │ │ │ ├── map.png │ │ │ │ ├── close.png │ │ │ │ ├── filter.png │ │ │ │ ├── news1.png │ │ │ │ ├── news2.png │ │ │ │ ├── news3.png │ │ │ │ ├── news4.png │ │ │ │ ├── poke001.png │ │ │ │ ├── search.png │ │ │ │ ├── pokeball.png │ │ │ │ ├── background_search_bar.xml │ │ │ │ ├── background_item_pokemon_span.xml │ │ │ │ ├── rounded_top_border.xml │ │ │ │ ├── rounded_bottom_border_red.xml │ │ │ │ ├── rounded_bottom_border.xml │ │ │ │ ├── background_item_pokemon.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── font │ │ │ │ ├── circularstd_bold.ttf │ │ │ │ ├── circularstd_book.ttf │ │ │ │ ├── circularstd_black.ttf │ │ │ │ ├── circularstd_medium.ttf │ │ │ │ └── circularstd.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── values │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── transition │ │ │ │ └── image_shared_element_transition.xml │ │ │ ├── layout │ │ │ │ ├── fragment_moves.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_evolution.xml │ │ │ │ ├── item_menu.xml │ │ │ │ ├── fragment_generation.xml │ │ │ │ ├── fragment_search.xml │ │ │ │ ├── item_news.xml │ │ │ │ ├── item_generation.xml │ │ │ │ ├── fragment_pokedex.xml │ │ │ │ ├── item_pokemon.xml │ │ │ │ ├── fragment_news_detail.xml │ │ │ │ ├── fragment_home.xml │ │ │ │ ├── fragment_about.xml │ │ │ │ ├── fragment_dashboard.xml │ │ │ │ └── fragment_stats.xml │ │ │ ├── menu │ │ │ │ └── menu_pokedex.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── navigation │ │ │ │ └── mobile_navigation.xml │ │ └── AndroidManifest.xml │ ├── androidTest │ │ └── java │ │ │ └── dev │ │ │ └── marcosfarias │ │ │ └── pokedex │ │ │ ├── ExampleInstrumentedTest.kt │ │ │ ├── robots │ │ │ └── BaseRobot.kt │ │ │ ├── FragmentNewsDetailsTest.kt │ │ │ ├── DashboardTests.kt │ │ │ ├── PokedexTest.kt │ │ │ └── HomeTest.kt │ └── test │ │ └── java │ │ └── dev │ │ └── marcosfarias │ │ └── pokedex │ │ ├── PokedexViewModelTest.kt │ │ ├── HomeViewModelTest.kt │ │ ├── GenerationViewModelTest.kt │ │ └── DashboardViewModelTest.kt ├── proguard-rules.pro └── build.gradle.kts ├── .github ├── CODEOWNERS ├── dependabot.yml └── workflows │ └── reviewdog.yml ├── settings.gradle.kts ├── .DS_Store ├── screenshots ├── home.png ├── kotlin.png ├── pokedex.png ├── news-detail.png ├── pokedex-fab.png ├── google-play-badge.png ├── pokedex-fab-search.png ├── pokemon-info-about.png ├── pokedex-fab-generation.png ├── pokemon-info-base-stats.png └── pokemon-info-evolution.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── pre-commit ├── install-git-hook.gradle ├── gradle.properties ├── contributing.md ├── ktlint.gradle.kts ├── LICENSE ├── .gitignore ├── gradlew.bat ├── README.md └── gradlew /.idea/.name: -------------------------------------------------------------------------------- 1 | Pokedex -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @mrcsxsiq 2 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | include(":app") 2 | rootProject.name="Pokedex" 3 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/.DS_Store -------------------------------------------------------------------------------- /screenshots/home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/home.png -------------------------------------------------------------------------------- /screenshots/kotlin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/kotlin.png -------------------------------------------------------------------------------- /screenshots/pokedex.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokedex.png -------------------------------------------------------------------------------- /screenshots/news-detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/news-detail.png -------------------------------------------------------------------------------- /screenshots/pokedex-fab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokedex-fab.png -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/model/News.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.model 2 | 3 | class News 4 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen4.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen5.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen6.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen7.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/gen8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/gen8.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/map.png -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /screenshots/google-play-badge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/google-play-badge.png -------------------------------------------------------------------------------- /screenshots/pokedex-fab-search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokedex-fab-search.png -------------------------------------------------------------------------------- /screenshots/pokemon-info-about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokemon-info-about.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/close.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/filter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/filter.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/news1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/news1.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/news2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/news2.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/news3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/news3.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/news4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/news4.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/poke001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/poke001.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/pokeball.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/drawable/pokeball.png -------------------------------------------------------------------------------- /screenshots/pokedex-fab-generation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokedex-fab-generation.png -------------------------------------------------------------------------------- /screenshots/pokemon-info-base-stats.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokemon-info-base-stats.png -------------------------------------------------------------------------------- /screenshots/pokemon-info-evolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/screenshots/pokemon-info-evolution.png -------------------------------------------------------------------------------- /app/src/main/res/font/circularstd_bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/font/circularstd_bold.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/circularstd_book.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/font/circularstd_book.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/circularstd_black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/font/circularstd_black.ttf -------------------------------------------------------------------------------- /app/src/main/res/font/circularstd_medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/font/circularstd_medium.ttf -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/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/mrcsxsiq/Kotlin-Pokedex/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/mrcsxsiq/Kotlin-Pokedex/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/mrcsxsiq/Kotlin-Pokedex/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/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mrcsxsiq/Kotlin-Pokedex/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /app/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "gradle" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | open-pull-requests-limit: 15 8 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/di/AppComponent.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.di 2 | 3 | val appComponent = listOf( 4 | databaseModule, 5 | networkModule, 6 | viewModelsModule 7 | ) 8 | -------------------------------------------------------------------------------- /.idea/google-java-format.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Running git pre-commit hook" 4 | 5 | ./gradlew ktlintFormat 6 | 7 | RESULT=$? 8 | 9 | # return 1 exit code if running checks fails 10 | [ $RESULT -ne 0 ] && exit 1 11 | exit 0 12 | -------------------------------------------------------------------------------- /install-git-hook.gradle: -------------------------------------------------------------------------------- 1 | task installGitHook(type: Copy) { 2 | from new File(rootProject.rootDir, 'pre-commit') 3 | into { new File(rootProject.rootDir, '.git/hooks') } 4 | fileMode 0777 5 | } 6 | preBuild.dependsOn installGitHook -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | org.gradle.jvmargs=-Xmx1536m 3 | android.databinding.incremental=true 4 | android.useAndroidX=true 5 | android.enableJetifier=true 6 | kotlin.code.style=official 7 | kapt.incremental.apt=true 8 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/PokedexGlideModule.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex 2 | 3 | import com.bumptech.glide.annotation.GlideModule 4 | import com.bumptech.glide.module.AppGlideModule 5 | 6 | @GlideModule 7 | class PokedexGlideModule : AppGlideModule() { 8 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 14 20:43:47 WIB 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/model/Menu.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.model 2 | 3 | import androidx.annotation.ColorRes 4 | import androidx.annotation.StringRes 5 | 6 | data class Menu( 7 | val id: Int, 8 | @StringRes val name: Int, 9 | @ColorRes val color: Int 10 | ) 11 | -------------------------------------------------------------------------------- /app/src/main/res/font/circularstd.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /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/dev/marcosfarias/pokedex/repository/PokemonService.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.repository 2 | 3 | import dev.marcosfarias.pokedex.model.Pokemon 4 | import retrofit2.Call 5 | import retrofit2.http.GET 6 | 7 | interface PokemonService { 8 | @GET("pokemon.json") 9 | fun get(): Call> 10 | } 11 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/model/Generation.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.model 2 | 3 | import androidx.annotation.DrawableRes 4 | import androidx.annotation.StringRes 5 | 6 | class Generation( 7 | val id: Int, 8 | @StringRes val title: Int, 9 | @DrawableRes val image: Int 10 | ) { 11 | override fun toString() = "$id$title$image" 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_search_bar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_item_pokemon_span.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 180dp 6 | 16dp 7 | 16dp 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | 6 | class MainActivity : AppCompatActivity() { 7 | 8 | override fun onCreate(savedInstanceState: Bundle?) { 9 | super.onCreate(savedInstanceState) 10 | setContentView(R.layout.activity_main) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/transition/image_shared_element_transition.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/database/AppDatabase.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.database 2 | 3 | import androidx.room.Database 4 | import androidx.room.RoomDatabase 5 | import dev.marcosfarias.pokedex.database.dao.PokemonDAO 6 | import dev.marcosfarias.pokedex.model.Pokemon 7 | 8 | @Database(entities = [Pokemon::class], version = 5, exportSchema = false) 9 | abstract class AppDatabase : RoomDatabase() { 10 | 11 | abstract fun pokemonDAO(): PokemonDAO 12 | } 13 | -------------------------------------------------------------------------------- /.github/workflows/reviewdog.yml: -------------------------------------------------------------------------------- 1 | name: reviewdog 2 | on: [pull_request] 3 | jobs: 4 | ktlint: 5 | name: Check Code Quality 6 | runs-on: ubuntu-latest 7 | 8 | steps: 9 | - name: Clone repo 10 | uses: actions/checkout@master 11 | with: 12 | fetch-depth: 1 13 | - name: ktlint 14 | uses: ScaCap/action-ktlint@master 15 | with: 16 | github_token: ${{ secrets.GITHUB_TOKEN }} 17 | reporter: github-pr-review 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_top_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/App.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex 2 | 3 | import android.app.Application 4 | import dev.marcosfarias.pokedex.di.appComponent 5 | import org.koin.android.ext.koin.androidContext 6 | import org.koin.core.context.startKoin 7 | 8 | class App : Application() { 9 | 10 | override fun onCreate() { 11 | super.onCreate() 12 | configureDI() 13 | } 14 | 15 | private fun configureDI() = startKoin { 16 | androidContext(this@App) 17 | modules(appComponent) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing Guide 2 | 3 | ## How to contribute 4 | 5 | - Fork the project from the `master` branch and submit a Pull Request (PR) 6 | 7 | - Explain what the PR fixes or improves. 8 | 9 | - If your PR aims to add a new resource to list, provide the address of the resource. 10 | 11 | 12 | 13 | - Use sensible commit messages 14 | 15 | - If your PR fixes a separate issue number, include it in the commit message. 16 | 17 | 18 | 19 | - Use a sensible number of commit messages as well 20 | 21 | - e.g. Your PR should not have 1000s of commits. -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_moves.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | -------------------------------------------------------------------------------- /.idea/deploymentTargetDropDown.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_pokedex.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 13 | 14 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/moves/MovesFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.dashboard.moves 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import dev.marcosfarias.pokedex.R 9 | 10 | class MovesFragment : Fragment() { 11 | 12 | override fun onCreateView( 13 | inflater: LayoutInflater, 14 | container: ViewGroup?, 15 | savedInstanceState: Bundle? 16 | ): View? { 17 | return inflater.inflate(R.layout.fragment_moves, container, false) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_bottom_border_red.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/di/DatabaseModule.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.di 2 | 3 | import androidx.room.Room 4 | import dev.marcosfarias.pokedex.R 5 | import dev.marcosfarias.pokedex.database.AppDatabase 6 | import org.koin.android.ext.koin.androidApplication 7 | import org.koin.dsl.module 8 | 9 | val databaseModule = module { 10 | single { 11 | Room.databaseBuilder( 12 | androidApplication(), 13 | AppDatabase::class.java, 14 | androidApplication().baseContext.getString(R.string.app_name) 15 | ).build() 16 | } 17 | 18 | single { 19 | get().pokemonDAO() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/di/ViewModelsModule.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.di 2 | 3 | import dev.marcosfarias.pokedex.ui.dashboard.DashboardViewModel 4 | import dev.marcosfarias.pokedex.ui.generation.GenerationViewModel 5 | import dev.marcosfarias.pokedex.ui.home.HomeViewModel 6 | import dev.marcosfarias.pokedex.ui.pokedex.PokedexViewModel 7 | import org.koin.androidx.viewmodel.dsl.viewModel 8 | import org.koin.dsl.module 9 | 10 | val viewModelsModule = module { 11 | viewModel { DashboardViewModel(get()) } 12 | viewModel { GenerationViewModel() } 13 | viewModel { HomeViewModel() } 14 | viewModel { PokedexViewModel(get(), get()) } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/DashboardViewModel.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.dashboard 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.ViewModel 5 | import dev.marcosfarias.pokedex.database.dao.PokemonDAO 6 | import dev.marcosfarias.pokedex.model.Pokemon 7 | 8 | class DashboardViewModel(private val pokemonDAO: PokemonDAO) : ViewModel() { 9 | 10 | fun getPokemonById(id: String?): LiveData { 11 | return pokemonDAO.getById(id) 12 | } 13 | 14 | fun getPokemonEvolutionsByIds(ids: List): LiveData> { 15 | return pokemonDAO.getEvolutionsByIds(ids) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/rounded_bottom_border.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_item_pokemon.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/search/SearchFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.search 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 8 | import dev.marcosfarias.pokedex.R 9 | 10 | class SearchFragment : BottomSheetDialogFragment() { 11 | 12 | override fun onCreateView( 13 | inflater: LayoutInflater, 14 | container: ViewGroup?, 15 | savedInstanceState: Bundle? 16 | ): View? { 17 | return inflater.inflate(R.layout.fragment_search, container, false) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/utils/ListStringConverter.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.utils 2 | 3 | import androidx.room.TypeConverter 4 | import com.google.gson.Gson 5 | import com.google.gson.reflect.TypeToken 6 | import java.lang.reflect.Type 7 | 8 | class ListStringConverter { 9 | private val gson = Gson() 10 | private val type: Type = object : TypeToken>() {}.type 11 | 12 | @TypeConverter 13 | fun fromString(json: String?): List { 14 | return gson.fromJson(json, type) 15 | } 16 | 17 | @TypeConverter 18 | fun fromList(list: List?): String { 19 | return gson.toJson(list, type) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/di/NetworkModule.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.di 2 | 3 | import dev.marcosfarias.pokedex.repository.PokemonService 4 | import org.koin.dsl.module 5 | import retrofit2.Retrofit 6 | import retrofit2.converter.gson.GsonConverterFactory 7 | import retrofit2.create 8 | 9 | val networkModule = module { 10 | single { 11 | Retrofit.Builder() 12 | .baseUrl("https://gist.githubusercontent.com/mrcsxsiq/b94dbe9ab67147b642baa9109ce16e44/raw/97811a5df2df7304b5bc4fbb9ee018a0339b8a38/") 13 | .addConverterFactory(GsonConverterFactory.create()) 14 | .build() 15 | } 16 | 17 | single { 18 | get().create() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/dev/marcosfarias/pokedex/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex 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("dev.marcosfarias.pokedex", 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.kts. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /ktlint.gradle.kts: -------------------------------------------------------------------------------- 1 | val ktlint: Configuration by configurations.creating 2 | 3 | dependencies { 4 | ktlint("com.pinterest:ktlint:0.42.1") 5 | // additional 3rd party ruleset(s) can be specified here 6 | // just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and 7 | // ktlint will pick them up 8 | } 9 | 10 | tasks.register("ktlint") { 11 | group = "verification" 12 | description = "Check Kotlin code style." 13 | classpath = ktlint 14 | main = "com.pinterest.ktlint.Main" 15 | args("src/**/*.kt") 16 | } 17 | 18 | tasks.named("check") { 19 | dependsOn(ktlint) 20 | } 21 | 22 | tasks.register("ktlintFormat") { 23 | group = "formatting" 24 | description = "Fix Kotlin code style deviations." 25 | classpath = ktlint 26 | main = "com.pinterest.ktlint.Main" 27 | args("-F", "src/**/*.kt") 28 | } -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 19 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/newsdetail/NewsDetailFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.newsdetail 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import dev.marcosfarias.pokedex.R 9 | import dev.marcosfarias.pokedex.utils.PokemonColorUtil 10 | 11 | class NewsDetailFragment : Fragment() { 12 | 13 | override fun onCreateView( 14 | inflater: LayoutInflater, 15 | container: ViewGroup?, 16 | savedInstanceState: Bundle? 17 | ): View? { 18 | return inflater.inflate(R.layout.fragment_news_detail, container, false) 19 | } 20 | 21 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 22 | super.onViewCreated(view, savedInstanceState) 23 | activity?.window?.statusBarColor = 24 | PokemonColorUtil(view.context).convertColor(R.color.white) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/database/dao/PokemonDAO.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.database.dao 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.room.Dao 5 | import androidx.room.Delete 6 | import androidx.room.Insert 7 | import androidx.room.OnConflictStrategy 8 | import androidx.room.Query 9 | import dev.marcosfarias.pokedex.model.Pokemon 10 | 11 | @Dao 12 | interface PokemonDAO { 13 | 14 | @Query("SELECT * FROM pokemon WHERE id = :id") 15 | fun getById(id: String?): LiveData 16 | 17 | @Query("SELECT * FROM pokemon WHERE id IN(:evolutionIds)") 18 | fun getEvolutionsByIds(evolutionIds: List): LiveData> 19 | 20 | @Query("SELECT * FROM pokemon") 21 | fun all(): LiveData> 22 | 23 | @Insert(onConflict = OnConflictStrategy.REPLACE) 24 | fun add(pokemon: List) 25 | 26 | @Query("DELETE FROM pokemon") 27 | fun deleteAll() 28 | 29 | @Delete 30 | fun delete(model: Pokemon) 31 | } 32 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_evolution.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 15 | 16 | 22 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/utils/ImageLoadingListener.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.utils 2 | 3 | import android.graphics.drawable.Drawable 4 | import com.bumptech.glide.load.DataSource 5 | import com.bumptech.glide.load.engine.GlideException 6 | import com.bumptech.glide.request.RequestListener 7 | import com.bumptech.glide.request.target.Target 8 | 9 | class ImageLoadingListener(private val listener: OnLoadFinishedListener) : 10 | RequestListener { 11 | override fun onLoadFailed( 12 | e: GlideException?, 13 | model: Any?, 14 | target: Target?, 15 | isFirstResource: Boolean 16 | ): Boolean { 17 | listener.invoke() 18 | return false 19 | } 20 | 21 | override fun onResourceReady( 22 | resource: Drawable?, 23 | model: Any?, 24 | target: Target?, 25 | dataSource: DataSource?, 26 | isFirstResource: Boolean 27 | ): Boolean { 28 | listener.invoke() 29 | return false 30 | } 31 | } 32 | 33 | typealias OnLoadFinishedListener = () -> Unit 34 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Marcos Paulo Farias 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/utils/PokemonColorUtil.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.utils 2 | 3 | import android.content.Context 4 | import androidx.annotation.ColorInt 5 | import androidx.annotation.ColorRes 6 | import androidx.core.content.ContextCompat 7 | import dev.marcosfarias.pokedex.R 8 | import java.util.Locale 9 | 10 | class PokemonColorUtil(var context: Context) { 11 | 12 | @ColorInt 13 | fun getPokemonColor(typeOfPokemon: List?): Int { 14 | val type = typeOfPokemon?.getOrNull(0) 15 | val color = when (type?.toLowerCase(Locale.ROOT)) { 16 | "grass", "bug" -> R.color.lightTeal 17 | "fire" -> R.color.lightRed 18 | "water", "fighting", "normal" -> R.color.lightBlue 19 | "electric", "psychic" -> R.color.lightYellow 20 | "poison", "ghost" -> R.color.lightPurple 21 | "ground", "rock" -> R.color.lightBrown 22 | "dark" -> R.color.black 23 | else -> R.color.lightBlue 24 | } 25 | return convertColor(color) 26 | } 27 | 28 | @ColorInt 29 | fun convertColor(@ColorRes color: Int): Int { 30 | return ContextCompat.getColor(context, color) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | @color/backgroundLight 4 | #00574B 5 | @color/red 6 | 7 | #E8E8E8 8 | #F5F5F5 9 | #FFFFFF 10 | 11 | #303943 12 | #429BED 13 | #B1736C 14 | #303943 15 | #6C79DB 16 | #58ABF6 17 | #CA8179 18 | #F4F5F4 19 | #F5F5F5 20 | #9F5BBA 21 | #F7786B 22 | #2CDAB1 23 | #FFCE4B 24 | #7C538C 25 | #FA6555 26 | #4FC1A6 27 | #F6C747 28 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationViewModel.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.generation 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import dev.marcosfarias.pokedex.R 7 | import dev.marcosfarias.pokedex.model.Generation 8 | 9 | class GenerationViewModel : ViewModel() { 10 | 11 | private val listGeneration = MutableLiveData>() 12 | 13 | fun getListGeneration(): LiveData> { 14 | listGeneration.value = listOf( 15 | Generation(id = 1, title = R.string.generation_item_1, image = R.drawable.gen1), 16 | Generation(id = 1, title = R.string.generation_item_2, image = R.drawable.gen2), 17 | Generation(id = 1, title = R.string.generation_item_3, image = R.drawable.gen3), 18 | Generation(id = 1, title = R.string.generation_item_4, image = R.drawable.gen4), 19 | Generation(id = 1, title = R.string.generation_item_5, image = R.drawable.gen5), 20 | Generation(id = 1, title = R.string.generation_item_6, image = R.drawable.gen6), 21 | Generation(id = 1, title = R.string.generation_item_7, image = R.drawable.gen7), 22 | Generation(id = 1, title = R.string.generation_item_8, image = R.drawable.gen8) 23 | ) 24 | return listGeneration 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/pokedex/PokedexViewModel.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.pokedex 2 | 3 | import androidx.lifecycle.ViewModel 4 | import dev.marcosfarias.pokedex.database.dao.PokemonDAO 5 | import dev.marcosfarias.pokedex.model.Pokemon 6 | import dev.marcosfarias.pokedex.repository.PokemonService 7 | import retrofit2.Call 8 | import retrofit2.Callback 9 | import retrofit2.Response 10 | import kotlin.concurrent.thread 11 | 12 | class PokedexViewModel( 13 | private val pokemonDAO: PokemonDAO, 14 | private val pokemonService: PokemonService 15 | ) : ViewModel() { 16 | 17 | init { 18 | initNetworkRequest() 19 | } 20 | 21 | private fun initNetworkRequest() { 22 | val call = pokemonService.get() 23 | 24 | call.enqueue(object : Callback?> { 25 | override fun onResponse( 26 | call: Call?>?, 27 | response: Response?>? 28 | ) { 29 | response?.body()?.let { pokemons: List -> 30 | thread { 31 | pokemonDAO.add(pokemons) 32 | } 33 | } 34 | } 35 | 36 | override fun onFailure(call: Call?>?, t: Throwable?) { 37 | // TODO handle failure 38 | } 39 | }) 40 | } 41 | 42 | fun getListPokemon() = pokemonDAO.all() 43 | } 44 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/model/Pokemon.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.model 2 | 3 | import androidx.annotation.NonNull 4 | import androidx.room.Entity 5 | import androidx.room.PrimaryKey 6 | import androidx.room.TypeConverters 7 | import dev.marcosfarias.pokedex.utils.ListStringConverter 8 | 9 | @Entity 10 | @TypeConverters(ListStringConverter::class) 11 | data class Pokemon( 12 | @PrimaryKey 13 | @NonNull 14 | var id: String = "", 15 | var abilities: List? = null, 16 | var attack: Int? = null, 17 | var base_exp: String? = null, 18 | var category: String? = null, 19 | var cycles: String? = null, 20 | var defense: Int? = null, 21 | var egg_groups: String? = null, 22 | var evolutions: List? = null, 23 | var evolvedfrom: String? = null, 24 | var female_percentage: String? = null, 25 | var genderless: Int? = null, 26 | var height: String? = null, 27 | var hp: Int? = null, 28 | var imageurl: String? = null, 29 | var male_percentage: String? = null, 30 | var name: String? = null, 31 | var reason: String? = null, 32 | var special_attack: Int? = null, 33 | var special_defense: Int? = null, 34 | var speed: Int? = null, 35 | var total: Int? = null, 36 | var typeofpokemon: List? = null, 37 | var weaknesses: List? = null, 38 | var weight: String? = null, 39 | var xdescription: String? = null, 40 | var ydescription: String? = null 41 | ) -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/home/NewsAdapter.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.home 2 | 3 | import android.content.Context 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.navigation.findNavController 8 | import androidx.recyclerview.widget.RecyclerView 9 | import dev.marcosfarias.pokedex.R 10 | import dev.marcosfarias.pokedex.model.News 11 | 12 | class NewsAdapter( 13 | private val list: List, 14 | private val context: Context 15 | ) : RecyclerView.Adapter() { 16 | 17 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 18 | fun bindView(item: News) { 19 | // itemView.textViewName.text = item.title 20 | itemView.setOnClickListener { 21 | it.findNavController() 22 | .navigate(R.id.action_navigation_home_to_navigation_news_detail) 23 | } 24 | } 25 | } 26 | 27 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { 28 | val view = LayoutInflater.from(context).inflate(R.layout.item_news, parent, false) 29 | return ViewHolder(view) 30 | } 31 | 32 | override fun onBindViewHolder(holder: ViewHolder, position: Int) { 33 | val item = list[position] 34 | holder.bindView(item) 35 | } 36 | 37 | override fun getItemCount(): Int { 38 | return list.size 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/home/HomeViewModel.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.home 2 | 3 | import androidx.lifecycle.LiveData 4 | import androidx.lifecycle.MutableLiveData 5 | import androidx.lifecycle.ViewModel 6 | import dev.marcosfarias.pokedex.R 7 | import dev.marcosfarias.pokedex.model.Menu 8 | import dev.marcosfarias.pokedex.model.News 9 | 10 | class HomeViewModel : ViewModel() { 11 | 12 | private val listMenu = MutableLiveData>() 13 | private val listNews = MutableLiveData>() 14 | 15 | fun getListMenu(): LiveData> { 16 | listMenu.value = listOf( 17 | Menu(id = 1, name = R.string.menu_item_1, color = R.color.lightTeal), 18 | Menu(id = 1, name = R.string.menu_item_2, color = R.color.lightRed), 19 | Menu(id = 1, name = R.string.menu_item_3, color = R.color.lightBlue), 20 | Menu(id = 1, name = R.string.menu_item_4, color = R.color.lightYellow), 21 | Menu(id = 1, name = R.string.menu_item_5, color = R.color.lightPurple), 22 | Menu(id = 1, name = R.string.menu_item_6, color = R.color.lightBrown) 23 | ) 24 | return listMenu 25 | } 26 | 27 | fun getListNews(): LiveData> { 28 | listNews.value = listOf( 29 | News(), 30 | News(), 31 | News(), 32 | News(), 33 | News(), 34 | News(), 35 | News(), 36 | News() 37 | ) 38 | return listNews 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationAdapter.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.generation 2 | 3 | import android.content.Context 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.recyclerview.widget.RecyclerView 8 | import dev.marcosfarias.pokedex.R 9 | import dev.marcosfarias.pokedex.databinding.ItemGenerationBinding 10 | import dev.marcosfarias.pokedex.model.Generation 11 | 12 | class GenerationAdapter( 13 | private val list: List, 14 | private val context: Context 15 | ) : RecyclerView.Adapter() { 16 | 17 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 18 | private val viewBinding = ItemGenerationBinding.bind(itemView) 19 | fun bindView(item: Generation) { 20 | viewBinding.textViewTitle.text = itemView.context.getString(item.title) 21 | viewBinding.imageView.setImageResource(item.image) 22 | } 23 | } 24 | 25 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { 26 | val inflater = LayoutInflater.from(context) 27 | val view = inflater.inflate(R.layout.item_generation, parent, false) 28 | return ViewHolder(view) 29 | } 30 | 31 | override fun onBindViewHolder(holder: ViewHolder, position: Int) { 32 | val item = list[position] 33 | holder.bindView(item) 34 | } 35 | 36 | override fun getItemCount(): Int { 37 | return list.size 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 28 | 29 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/androidTest/java/dev/marcosfarias/pokedex/robots/BaseRobot.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.robots 2 | 3 | import androidx.recyclerview.widget.RecyclerView 4 | import androidx.test.espresso.Espresso.onView 5 | import androidx.test.espresso.ViewInteraction 6 | import androidx.test.espresso.action.ViewActions.click 7 | import androidx.test.espresso.assertion.ViewAssertions 8 | import androidx.test.espresso.contrib.RecyclerViewActions 9 | import androidx.test.espresso.matcher.ViewMatchers 10 | import androidx.test.espresso.matcher.ViewMatchers.* 11 | import dev.marcosfarias.pokedex.R 12 | 13 | open class BaseRobot { 14 | 15 | fun testViewText(id: Int, text: String): ViewInteraction = 16 | onView(withId(id)) 17 | .check(ViewAssertions.matches(withText(text))) 18 | 19 | // Click for View with type Button 20 | fun onClick(id: Int): ViewInteraction = onView( 21 | withId(id) 22 | ).perform( 23 | click() 24 | ) 25 | 26 | // Click for RecyclerView 27 | fun onClickItem(recyclerViewId: Int): ViewInteraction = onView( 28 | withId(recyclerViewId) 29 | ).perform( 30 | RecyclerViewActions.actionOnItemAtPosition(0, click()) 31 | ) 32 | 33 | fun isViewDisplayed(viewId: Int): ViewInteraction = 34 | onView(withId(viewId)).check(ViewAssertions.matches(isDisplayed())) 35 | 36 | fun isRecyclerViewItemDisplayed(viewId: Int, text: String): ViewInteraction = 37 | onView(withId(viewId)).perform( 38 | RecyclerViewActions.actionOnItem( 39 | hasDescendant( 40 | withText(text) 41 | ), 42 | click() 43 | ) 44 | ) 45 | } -------------------------------------------------------------------------------- /app/src/test/java/dev/marcosfarias/pokedex/PokedexViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex 2 | 3 | import androidx.arch.core.executor.testing.InstantTaskExecutorRule 4 | import androidx.lifecycle.MutableLiveData 5 | import dev.marcosfarias.pokedex.database.dao.PokemonDAO 6 | import dev.marcosfarias.pokedex.model.Pokemon 7 | import dev.marcosfarias.pokedex.repository.PokemonService 8 | import dev.marcosfarias.pokedex.ui.pokedex.PokedexViewModel 9 | import io.mockk.* 10 | import org.junit.* 11 | 12 | class PokedexViewModelTest { 13 | 14 | @get:Rule 15 | val instantExecutorRule = InstantTaskExecutorRule() 16 | 17 | private val dao: PokemonDAO = mockk(relaxed = true) 18 | private val service: PokemonService = mockk(relaxed = true) 19 | private lateinit var viewModel: PokedexViewModel 20 | 21 | @Before 22 | fun before() { 23 | viewModel = PokedexViewModel(dao, service) 24 | } 25 | 26 | @Test 27 | fun `GIVEN service WHEN call service THEN check if is called once at viewmodel initialization`() { 28 | verify(exactly = 1) { service.get() } 29 | } 30 | 31 | @Test 32 | fun `GIVEN mocked dao results WHEN get list of pokemons from view model THEN result as expected`() { 33 | // GIVEN 34 | val expected = listOf( 35 | Pokemon().apply { name = "Psyduck" }, 36 | Pokemon().apply { name = "Onyx" } 37 | ) 38 | every { dao.all() } returns MutableLiveData(expected) 39 | 40 | // WHEN 41 | val result = viewModel.getListPokemon() 42 | 43 | // THEN 44 | Assert.assertEquals(expected, result.value!!) 45 | } 46 | 47 | companion object { 48 | @JvmStatic 49 | @AfterClass 50 | fun tearDown() { 51 | unmockkAll() 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_generation.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 22 | 23 | 30 | 31 | 32 | 33 | 45 | 46 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/generation/GenerationFragment.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.generation 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.lifecycle.Observer 8 | import androidx.recyclerview.widget.GridLayoutManager 9 | import com.google.android.material.bottomsheet.BottomSheetDialogFragment 10 | import dev.marcosfarias.pokedex.R 11 | import dev.marcosfarias.pokedex.databinding.FragmentGenerationBinding 12 | import dev.marcosfarias.pokedex.model.Generation 13 | import org.koin.androidx.viewmodel.ext.android.viewModel 14 | 15 | class GenerationFragment : BottomSheetDialogFragment() { 16 | 17 | private val generationViewModel: GenerationViewModel by viewModel() 18 | 19 | private var viewBinding: FragmentGenerationBinding? = null 20 | 21 | override fun onCreateView( 22 | inflater: LayoutInflater, 23 | container: ViewGroup?, 24 | savedInstanceState: Bundle? 25 | ): View? { 26 | return inflater.inflate(R.layout.fragment_generation, container, false) 27 | } 28 | 29 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 30 | super.onViewCreated(view, savedInstanceState) 31 | viewBinding = FragmentGenerationBinding.bind(view) 32 | 33 | val layoutManager = GridLayoutManager(context, 2) 34 | viewBinding?.recyclerView?.layoutManager = layoutManager 35 | 36 | generationViewModel.getListGeneration().observe(viewLifecycleOwner, Observer { 37 | val pokemons: List = it 38 | viewBinding?.recyclerView?.adapter = GenerationAdapter(pokemons, view.context) 39 | }) 40 | } 41 | 42 | override fun onDestroyView() { 43 | viewBinding = null 44 | super.onDestroyView() 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 22 | 23 | 31 | 32 | 37 | 38 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.aar 4 | *.ap_ 5 | *.aab 6 | 7 | # Files for the ART/Dalvik VM 8 | *.dex 9 | 10 | # Java class files 11 | *.class 12 | 13 | # Generated files 14 | bin/ 15 | gen/ 16 | out/ 17 | # Uncomment the following line in case you need and you don't have the release build type files in your app 18 | # release/ 19 | 20 | # Gradle files 21 | .gradle/ 22 | build/ 23 | 24 | # Local configuration file (sdk path, etc) 25 | local.properties 26 | 27 | # Proguard folder generated by Eclipse 28 | proguard/ 29 | 30 | # Log Files 31 | *.log 32 | 33 | # Android Studio Navigation editor temp files 34 | .navigation/ 35 | 36 | # Android Studio captures folder 37 | captures/ 38 | 39 | # IntelliJ 40 | *.iml 41 | .idea/workspace.xml 42 | .idea/tasks.xml 43 | .idea/gradle.xml 44 | .idea/assetWizardSettings.xml 45 | .idea/dictionaries 46 | .idea/libraries 47 | # Android Studio 3 in .gitignore file. 48 | .idea/caches 49 | .idea/modules.xml 50 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 51 | .idea/navEditor.xml 52 | .idea/codeStyles/Project.xml 53 | .idea/codeStyles/codeStyleConfig.xml 54 | .idea/misc.xml 55 | .idea/runConfigurations.xml 56 | 57 | # Keystore files 58 | # Uncomment the following lines if you do not want to check your keystore files in. 59 | #*.jks 60 | #*.keystore 61 | 62 | # External native build folder generated in Android Studio 2.2 and later 63 | .externalNativeBuild 64 | .cxx/ 65 | 66 | # Google Services (e.g. APIs or Firebase) 67 | # google-services.json 68 | 69 | # Freeline 70 | freeline.py 71 | freeline/ 72 | freeline_project_description.json 73 | 74 | # fastlane 75 | fastlane/report.xml 76 | fastlane/Preview.html 77 | fastlane/screenshots 78 | fastlane/test_output 79 | fastlane/readme.md 80 | 81 | # Version control 82 | vcs.xml 83 | 84 | # lint 85 | lint/intermediates/ 86 | lint/generated/ 87 | lint/outputs/ 88 | lint/tmp/ 89 | # lint/reports/ 90 | -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/dashboard/ViewPagerAdapter.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.dashboard 2 | 3 | import android.content.Context 4 | import androidx.fragment.app.Fragment 5 | import androidx.fragment.app.FragmentManager 6 | import androidx.fragment.app.FragmentStatePagerAdapter 7 | import dev.marcosfarias.pokedex.R 8 | import dev.marcosfarias.pokedex.ui.dashboard.about.AboutFragment 9 | import dev.marcosfarias.pokedex.ui.dashboard.evolution.EvolutionFragment 10 | import dev.marcosfarias.pokedex.ui.dashboard.moves.MovesFragment 11 | import dev.marcosfarias.pokedex.ui.dashboard.stats.StatsFragment 12 | 13 | class ViewPagerAdapter( 14 | supportFragmentManager: FragmentManager, 15 | context: Context, 16 | private val pokemonId: String 17 | ) : FragmentStatePagerAdapter(supportFragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { 18 | 19 | data class Page(val title: String, val ctor: () -> Fragment) 20 | 21 | @Suppress("MoveLambdaOutsideParentheses") 22 | private val pages = listOf( 23 | Page( 24 | context.getString(R.string.dashboard_tab_1), 25 | { AboutFragment.newInstance(pokemonId) } 26 | ), 27 | Page( 28 | context.getString(R.string.dashboard_tab_2), 29 | { StatsFragment.newInstance(pokemonId) } 30 | ), 31 | Page( 32 | context.getString(R.string.dashboard_tab_3), 33 | { EvolutionFragment.newInstance(pokemonId) } 34 | ), 35 | Page( 36 | context.getString(R.string.dashboard_tab_4), 37 | { MovesFragment() } 38 | ) 39 | ) 40 | 41 | override fun getItem(position: Int): Fragment { 42 | return pages[position].ctor() 43 | } 44 | 45 | override fun getCount(): Int { 46 | return pages.size 47 | } 48 | 49 | override fun getPageTitle(position: Int): CharSequence? { 50 | return pages[position].title 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/androidTest/java/dev/marcosfarias/pokedex/FragmentNewsDetailsTest.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex 2 | 3 | import android.content.res.Resources 4 | import androidx.fragment.app.testing.launchFragmentInContainer 5 | import androidx.navigation.Navigation 6 | import androidx.navigation.testing.TestNavHostController 7 | import androidx.test.core.app.ApplicationProvider 8 | import androidx.test.platform.app.InstrumentationRegistry 9 | import dev.marcosfarias.pokedex.robots.BaseRobot 10 | import dev.marcosfarias.pokedex.ui.newsdetail.NewsDetailFragment 11 | import org.junit.Before 12 | import org.junit.Test 13 | 14 | class FragmentNewsDetailsTest: BaseRobot() { 15 | 16 | lateinit var navHost: TestNavHostController 17 | 18 | private val resources: Resources by lazy { 19 | InstrumentationRegistry.getInstrumentation().targetContext.resources 20 | } 21 | 22 | @Before 23 | fun setup() { 24 | // Create a TestNavHostController 25 | navHost = TestNavHostController(ApplicationProvider.getApplicationContext()) 26 | launchFragmentInContainer(themeResId = R.style.AppTheme) { 27 | NewsDetailFragment().also { fragment -> 28 | // In addition to returning a new instance of our Fragment, // get a callback whenever the fragment’s view is created // or destroyed so that we can set the NavController 29 | fragment.viewLifecycleOwnerLiveData.observeForever { viewLifecycleOwner -> 30 | if (viewLifecycleOwner != null) { 31 | // The fragment’s view has just been created 32 | navHost.setGraph(R.navigation.mobile_navigation) 33 | Navigation.setViewNavController(fragment.requireView(), navHost) 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | @Test 41 | fun verifyIfTitleTextIsDisplayed() { 42 | isViewDisplayed(R.id.txtNewsTitle) 43 | } 44 | 45 | } -------------------------------------------------------------------------------- /app/src/main/java/dev/marcosfarias/pokedex/ui/home/MenuAdapter.kt: -------------------------------------------------------------------------------- 1 | package dev.marcosfarias.pokedex.ui.home 2 | 3 | import android.content.Context 4 | import android.graphics.PorterDuff 5 | import android.graphics.PorterDuffColorFilter 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import androidx.navigation.findNavController 10 | import androidx.recyclerview.widget.RecyclerView 11 | import dev.marcosfarias.pokedex.R 12 | import dev.marcosfarias.pokedex.databinding.ItemMenuBinding 13 | import dev.marcosfarias.pokedex.model.Menu 14 | import dev.marcosfarias.pokedex.utils.PokemonColorUtil 15 | 16 | class MenuAdapter( 17 | private val list: List, 18 | private val context: Context 19 | ) : RecyclerView.Adapter() { 20 | 21 | class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { 22 | private val viewBinding = ItemMenuBinding.bind(itemView) 23 | fun bindView(item: Menu) { 24 | viewBinding.textViewName.text = itemView.context.getString(item.name) 25 | 26 | val color = PokemonColorUtil(itemView.context).convertColor(item.color) 27 | viewBinding.relativeLayoutBackground.background.colorFilter = 28 | PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP) 29 | 30 | itemView.setOnClickListener { 31 | it.findNavController().navigate(R.id.action_navigation_home_to_navigation_pokedex) 32 | } 33 | } 34 | } 35 | 36 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { 37 | val view = LayoutInflater.from(context).inflate(R.layout.item_menu, parent, false) 38 | return ViewHolder(view) 39 | } 40 | 41 | override fun onBindViewHolder(holder: ViewHolder, position: Int) { 42 | val item = list[position] 43 | holder.bindView(item) 44 | } 45 | 46 | override fun getItemCount(): Int { 47 | return list.size 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_news.xml: -------------------------------------------------------------------------------- 1 | 2 | 14 | 15 | 31 | 32 | 33 | 40 | 41 | 42 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | 19 | 20 | 23 | 24 | 27 | 28 | 31 | 32 | 35 | 36 | 40 | 41 |