├── .idea
├── .gitignore
├── caches
│ └── build_file_checksums.ser
├── encodings.xml
├── vcs.xml
├── misc.xml
├── libraries
│ ├── Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml
│ ├── Gradle__androidx_constraintlayout_constraintlayout_solver_1_1_3_jar.xml
│ ├── Gradle__rxjava_2_2_7.xml
│ ├── Gradle__androidx_constraintlayout_constraintlayout_1_1_3_aar.xml
│ ├── Gradle__annotations_13_0.xml
│ ├── Gradle__koin_core_2_0_0_rc_1.xml
│ ├── Gradle__koin_android_2_0_0_rc_1.xml
│ ├── Gradle__androidx_room_room_common_2_2_3_jar.xml
│ ├── Gradle__kotlin_stdlib_1_3_61.xml
│ ├── Gradle__reactive_streams_1_0_2.xml
│ ├── Gradle__androidx_arch_core_core_common_2_0_1_jar.xml
│ ├── Gradle__androidx_arch_core_core_common_2_1_0_jar.xml
│ ├── Gradle__androidx_collection_collection_1_1_0_jar.xml
│ ├── Gradle__kotlin_stdlib_jdk7_1_3_61.xml
│ ├── Gradle__kotlin_stdlib_common_1_3_61.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_common_2_1_0_jar.xml
│ ├── Gradle__kotlinx_coroutines_core_1_3_3.xml
│ ├── Gradle__kotlinx_coroutines_android_1_3_3.xml
│ ├── Gradle__androidx_loader_loader_1_0_0_aar.xml
│ ├── Gradle__androidx_sqlite_sqlite_2_0_1_aar.xml
│ ├── Gradle__androidx_core_core_ktx_1_0_1_aar.xml
│ ├── Gradle__androidx_room_room_ktx_2_2_3_aar.xml
│ ├── Gradle__androidx_activity_activity_1_0_0_aar.xml
│ ├── Gradle__androidx_cardview_cardview_1_0_0_aar.xml
│ ├── Gradle__junit_junit_4_12_jar.xml
│ ├── Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml
│ ├── Gradle__androidx_customview_customview_1_0_0_aar.xml
│ ├── Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml
│ ├── Gradle__androidx_arch_core_core_runtime_2_0_1_aar.xml
│ ├── Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml
│ ├── Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml
│ ├── Gradle__androidx_sqlite_sqlite_framework_2_0_1_aar.xml
│ ├── Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_process_2_0_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_service_2_0_0_aar.xml
│ ├── Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml
│ ├── Gradle__com_squareup_okio_okio_1_15_0_jar.xml
│ ├── Gradle__javax_inject_javax_inject_1_jar.xml
│ ├── Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml
│ ├── Gradle__androidx_databinding_databinding_runtime_3_5_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_extensions_2_0_0_aar.xml
│ ├── Gradle__com_google_code_gson_gson_2_8_5_jar.xml
│ ├── Gradle__androidx_databinding_databinding_adapters_3_5_0_aar.xml
│ ├── Gradle__com_squareup_javawriter_2_1_1_jar.xml
│ ├── Gradle__org_jetbrains_annotations_13_0_jar.xml
│ ├── Gradle__io_reactivex_rxjava2_rxjava_2_2_7_jar.xml
│ ├── Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml
│ ├── Gradle__org_koin_koin_core_2_0_0_rc_1_jar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml
│ ├── Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_1_0_aar.xml
│ ├── Gradle__com_squareup_okhttp3_okhttp_3_12_0_jar.xml
│ ├── Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml
│ ├── Gradle__io_reactivex_rxjava2_rxkotlin_2_2_0_jar.xml
│ ├── Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml
│ ├── Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml
│ ├── Gradle__androidx_annotation_annotation_1_1_0_jar.xml
│ ├── Gradle__com_squareup_retrofit2_retrofit_2_6_0_jar.xml
│ ├── Gradle__org_koin_koin_core_ext_2_0_0_rc_1_jar.xml
│ ├── Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml
│ ├── Gradle__androidx_core_core_1_1_0_aar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_61_jar.xml
│ ├── Gradle__androidx_test_runner_1_1_1_aar.xml
│ ├── Gradle__com_squareup_retrofit2_converter_gson_2_6_0_jar.xml
│ ├── Gradle__org_reactivestreams_reactive_streams_1_0_2_jar.xml
│ ├── Gradle__com_squareup_retrofit2_adapter_rxjava2_2_6_0_jar.xml
│ ├── Gradle__androidx_test_monitor_1_1_1_aar.xml
│ ├── Gradle__androidx_databinding_databinding_common_3_5_0_jar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_61_jar.xml
│ ├── Gradle__androidx_fragment_fragment_1_1_0_aar.xml
│ ├── Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml
│ ├── Gradle__androidx_room_room_runtime_2_2_3_aar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_61_jar.xml
│ ├── Gradle__androidx_transition_transition_1_2_0_aar.xml
│ ├── Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml
│ ├── Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml
│ ├── Gradle__com_google_android_material_material_1_1_0_aar.xml
│ ├── Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_3_jar.xml
│ ├── Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml
│ ├── Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml
│ ├── Gradle__org_koin_koin_android_2_0_0_rc_1_aar.xml
│ ├── Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_3_jar.xml
│ ├── Gradle__androidx_test_espresso_espresso_core_3_1_1_aar.xml
│ ├── Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml
│ ├── Gradle__org_koin_koin_androidx_scope_2_0_0_rc_1_aar.xml
│ ├── Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_61_jar.xml
│ ├── Gradle__org_koin_koin_androidx_viewmodel_2_0_0_rc_1_aar.xml
│ └── Gradle__androidx_test_espresso_espresso_idling_resource_3_1_1_aar.xml
├── runConfigurations.xml
├── modules.xml
├── gradle.xml
├── assetWizardSettings.xml
└── codeStyles
│ └── Project.xml
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── iconfinder_flag-brazil_748057.png
├── data
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ └── values
│ │ │ └── strings.xml
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── data
│ │ ├── remote
│ │ ├── api
│ │ │ └── ServerApi.kt
│ │ ├── model
│ │ │ └── AndroidJobPayload.kt
│ │ ├── mapper
│ │ │ └── AndroidJobMapper.kt
│ │ └── source
│ │ │ └── RemoteDataSourceImpl.kt
│ │ ├── local
│ │ ├── model
│ │ │ └── AndroidJobCache.kt
│ │ ├── database
│ │ │ ├── JobsDataBase.kt
│ │ │ └── JobsDao.kt
│ │ ├── mapper
│ │ │ └── AndroidJobCacheMapper.kt
│ │ └── source
│ │ │ └── JobsCacheSource.kt
│ │ ├── di
│ │ ├── DataCacheModule.kt
│ │ ├── DataModule.kt
│ │ └── DataRemoteModule.kt
│ │ ├── extensions
│ │ └── mapRemoteErrors.kt
│ │ └── AndroidJobsRepositoryImpl.kt
├── .gitignore
├── build.gradle
└── data.iml
├── iconfinder_flag-united-kingdom_748024.png
├── app
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── ic_add_black_24dp.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ └── layout
│ │ │ │ ├── item_android_job.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ └── activity_android_jobs_list.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── mymoduleexample
│ │ │ │ ├── utils
│ │ │ │ ├── exhaustive.kt
│ │ │ │ └── Event.kt
│ │ │ │ ├── extension
│ │ │ │ ├── ViewGroup.kt
│ │ │ │ ├── Context.kt
│ │ │ │ └── View.kt
│ │ │ │ ├── di
│ │ │ │ └── PresentationModule.kt
│ │ │ │ ├── MyModuleApplication.kt
│ │ │ │ └── feature
│ │ │ │ ├── main
│ │ │ │ ├── MainViewModel.kt
│ │ │ │ └── MainActivity.kt
│ │ │ │ ├── viewmodel
│ │ │ │ └── ViewState.kt
│ │ │ │ └── list
│ │ │ │ ├── AndroidJobsAdapter.kt
│ │ │ │ ├── AndroidJobListViewModel.kt
│ │ │ │ └── AndroidJobsListActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── mymoduleexample
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── mymoduleexample
│ │ └── ExampleInstrumentedTest.kt
├── .gitignore
├── proguard-rules.pro
└── build.gradle
├── domain
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── example
│ │ └── domain
│ │ ├── entities
│ │ └── AndroidJob.kt
│ │ ├── responses
│ │ ├── ResultRequired.kt
│ │ └── ResultRemote.kt
│ │ ├── repository
│ │ └── AndroidJobsRepository.kt
│ │ ├── di
│ │ └── DomainModule.kt
│ │ └── usecases
│ │ └── GetJobsUseCases.kt
├── build.gradle
├── .gitignore
└── domain.iml
├── local.properties
├── android-my-bootcamp-android-modularization.iml
├── gradle.properties
├── gradlew.bat
├── README.md
├── dependencies.gradle
└── gradlew
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':domain', ':data'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/iconfinder_flag-brazil_748057.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/iconfinder_flag-brazil_748057.png
--------------------------------------------------------------------------------
/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/data/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/iconfinder_flag-united-kingdom_748024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/iconfinder_flag-united-kingdom_748024.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/utils/exhaustive.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.utils
2 |
3 | val T.exhaustive: T
4 | get() = this
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ifucolo/android-modularization/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/ifucolo/android-modularization/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/ifucolo/android-modularization/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/ifucolo/android-modularization/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/ifucolo/android-modularization/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/data/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | https://demo8470178.mockable.io
4 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/example/domain/entities/AndroidJob.kt:
--------------------------------------------------------------------------------
1 | package com.example.domain.entities
2 |
3 | data class AndroidJob(
4 | val title: String,
5 | val experienceTimeRequired: String,
6 | val native: Boolean,
7 | val country: String
8 | )
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jan 10 12:56:56 CET 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-5.4.1-all.zip
7 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/example/domain/responses/ResultRequired.kt:
--------------------------------------------------------------------------------
1 | package com.example.domain.responses
2 |
3 | sealed class ResultRequired {
4 | data class Success(val result: T): ResultRequired()
5 | data class Error(val throwable: Throwable): ResultRequired()
6 | }
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/remote/api/ServerApi.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.remote.api
2 |
3 | import com.example.data.remote.model.JobsPayload
4 | import io.reactivex.Single
5 | import retrofit2.http.GET
6 |
7 | interface ServerApi {
8 |
9 | @GET("/android-jobs")
10 | suspend fun fetchJobs(): JobsPayload
11 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/extension/ViewGroup.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.extension
2 |
3 | import android.view.LayoutInflater
4 | import android.view.View
5 | import android.view.ViewGroup
6 |
7 | fun ViewGroup.inflate(layoutId: Int, attachToRoot: Boolean = false): View {
8 | return LayoutInflater.from(context).inflate(layoutId, this, attachToRoot)
9 | }
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/extension/Context.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.extension
2 |
3 | import android.content.Context
4 | import android.widget.Toast
5 |
6 | /**
7 | * Created by bruno on 07/07/17.
8 | */
9 | inline fun Context.toast(message: CharSequence, duration: Int = Toast.LENGTH_SHORT) {
10 | Toast.makeText(this, message, duration).show()
11 | }
--------------------------------------------------------------------------------
/domain/src/main/java/com/example/domain/repository/AndroidJobsRepository.kt:
--------------------------------------------------------------------------------
1 | package com.example.domain.repository
2 |
3 | import com.example.domain.entities.AndroidJob
4 | import com.example.domain.responses.ResultRequired
5 | import kotlinx.coroutines.flow.Flow
6 |
7 | interface AndroidJobsRepository {
8 | fun getJobs(): Flow>>
9 | fun add()
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/extension/View.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.extension
2 |
3 | import android.view.View
4 |
5 | fun View.visible(visible: Boolean = false) {
6 | visibility = if (visible) View.VISIBLE else View.GONE
7 | }
8 |
9 | fun View.show() {
10 | visibility = View.VISIBLE
11 | }
12 |
13 | fun View.hide() {
14 | visibility = View.GONE
15 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/local/model/AndroidJobCache.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.local.model
2 |
3 | import androidx.room.Entity
4 | import androidx.room.PrimaryKey
5 |
6 | @Entity(tableName = "jobs")
7 | data class AndroidJobCache(
8 | @PrimaryKey(autoGenerate = true)
9 | var id: Int = 0,
10 | var title: String = "",
11 | var requiredExperienceYears: Int = 0,
12 | var native: Boolean = true,
13 | var country: String = ""
14 | )
15 |
--------------------------------------------------------------------------------
/app/src/test/java/com/example/mymoduleexample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file should *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | sdk.dir=/Users/iagomendesfucolo/Library/Android/sdk
11 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/example/domain/di/DomainModule.kt:
--------------------------------------------------------------------------------
1 | package com.example.domain.di
2 |
3 | import com.example.domain.usecases.GetJobsUseCases
4 | import com.example.domain.usecases.GetJobsUseCasesImpl
5 | import io.reactivex.schedulers.Schedulers
6 | import org.koin.dsl.module
7 |
8 | val useCaseModule = module {
9 |
10 | factory {
11 | GetJobsUseCasesImpl(
12 | repository = get()
13 | )
14 | }
15 | }
16 |
17 | val domainModule = listOf(useCaseModule)
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_solver_1_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/domain/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java-library'
2 | apply plugin: 'kotlin'
3 |
4 | dependencies {
5 |
6 | def dependencies = rootProject.ext.dependencies
7 |
8 | implementation dependencies.kotlin
9 | implementation dependencies.rxJava
10 | implementation dependencies.koin
11 |
12 | implementation dependencies.coroutinesCore
13 | implementation dependencies.coroutinesAndroid
14 | }
15 |
16 | sourceCompatibility = JavaVersion.VERSION_1_8
17 | targetCompatibility = JavaVersion.VERSION_1_8
--------------------------------------------------------------------------------
/domain/src/main/java/com/example/domain/responses/ResultRemote.kt:
--------------------------------------------------------------------------------
1 | package com.example.domain.responses
2 |
3 | sealed class ResultRemote {
4 | data class Success(val response: T): ResultRemote()
5 |
6 | sealed class ErrorResponse(open val throwable: Throwable) : ResultRemote(){
7 | data class Unknown(override val throwable: Throwable): ErrorResponse(throwable)
8 | data class TokenExpired(override val throwable: Throwable): ErrorResponse(throwable)
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | MyModuleExample
3 | Ver lista de Android Jobs
4 | Sair
5 | Carregando…
6 | Ops! tivemos um problema, volte mais tarde
7 | Tente novamente
8 | Sem resultados.
9 | Adicionar
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/di/DataCacheModule.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.di
2 |
3 | import com.example.data.local.database.JobsDataBase
4 | import com.example.data.local.source.JobsCacheDataSource
5 | import com.example.data.local.source.JobsCacheSourceImpl
6 | import org.koin.android.ext.koin.androidContext
7 | import org.koin.dsl.module
8 |
9 | val cacheDataModule = module {
10 | single { JobsDataBase.createDataBase(androidContext()) }
11 | factory { JobsCacheSourceImpl(jobsDao = get()) }
12 | }
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/di/DataModule.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.di
2 |
3 | import com.example.data.AndroidJobsRepositoryImpl
4 | import com.example.domain.repository.AndroidJobsRepository
5 | import org.koin.dsl.module
6 |
7 | val repositoryModule = module {
8 | factory {
9 | AndroidJobsRepositoryImpl(
10 | jobsCacheDataSource = get(),
11 | remoteDataSource = get()
12 | )
13 | }
14 | }
15 |
16 | val dataModules = listOf(remoteDataSourceModule, repositoryModule, cacheDataModule)
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/remote/model/AndroidJobPayload.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.remote.model
2 |
3 | import com.google.gson.annotations.SerializedName
4 |
5 | class JobsPayload(
6 | @SerializedName("jobs") val jobsPayload: List
7 | )
8 |
9 | class AndroidJobPayload(
10 | @SerializedName("native") val native: Boolean,
11 | @SerializedName("title") val title: String,
12 | @SerializedName("required_experience_years") val requiredExperienceYears: Int,
13 | @SerializedName("country") val country: String
14 | )
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__rxjava_2_2_7.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_constraintlayout_constraintlayout_1_1_3_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__annotations_13_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__koin_core_2_0_0_rc_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/extensions/mapRemoteErrors.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.extensions
2 |
3 | import com.example.domain.responses.ResultRemote
4 | import retrofit2.HttpException
5 |
6 | fun Throwable.mapRemoteErrors(): ResultRemote.ErrorResponse {
7 | return when (this) {
8 | is HttpException -> {
9 | when (code()) {
10 | 401, 403 -> ResultRemote.ErrorResponse.TokenExpired(this)
11 | else -> ResultRemote.ErrorResponse.Unknown(this)
12 | }
13 | }
14 | else -> ResultRemote.ErrorResponse.Unknown(this)
15 | }
16 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__koin_android_2_0_0_rc_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_room_room_common_2_2_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__kotlin_stdlib_1_3_61.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__reactive_streams_1_0_2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_arch_core_core_common_2_0_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_collection_collection_1_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__kotlin_stdlib_jdk7_1_3_61.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/remote/mapper/AndroidJobMapper.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.remote.mapper
2 |
3 | import com.example.data.remote.model.AndroidJobPayload
4 | import com.example.data.remote.model.JobsPayload
5 | import com.example.domain.entities.AndroidJob
6 |
7 | object AndroidJobMapper {
8 |
9 | fun map(payload: JobsPayload) = payload.jobsPayload.map { map(it) }
10 |
11 | private fun map(payload: AndroidJobPayload) = AndroidJob(
12 | title = payload.title,
13 | experienceTimeRequired = payload.requiredExperienceYears.toString(),
14 | native = payload.native,
15 | country = payload.country
16 | )
17 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__kotlin_stdlib_common_1_3_61.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/di/PresentationModule.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.di
2 |
3 | import com.example.mymoduleexample.feature.list.AndroidJobListViewModel
4 | import com.example.mymoduleexample.feature.list.AndroidJobsAdapter
5 | import com.example.mymoduleexample.feature.main.MainViewModel
6 | import io.reactivex.android.schedulers.AndroidSchedulers
7 | import org.koin.androidx.viewmodel.dsl.viewModel
8 | import org.koin.dsl.module
9 |
10 | val presentationModule = module {
11 | viewModel { MainViewModel() }
12 |
13 | viewModel {
14 | AndroidJobListViewModel(
15 | jobsUseCase = get()
16 | )
17 | }
18 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__kotlinx_coroutines_core_1_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__kotlinx_coroutines_android_1_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/MyModuleApplication.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample
2 |
3 | import android.app.Application
4 | import com.example.data.di.dataModules
5 | import com.example.domain.di.domainModule
6 | import com.example.mymoduleexample.di.presentationModule
7 | import org.koin.android.ext.koin.androidContext
8 | import org.koin.core.context.startKoin
9 |
10 | class MyModuleApplication: Application() {
11 |
12 | override fun onCreate() {
13 | super.onCreate()
14 |
15 | startKoin {
16 | androidContext(this@MyModuleApplication)
17 |
18 | modules(domainModule + dataModules + listOf(presentationModule))
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/utils/Event.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.utils
2 |
3 | open class Event(private val content: T) {
4 |
5 | var hasBeenHandled = false
6 | private set // Allow external read but not write
7 |
8 | /**
9 | * Returns the content and prevents its use again.
10 | */
11 | fun getContentIfNotHandled(): T? {
12 | return if (hasBeenHandled) {
13 | null
14 | } else {
15 | hasBeenHandled = true
16 | content
17 | }
18 | }
19 |
20 | /**
21 | * Returns the content, even if it's already been handled.
22 | */
23 | fun peekContent(): T = content
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_sqlite_sqlite_2_0_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_core_core_ktx_1_0_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_room_room_ktx_2_2_3_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_activity_activity_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_cardview_cardview_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__junit_junit_4_12_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | /*/build/
3 |
4 | # Crashlytics configuations
5 | com_crashlytics_export_strings.xml
6 |
7 | # Local configuration file (sdk path, etc)
8 | local.properties
9 |
10 | # Gradle generated files
11 | .gradle/
12 |
13 | # Signing files
14 | .signing/
15 |
16 | # User-specific configurations
17 | .idea/libraries/
18 | .idea/workspace.xml
19 | .idea/tasks.xml
20 | .idea/.name
21 | .idea/compiler.xml
22 | .idea/copyright/profiles_settings.xml
23 | .idea/encodings.xml
24 | .idea/misc.xml
25 | .idea/modules.xml
26 | .idea/scopes/scope_settings.xml
27 | .idea/vcs.xml
28 | *.iml
29 |
30 | # OS-specific files
31 | .DS_Store
32 | .DS_Store?
33 | ._*
34 | .Spotlight-V100
35 | .Trashes
36 | ehthumbs.db
37 | Thumbs.db
--------------------------------------------------------------------------------
/data/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | /*/build/
3 |
4 | # Crashlytics configuations
5 | com_crashlytics_export_strings.xml
6 |
7 | # Local configuration file (sdk path, etc)
8 | local.properties
9 |
10 | # Gradle generated files
11 | .gradle/
12 |
13 | # Signing files
14 | .signing/
15 |
16 | # User-specific configurations
17 | .idea/libraries/
18 | .idea/workspace.xml
19 | .idea/tasks.xml
20 | .idea/.name
21 | .idea/compiler.xml
22 | .idea/copyright/profiles_settings.xml
23 | .idea/encodings.xml
24 | .idea/misc.xml
25 | .idea/modules.xml
26 | .idea/scopes/scope_settings.xml
27 | .idea/vcs.xml
28 | *.iml
29 |
30 | # OS-specific files
31 | .DS_Store
32 | .DS_Store?
33 | ._*
34 | .Spotlight-V100
35 | .Trashes
36 | ehthumbs.db
37 | Thumbs.db
--------------------------------------------------------------------------------
/domain/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | /*/build/
3 |
4 | # Crashlytics configuations
5 | com_crashlytics_export_strings.xml
6 |
7 | # Local configuration file (sdk path, etc)
8 | local.properties
9 |
10 | # Gradle generated files
11 | .gradle/
12 |
13 | # Signing files
14 | .signing/
15 |
16 | # User-specific configurations
17 | .idea/libraries/
18 | .idea/workspace.xml
19 | .idea/tasks.xml
20 | .idea/.name
21 | .idea/compiler.xml
22 | .idea/copyright/profiles_settings.xml
23 | .idea/encodings.xml
24 | .idea/misc.xml
25 | .idea/modules.xml
26 | .idea/scopes/scope_settings.xml
27 | .idea/vcs.xml
28 | *.iml
29 |
30 | # OS-specific files
31 | .DS_Store
32 | .DS_Store?
33 | ._*
34 | .Spotlight-V100
35 | .Trashes
36 | ehthumbs.db
37 | Thumbs.db
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_0_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_sqlite_sqlite_framework_2_0_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_process_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_service_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/local/database/JobsDataBase.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.local.database
2 | import android.content.Context
3 | import androidx.room.Database
4 | import androidx.room.Room
5 | import androidx.room.RoomDatabase
6 | import androidx.room.TypeConverters
7 | import com.example.data.local.model.AndroidJobCache
8 |
9 | @Database(version = 1, entities = [AndroidJobCache::class])
10 | abstract class JobsDataBase : RoomDatabase() {
11 | abstract fun jobsDao(): JobsDao
12 |
13 | companion object {
14 | fun createDataBase(context: Context) : JobsDao {
15 | return Room
16 | .databaseBuilder(context, JobsDataBase::class.java, "Jobs.db")
17 | .build()
18 | .jobsDao()
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_okio_okio_1_15_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__javax_inject_javax_inject_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_databinding_databinding_runtime_3_5_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_extensions_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_google_code_gson_gson_2_8_5_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/example/mymoduleexample/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.example.mymoduleexample", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_databinding_databinding_adapters_3_5_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_annotations_13_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__io_reactivex_rxjava2_rxjava_2_2_7_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_koin_koin_core_2_0_0_rc_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_ktx_2_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_okhttp3_okhttp_3_12_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__io_reactivex_rxjava2_rxkotlin_2_2_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_retrofit2_retrofit_2_6_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/local/database/JobsDao.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.local.database
2 |
3 | import androidx.room.Dao
4 | import androidx.room.Insert
5 | import androidx.room.Query
6 | import androidx.room.Transaction
7 | import com.example.data.local.model.AndroidJobCache
8 | import io.reactivex.Single
9 | import kotlinx.coroutines.flow.Flow
10 |
11 | @Dao
12 | interface JobsDao {
13 |
14 | @Query("SELECT * FROM jobs")
15 | fun getJobs(): Flow>
16 |
17 | @Transaction
18 | fun updateData(users: List) {
19 | deleteAll()
20 | insertAll(users)
21 | }
22 |
23 | @Insert
24 | fun insertAll(users: List)
25 |
26 | @Insert
27 | fun insert(vararg job: AndroidJobCache)
28 |
29 | @Query("DELETE FROM jobs")
30 | fun deleteAll()
31 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_koin_koin_core_ext_2_0_0_rc_1_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/feature/main/MainViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.feature.main
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import com.example.mymoduleexample.utils.Event
7 |
8 | class MainViewModel: ViewModel() {
9 |
10 | private val _mainActionLiveData = MutableLiveData>()
11 | val mainActionLiveData: LiveData> = _mainActionLiveData
12 |
13 | fun onShowAndroidJobsRequire() {
14 | _mainActionLiveData.postValue(Event(MainAction.SHOW_JOBS))
15 | }
16 |
17 | fun onOutAppLiveData() {
18 | _mainActionLiveData.postValue(Event(MainAction.LEAVE_APP))
19 | }
20 | }
21 |
22 | sealed class MainAction {
23 | object SHOW_JOBS: MainAction()
24 | object LEAVE_APP: MainAction()
25 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_core_core_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_1_3_61_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_runner_1_1_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_retrofit2_converter_gson_2_6_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_reactivestreams_reactive_streams_1_0_2_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_squareup_retrofit2_adapter_rxjava2_2_6_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_monitor_1_1_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_databinding_databinding_common_3_5_0_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_jdk7_1_3_61_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_fragment_fragment_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_room_room_runtime_2_2_3_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_stdlib_common_1_3_61_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/local/mapper/AndroidJobCacheMapper.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.local.mapper
2 |
3 | import com.example.data.local.model.AndroidJobCache
4 | import com.example.domain.entities.AndroidJob
5 |
6 | object AndroidJobCacheMapper {
7 |
8 | fun map(cacheData: List) = cacheData.map { map(it) }
9 |
10 | private fun map(cacheData: AndroidJobCache) = AndroidJob(
11 | title = cacheData.title,
12 | experienceTimeRequired = cacheData.requiredExperienceYears.toString(),
13 | native = cacheData.native,
14 | country = cacheData.country
15 | )
16 |
17 | fun mapJobsToCache(jobs: List) = jobs.map { map(it) }
18 |
19 | fun map(data: AndroidJob) = AndroidJobCache(
20 | title = data.title,
21 | requiredExperienceYears = data.experienceTimeRequired.toInt(),
22 | native = data.native,
23 | country = data.country
24 | )
25 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_transition_transition_1_2_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_viewpager2_viewpager2_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__io_reactivex_rxjava2_rxandroid_2_1_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/feature/viewmodel/ViewState.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.feature.viewmodel
2 |
3 | import io.reactivex.Single
4 | import io.reactivex.SingleSource
5 | import io.reactivex.SingleTransformer
6 |
7 | sealed class ViewState {
8 | object Loading : ViewState()
9 | data class Success(val data: T) : ViewState()
10 | data class Failed(val throwable: Throwable) : ViewState()
11 | }
12 |
13 | class StateMachineSingle: SingleTransformer> {
14 |
15 | override fun apply(upstream: Single): SingleSource> {
16 | return upstream
17 | .map {
18 | ViewState.Success(it) as ViewState
19 | }
20 | .onErrorReturn {
21 | ViewState.Failed(it)
22 | }
23 | .doOnSubscribe {
24 |
25 | ViewState.Loading
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__com_google_android_material_material_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_core_1_3_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_recyclerview_recyclerview_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_koin_koin_android_2_0_0_rc_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/android-my-bootcamp-android-modularization.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlinx_kotlinx_coroutines_android_1_3_3_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_1_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_koin_koin_androidx_scope_2_0_0_rc_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_android_extensions_runtime_1_3_61_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__org_koin_koin_androidx_viewmodel_2_0_0_rc_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/remote/source/RemoteDataSourceImpl.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.remote.source
2 |
3 | import com.example.data.extensions.mapRemoteErrors
4 | import com.example.data.remote.api.ServerApi
5 | import com.example.data.remote.mapper.AndroidJobMapper
6 | import com.example.data.remote.model.JobsPayload
7 | import com.example.domain.entities.AndroidJob
8 | import com.example.domain.responses.ResultRemote
9 | import io.reactivex.Single
10 | import java.lang.Exception
11 |
12 | interface RemoteDataSource {
13 | suspend fun getJobs(): ResultRemote
14 | }
15 |
16 | class RemoteDataSourceImpl(
17 | private val serverApi: ServerApi
18 | ): RemoteDataSource {
19 |
20 | override suspend fun getJobs(): ResultRemote {
21 | return try {
22 | val jobsPayload = serverApi.fetchJobs()
23 |
24 | ResultRemote.Success(
25 | response = jobsPayload
26 | )
27 | } catch (throwable: Throwable) {
28 | throwable.mapRemoteErrors()
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_1_1_aar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/local/source/JobsCacheSource.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.local.source
2 |
3 | import com.example.data.local.database.JobsDao
4 | import com.example.data.local.mapper.AndroidJobCacheMapper
5 | import com.example.data.local.model.AndroidJobCache
6 | import com.example.domain.entities.AndroidJob
7 | import com.example.domain.responses.ResultRequired
8 | import io.reactivex.Single
9 | import kotlinx.coroutines.flow.Flow
10 | import kotlinx.coroutines.flow.catch
11 | import kotlinx.coroutines.flow.map
12 |
13 | interface JobsCacheDataSource {
14 | fun getJobs(): Flow>
15 |
16 | fun insertData(jobCache : AndroidJobCache)
17 | fun updateData(cacheList: List)
18 | }
19 |
20 | class JobsCacheSourceImpl(private val jobsDao: JobsDao): JobsCacheDataSource {
21 |
22 | override fun getJobs(): Flow> = jobsDao.getJobs()
23 |
24 | override fun insertData(jobCache: AndroidJobCache) {
25 | jobsDao.insert(jobCache)
26 | }
27 |
28 | override fun updateData(cacheList: List) {
29 | jobsDao.updateData(cacheList)
30 | }
31 | }
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # 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
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/feature/list/AndroidJobsAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.feature.list
2 |
3 | import android.view.ViewGroup
4 | import androidx.recyclerview.widget.RecyclerView
5 | import com.example.domain.entities.AndroidJob
6 | import com.example.mymoduleexample.R
7 | import com.example.mymoduleexample.extension.inflate
8 | import kotlinx.android.synthetic.main.item_android_job.view.*
9 |
10 | class AndroidJobsAdapter(var jobs: List = listOf()): RecyclerView.Adapter() {
11 |
12 | inner class ViewHolder(parent: ViewGroup): RecyclerView.ViewHolder(parent.inflate(R.layout.item_android_job)) {
13 |
14 | fun bind(androidJob: AndroidJob) = with(itemView) {
15 | txtTitle.text = androidJob.title
16 | txtCountry.text = androidJob.country
17 | txtYears.text = androidJob.experienceTimeRequired
18 |
19 | chkNative.isChecked = androidJob.native
20 | }
21 | }
22 |
23 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder = ViewHolder(parent)
24 | override fun getItemCount(): Int = jobs.size
25 | override fun onBindViewHolder(holder: ViewHolder, position: Int) = holder.bind(jobs[position])
26 | }
--------------------------------------------------------------------------------
/data/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-kapt'
4 |
5 | android {
6 | def globalConfiguration = rootProject.extensions.getByName("ext")
7 |
8 | compileSdkVersion globalConfiguration["compileSDK"]
9 |
10 | defaultConfig {
11 | minSdkVersion globalConfiguration["minSDK"]
12 | targetSdkVersion globalConfiguration["targetSDK"]
13 | }
14 |
15 | compileOptions {
16 | sourceCompatibility JavaVersion.VERSION_1_8
17 | targetCompatibility JavaVersion.VERSION_1_8
18 | }
19 | }
20 |
21 | dependencies {
22 | def dependencies = rootProject.ext.dependencies
23 |
24 | implementation project(":domain")
25 |
26 | implementation dependencies.kotlin
27 | implementation dependencies.rxJava
28 |
29 | implementation dependencies.retrofit
30 | implementation dependencies.retrofitRxAdapter
31 | implementation dependencies.retrofitGsonConverter
32 | implementation dependencies.gson
33 |
34 | implementation dependencies.room
35 | implementation dependencies.roomKtx
36 | kapt dependencies.roomCompiler
37 |
38 | implementation dependencies.koin
39 |
40 | implementation dependencies.coroutinesCore
41 | implementation dependencies.coroutinesAndroid
42 | }
43 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/di/DataRemoteModule.kt:
--------------------------------------------------------------------------------
1 | package com.example.data.di
2 |
3 | import com.example.data.R
4 | import com.example.data.remote.api.ServerApi
5 | import com.example.data.remote.source.RemoteDataSource
6 | import com.example.data.remote.source.RemoteDataSourceImpl
7 | import okhttp3.OkHttpClient
8 | import org.koin.android.ext.koin.androidContext
9 | import org.koin.dsl.module
10 | import retrofit2.Retrofit
11 | import retrofit2.converter.gson.GsonConverterFactory
12 | import java.util.concurrent.TimeUnit
13 |
14 |
15 | val remoteDataSourceModule = module {
16 | factory { providesOkHttpClient() }
17 | single { createWebService(
18 | okHttpClient = get(),
19 | url = androidContext().getString(R.string.base_url)
20 | ) }
21 |
22 | factory { RemoteDataSourceImpl(serverApi = get()) }
23 | }
24 |
25 | fun providesOkHttpClient(): OkHttpClient {
26 | return OkHttpClient.Builder()
27 | .connectTimeout(30, TimeUnit.SECONDS)
28 | .readTimeout(30, TimeUnit.SECONDS)
29 | .writeTimeout(30, TimeUnit.SECONDS)
30 | .build()
31 | }
32 |
33 | inline fun createWebService(okHttpClient: OkHttpClient , url: String): T {
34 | return Retrofit.Builder()
35 | .addConverterFactory(GsonConverterFactory.create())
36 | .baseUrl(url)
37 | .client(okHttpClient)
38 | .build()
39 | .create(T::class.java)
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/feature/main/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.feature.main
2 |
3 | import android.os.Bundle
4 | import androidx.appcompat.app.AppCompatActivity
5 | import androidx.databinding.DataBindingUtil
6 | import androidx.lifecycle.Observer
7 | import com.example.mymoduleexample.R
8 | import com.example.mymoduleexample.databinding.ActivityMainBinding
9 | import com.example.mymoduleexample.feature.list.AndroidJobsListActivity
10 | import com.example.mymoduleexample.utils.exhaustive
11 | import org.koin.androidx.viewmodel.ext.android.viewModel
12 |
13 | class MainActivity : AppCompatActivity() {
14 |
15 | private val viewModel: MainViewModel by viewModel()
16 | private lateinit var binding: ActivityMainBinding
17 |
18 | override fun onCreate(savedInstanceState: Bundle?) {
19 | super.onCreate(savedInstanceState)
20 |
21 | binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
22 | binding.viewModel = viewModel
23 | binding.lifecycleOwner = this
24 |
25 | setupViewModel()
26 | }
27 |
28 | private fun setupViewModel() {
29 | viewModel.mainActionLiveData.observe(this, Observer {
30 | it.getContentIfNotHandled()?.let { mainAction ->
31 | when(mainAction) {
32 | MainAction.SHOW_JOBS -> startActivity(AndroidJobsListActivity.launchIntent(this))
33 | MainAction.LEAVE_APP -> finish()
34 | }.exhaustive
35 | }
36 | })
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/domain/src/main/java/com/example/domain/usecases/GetJobsUseCases.kt:
--------------------------------------------------------------------------------
1 | package com.example.domain.usecases
2 |
3 | import com.example.domain.entities.AndroidJob
4 | import com.example.domain.repository.AndroidJobsRepository
5 | import com.example.domain.responses.ResultRequired
6 | import kotlinx.coroutines.flow.Flow
7 | import kotlinx.coroutines.flow.map
8 |
9 |
10 | interface GetJobsUseCases{
11 | fun getJobs(): Flow
12 | fun addJob()
13 |
14 | sealed class ResultJobs {
15 | data class Jobs(val list: List): ResultJobs()
16 | object NoJobs: ResultJobs()
17 | object Error: ResultJobs()
18 | }
19 | }
20 |
21 | class GetJobsUseCasesImpl(
22 | private val repository: AndroidJobsRepository
23 | ): GetJobsUseCases {
24 |
25 | override fun getJobs(): Flow {
26 | return repository.getJobs()
27 | .map {
28 | when(it) {
29 | is ResultRequired.Success -> {
30 | when {
31 | it.result.isEmpty() -> GetJobsUseCases.ResultJobs.NoJobs
32 | else -> GetJobsUseCases.ResultJobs.Jobs( it.result.reversed())
33 | }
34 | }
35 | is ResultRequired.Error -> {
36 | println(it.throwable.message)
37 | GetJobsUseCases.ResultJobs.Error
38 | }
39 | }
40 | }
41 | }
42 |
43 | override fun addJob() {
44 | repository.add()
45 | }
46 | }
47 |
48 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/feature/list/AndroidJobListViewModel.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.feature.list
2 |
3 | import androidx.lifecycle.LiveData
4 | import androidx.lifecycle.MutableLiveData
5 | import androidx.lifecycle.ViewModel
6 | import androidx.lifecycle.viewModelScope
7 | import com.example.domain.entities.AndroidJob
8 | import com.example.domain.usecases.GetJobsUseCases
9 | import com.example.mymoduleexample.utils.Event
10 | import kotlinx.coroutines.Dispatchers
11 | import kotlinx.coroutines.flow.collect
12 | import kotlinx.coroutines.launch
13 |
14 |
15 | class AndroidJobListViewModel(
16 | private val jobsUseCase: GetJobsUseCases
17 | ): ViewModel() {
18 |
19 |
20 | private val _viewJobsStatesLiveData = MutableLiveData>()
21 | val viewJobsStatesLiveData: LiveData> = _viewJobsStatesLiveData
22 |
23 | fun getJobs() {
24 | viewModelScope.launch(Dispatchers.IO) {
25 | jobsUseCase.getJobs().collect {
26 | val resultJobs = when(it) {
27 | is GetJobsUseCases.ResultJobs.Jobs -> ViewJobsStates.Show(it.list)
28 | GetJobsUseCases.ResultJobs.NoJobs -> ViewJobsStates.Empty
29 | GetJobsUseCases.ResultJobs.Error -> ViewJobsStates.Error
30 | }
31 |
32 | _viewJobsStatesLiveData.postValue(Event(resultJobs))
33 | }
34 | }
35 | }
36 |
37 | fun add() {
38 | viewModelScope.launch(Dispatchers.IO) {
39 | jobsUseCase.addJob()
40 | }
41 | }
42 |
43 | fun onTryAgainRequired() {
44 | getJobs()
45 | }
46 |
47 | sealed class ViewJobsStates {
48 | data class Show(val list: List): ViewJobsStates()
49 | object Empty: ViewJobsStates()
50 | object Error: ViewJobsStates()
51 | }
52 | }
--------------------------------------------------------------------------------
/.idea/assetWizardSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/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_android_job.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
21 |
22 |
32 |
33 |
41 |
42 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | apply plugin: 'kotlin-kapt'
5 |
6 |
7 | android {
8 | def globalConfiguration = rootProject.extensions.getByName("ext")
9 |
10 | compileSdkVersion globalConfiguration["compileSDK"]
11 |
12 | defaultConfig {
13 | applicationId "com.example.mymoduleexample"
14 | minSdkVersion globalConfiguration["minSDK"]
15 | targetSdkVersion globalConfiguration["targetSDK"]
16 | versionCode 1
17 | versionName "1.0"
18 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
19 | }
20 |
21 | dataBinding {
22 | enabled true
23 | }
24 |
25 | buildTypes {
26 | release {
27 | minifyEnabled false
28 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29 | }
30 | }
31 | }
32 |
33 | dependencies {
34 | implementation project(path: ':domain')
35 | implementation project(path: ':data')
36 |
37 | def dependencies = rootProject.ext.dependencies
38 | def testDependencies = rootProject.ext.testDependecies
39 |
40 | implementation dependencies.appCompact
41 | implementation dependencies.constraintlayout
42 |
43 | testImplementation testDependencies.junit
44 | androidTestImplementation testDependencies.runner
45 | androidTestImplementation testDependencies.espresso
46 |
47 | implementation dependencies.appCompact
48 | implementation dependencies.cardView
49 | implementation dependencies.recyclerView
50 | implementation dependencies.material
51 | implementation dependencies.kotlin
52 |
53 | implementation dependencies.ktx
54 |
55 | implementation dependencies.constraintlayout
56 | implementation dependencies.viewModel
57 |
58 | implementation dependencies.lifeCycle
59 |
60 | implementation dependencies.koin
61 | implementation dependencies.koinViewModel
62 |
63 | implementation dependencies.rxJava
64 | implementation dependencies.rxKotlin
65 | implementation dependencies.rxAndroid
66 |
67 | implementation dependencies.coroutinesCore
68 | implementation dependencies.coroutinesAndroid
69 |
70 |
71 | kapt dependencies.dataBinding
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
18 |
19 |
34 |
35 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/data/src/main/java/com/example/data/AndroidJobsRepositoryImpl.kt:
--------------------------------------------------------------------------------
1 | package com.example.data
2 |
3 | import com.example.data.local.mapper.AndroidJobCacheMapper
4 | import com.example.data.local.source.JobsCacheDataSource
5 | import com.example.data.remote.mapper.AndroidJobMapper
6 | import com.example.data.remote.source.RemoteDataSource
7 | import com.example.domain.entities.AndroidJob
8 | import com.example.domain.repository.AndroidJobsRepository
9 | import com.example.domain.responses.ResultRemote
10 | import com.example.domain.responses.ResultRequired
11 | import kotlinx.coroutines.flow.Flow
12 | import kotlinx.coroutines.flow.map
13 |
14 | class AndroidJobsRepositoryImpl(
15 | private val jobsCacheDataSource: JobsCacheDataSource,
16 | private val remoteDataSource: RemoteDataSource
17 | ): AndroidJobsRepository {
18 |
19 | override fun getJobs(): Flow>> {
20 | return jobsCacheDataSource.getJobs()
21 | .map { cacheList ->
22 | val result = when {
23 | cacheList.isEmpty() -> getJobsRemote()
24 | else -> {
25 | val jobs = AndroidJobCacheMapper.map(cacheList)
26 | ResultRequired.Success(jobs)
27 | }
28 | }
29 |
30 | result
31 | }
32 | }
33 |
34 | override fun add() {
35 | val androidJob = AndroidJob(
36 | title = "flow",
37 | experienceTimeRequired = (0..500).random().toString(),
38 | native = true,
39 | country = "Braziil"
40 | )
41 |
42 | val cacheJob = AndroidJobCacheMapper.map(androidJob)
43 | jobsCacheDataSource.insertData(cacheJob)
44 | }
45 |
46 | private suspend fun getJobsRemote(): ResultRequired> {
47 | val resultRemote = remoteDataSource.getJobs()
48 |
49 | return when(resultRemote) {
50 | is ResultRemote.Success -> {
51 | val mappedList = AndroidJobMapper.map(resultRemote.response)
52 | val cacheList = AndroidJobCacheMapper.mapJobsToCache(mappedList)
53 |
54 | jobsCacheDataSource.updateData(cacheList)
55 |
56 | ResultRequired.Success(
57 | result = mappedList
58 | )
59 | }
60 | is ResultRemote.ErrorResponse -> {
61 | ResultRequired.Error(resultRemote.throwable)
62 | }
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## **Android Modularization**
2 | > MVVM - KOIN - RX - ROOM - DATABINDING - COROUTINES - FLOW
3 |
4 | ## Resumo/Overview
5 |  Este projeto faz parte de uma série de 5 artigos, que ensina você a crirar o seu próprio projeto Android modularizado;
6 |
7 |  This project is a sample of a series of 5 articles to explain how you can create your android project applying modularization;
8 |
9 | ## Artigos/Articles
10 | 
11 |
12 | * [Parte 1](https://medium.com/@iagofucolo/modulariza%C3%A7%C3%A3o-android-parte-1-b69b509571c9)
13 | * [Parte 2](https://medium.com/@iagofucolo/modulariza%C3%A7%C3%A3o-android-parte-2-aab52b903d90)
14 | * [Parte 3](https://medium.com/@iagofucolo/modulariza%C3%A7%C3%A3o-android-parte-3-22622ae7d162)
15 | * [Parte 4](link)
16 | * [Parte 5](link)
17 |
18 |
19 | 
20 |
21 | Translation in progress....
22 |
23 | ## Architecture
24 | - MVVM
25 |
26 | ## Libs
27 | * [Koin](https://insert-koin.io/)
28 |
29 | * [ViewModel](https://developer.android.com/topic/libraries/architecture/viewmodel)
30 | * [DataBinding](https://developer.android.com/topic/libraries/data-binding)
31 | * [Room](https://developer.android.com/topic/libraries/architecture/room)
32 | * [ktx](https://developer.android.com/kotlin/ktx)
33 |
34 | * [RxAndroid](https://github.com/ReactiveX/RxAndroid)
35 | * [RxKotlin](https://github.com/ReactiveX/RxKotlin)
36 | * [RxJava](https://github.com/ReactiveX/RxJava)
37 |
38 | * [Retrofit](https://github.com/ww-tech/roxie/wiki/1.-ViewModel)
39 | * [Coroutines](https://developer.android.com/topic/libraries/architecture/coroutines)
40 |
41 |
42 |
43 | ## LICENSE
44 |
45 | ```
46 | The MIT License (MIT)
47 |
48 | Copyright (c) 2019 Iago Fucolo
49 |
50 | Permission is hereby granted, free of charge, to any person obtaining a copy of
51 | this software and associated documentation files (the "Software"), to deal in
52 | the Software without restriction, including without limitation the rights to
53 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
54 | the Software, and to permit persons to whom the Software is furnished to do so,
55 | subject to the following conditions:
56 |
57 | The above copyright notice and this permission notice shall be included in all
58 | copies or substantial portions of the Software.
59 |
60 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
61 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
62 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
63 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
64 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
65 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 | ```
67 |
--------------------------------------------------------------------------------
/app/src/main/java/com/example/mymoduleexample/feature/list/AndroidJobsListActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.mymoduleexample.feature.list
2 |
3 | import android.content.Context
4 | import android.content.Intent
5 | import android.os.Bundle
6 | import androidx.appcompat.app.AppCompatActivity
7 | import androidx.databinding.DataBindingUtil
8 | import androidx.lifecycle.Observer
9 | import androidx.recyclerview.widget.LinearLayoutManager
10 | import com.example.domain.entities.AndroidJob
11 | import com.example.mymoduleexample.R
12 | import com.example.mymoduleexample.databinding.ActivityAndroidJobsListBinding
13 | import com.example.mymoduleexample.extension.hide
14 | import com.example.mymoduleexample.extension.show
15 | import com.example.mymoduleexample.extension.visible
16 | import com.example.mymoduleexample.feature.viewmodel.ViewState
17 | import com.example.mymoduleexample.utils.exhaustive
18 | import org.koin.android.ext.android.inject
19 | import org.koin.androidx.viewmodel.ext.android.viewModel
20 |
21 |
22 | class AndroidJobsListActivity: AppCompatActivity() {
23 |
24 | private val viewModel: AndroidJobListViewModel by viewModel()
25 | private lateinit var binding: ActivityAndroidJobsListBinding
26 | private lateinit var androidJobsAdapter: AndroidJobsAdapter
27 |
28 | companion object {
29 | fun launchIntent(context: Context): Intent {
30 | return Intent(context, AndroidJobsListActivity::class.java)
31 | }
32 | }
33 |
34 | override fun onCreate(savedInstanceState: Bundle?) {
35 | super.onCreate(savedInstanceState)
36 |
37 | binding = DataBindingUtil.setContentView(this, R.layout.activity_android_jobs_list)
38 | binding.viewModel = viewModel
39 | binding.lifecycleOwner = this
40 |
41 | setupView()
42 | setupViewModel()
43 | }
44 |
45 | private fun setupView() {
46 | setSupportActionBar(binding.toolbar)
47 | binding.toolbar.setNavigationIcon(R.drawable.abc_ic_ab_back_material)
48 | binding.toolbar.setNavigationOnClickListener{
49 | finish()
50 | }
51 |
52 | setupRecyclerView()
53 | }
54 |
55 | private fun setupViewModel() {
56 | viewModel.getJobs()
57 |
58 | viewModel.viewJobsStatesLiveData.observe(this, Observer { state ->
59 | state.getContentIfNotHandled()?.let {
60 | hideAll()
61 |
62 | when(it) {
63 | is AndroidJobListViewModel.ViewJobsStates.Show -> showContent(it.list)
64 | AndroidJobListViewModel.ViewJobsStates.Empty -> showEmptyState()
65 | AndroidJobListViewModel.ViewJobsStates.Error -> showError()
66 | }.exhaustive
67 | }
68 | })
69 | }
70 |
71 | private fun setupRecyclerView() = with(binding.recyclerView) {
72 | androidJobsAdapter = AndroidJobsAdapter()
73 |
74 | layoutManager = LinearLayoutManager(context)
75 | adapter = androidJobsAdapter
76 | }
77 |
78 | private fun showError() {
79 | binding.btnTryAgain.show()
80 | }
81 |
82 | private fun showEmptyState() {
83 | binding.txtEmpty.show()
84 | }
85 |
86 | private fun showContent(list: List) = with(androidJobsAdapter) {
87 | jobs = list
88 | notifyDataSetChanged()
89 | binding.recyclerView.show()
90 | }
91 |
92 | private fun hideAll() {
93 | listOf(binding.btnTryAgain, binding.txtEmpty, binding.recyclerView, binding.progressBar).map {
94 | it.hide()
95 | }
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/dependencies.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 |
3 |
4 | //Android Config
5 | minSDK = 20
6 | targetSDK = 29
7 | compileSDK = 29
8 |
9 | buildTools = '3.5.0'
10 |
11 | appCompactVersion = '1.0.2'
12 | kotlinVersion = '1.3.61'
13 |
14 | AndroidArchVersion = '1.1.1'
15 | databindingVersion = '3.1.4'
16 | lifeCycleVersion = '2.1.0'
17 | ktxVersion = '1.0.1'
18 |
19 | constrainVersion = '1.1.3'
20 | cardViewVersion = '1.0.0'
21 | recyclerViewVersion = '1.0.0'
22 |
23 | coroutineVersion = '1.3.3'
24 |
25 | //Rx
26 | rxJavaVersion = '2.2.7'
27 | rxKotlinVersion = '2.2.0'
28 | rxAndroidVersion = '2.1.1'
29 |
30 | //Koin
31 | koinVersion = '2.0.0-rc-1'
32 |
33 | //Retrofit
34 | retrofitVersion = '2.6.0'
35 |
36 | //Gson
37 | gsonVersion = '2.8.5'
38 |
39 | //Room version
40 | roomVersion = '2.2.3'
41 |
42 | //Test
43 | junitVersion = '4.12'
44 | espressoVersion = '3.1.1'
45 | runnerVersion = '1.1.1'
46 |
47 | materialVersion = '1.1.0'
48 |
49 | dependencies = [
50 | kotlin : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion",
51 | coroutinesCore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion",
52 | coroutinesAndroid : "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutineVersion",
53 |
54 | appCompact : "androidx.appcompat:appcompat:$appCompactVersion",
55 | constraintlayout : "androidx.constraintlayout:constraintlayout:$constrainVersion",
56 | cardView : "androidx.cardview:cardview:$cardViewVersion",
57 | recyclerView : "androidx.recyclerview:recyclerview:$recyclerViewVersion",
58 | material : "com.google.android.material:material:$materialVersion",
59 |
60 | viewModel : "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifeCycleVersion",
61 | lifeCycle : "android.arch.lifecycle:extensions:$AndroidArchVersion",
62 |
63 | dataBinding : "com.android.databinding:compiler:$databindingVersion",
64 |
65 | ktx : "androidx.core:core-ktx:$ktxVersion",
66 |
67 | rxJava : "io.reactivex.rxjava2:rxjava:$rxJavaVersion",
68 | rxKotlin : "io.reactivex.rxjava2:rxkotlin:$rxKotlinVersion",
69 | rxAndroid : "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion",
70 |
71 | koin : "org.koin:koin-android:$koinVersion",
72 | koinViewModel : "org.koin:koin-androidx-viewmodel:$koinVersion",
73 |
74 | retrofit : "com.squareup.retrofit2:retrofit:$retrofitVersion",
75 | retrofitRxAdapter : "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion",
76 | retrofitGsonConverter : "com.squareup.retrofit2:converter-gson:$retrofitVersion",
77 | gson : "com.google.code.gson:gson:$gsonVersion",
78 |
79 | room : "androidx.room:room-runtime:$roomVersion",
80 | roomRxJava : "androidx.room:room-rxjava2:$roomVersion",
81 | roomCompiler : "androidx.room:room-compiler:$roomVersion",
82 | roomKtx : "androidx.room:room-ktx:$roomVersion"
83 | ]
84 |
85 | testDependecies = [
86 | junit : "junit:junit:$junitVersion",
87 | espresso : "androidx.test.espresso:espresso-core:$espressoVersion",
88 | runner : "androidx.test:runner:$runnerVersion"
89 | ]
90 | }
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | xmlns:android
14 |
15 | ^$
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | xmlns:.*
25 |
26 | ^$
27 |
28 |
29 | BY_NAME
30 |
31 |
32 |
33 |
34 |
35 |
36 | .*:id
37 |
38 | http://schemas.android.com/apk/res/android
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | .*:name
48 |
49 | http://schemas.android.com/apk/res/android
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | name
59 |
60 | ^$
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | style
70 |
71 | ^$
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 | .*
81 |
82 | ^$
83 |
84 |
85 | BY_NAME
86 |
87 |
88 |
89 |
90 |
91 |
92 | .*
93 |
94 | http://schemas.android.com/apk/res/android
95 |
96 |
97 | ANDROID_ATTRIBUTE_ORDER
98 |
99 |
100 |
101 |
102 |
103 |
104 | .*
105 |
106 | .*
107 |
108 |
109 | BY_NAME
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_android_jobs_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
18 |
19 |
29 |
30 |
41 |
42 |
57 |
58 |
71 |
72 |
86 |
87 |
99 |
100 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
11 |
16 |
21 |
26 |
31 |
36 |
41 |
46 |
51 |
56 |
61 |
66 |
71 |
76 |
81 |
86 |
91 |
96 |
101 |
106 |
111 |
116 |
121 |
126 |
131 |
136 |
141 |
146 |
151 |
156 |
161 |
166 |
171 |
172 |
--------------------------------------------------------------------------------
/domain/domain.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/data/data.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | generateDebugSources
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
--------------------------------------------------------------------------------