├── .gitignore ├── .idea ├── $CACHE_FILE$ ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── employeeinfo │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── employeeinfo │ │ │ ├── MainActivity.kt │ │ │ ├── adapters │ │ │ └── UserAdapter.kt │ │ │ ├── dependency │ │ │ └── DependencyUtils.kt │ │ │ ├── model │ │ │ ├── EmployeeModel.kt │ │ │ └── UserModel.kt │ │ │ ├── network │ │ │ ├── EmployeeService.kt │ │ │ └── NetworkUtil.kt │ │ │ ├── repository │ │ │ └── EmployeeRepository.kt │ │ │ └── viewmodel │ │ │ ├── EmployeeViewModel.kt │ │ │ └── EmployeeViewModelFactory.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── ic_launcher_background.xml │ │ └── ic_sync.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── item_user_list.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ ├── java │ └── com │ │ └── employeeinfo │ │ ├── EmployeeViewModelTest.kt │ │ ├── ExampleUnitTest.kt │ │ └── TestCoroutineRule.kt │ └── resources │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /.idea/$CACHE_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Android 10 | 11 | 12 | ComplianceLintAndroid 13 | 14 | 15 | CorrectnessLintAndroid 16 | 17 | 18 | LintAndroid 19 | 20 | 21 | PerformanceLintAndroid 22 | 23 | 24 | UsabilityLintAndroid 25 | 26 | 27 | 28 | 29 | Android 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 22 | 23 | 24 | 26 | 27 | 28 |
29 | 30 | 31 | 32 | xmlns:android 33 | 34 | ^$ 35 | 36 | 37 | 38 |
39 |
40 | 41 | 42 | 43 | xmlns:.* 44 | 45 | ^$ 46 | 47 | 48 | BY_NAME 49 | 50 |
51 |
52 | 53 | 54 | 55 | .*:id 56 | 57 | http://schemas.android.com/apk/res/android 58 | 59 | 60 | 61 |
62 |
63 | 64 | 65 | 66 | .*:name 67 | 68 | http://schemas.android.com/apk/res/android 69 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | 77 | name 78 | 79 | ^$ 80 | 81 | 82 | 83 |
84 |
85 | 86 | 87 | 88 | style 89 | 90 | ^$ 91 | 92 | 93 | 94 |
95 |
96 | 97 | 98 | 99 | .* 100 | 101 | ^$ 102 | 103 | 104 | BY_NAME 105 | 106 |
107 |
108 | 109 | 110 | 111 | .* 112 | 113 | http://schemas.android.com/apk/res/android 114 | 115 | 116 | ANDROID_ATTRIBUTE_ORDER 117 | 118 |
119 |
120 | 121 | 122 | 123 | .* 124 | 125 | .* 126 | 127 | 128 | BY_NAME 129 | 130 |
131 |
132 |
133 |
134 | 135 | 137 |
138 |
-------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /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 | android { 7 | compileSdkVersion 30 8 | buildToolsVersion "30.0.1" 9 | 10 | defaultConfig { 11 | applicationId "com.employeeinfo" 12 | minSdkVersion 21 13 | targetSdkVersion 30 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | } 33 | } 34 | 35 | dependencies { 36 | implementation fileTree(dir: "libs", include: ["*.jar"]) 37 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" 38 | implementation 'androidx.core:core-ktx:1.6.0' 39 | implementation 'androidx.appcompat:appcompat:1.3.0' 40 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 41 | testImplementation 'junit:junit:4.12' 42 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 44 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutine_version" 45 | //Retrofit and okhttp3 46 | implementation "com.squareup.retrofit2:retrofit:$retrofit_version" 47 | implementation "com.squareup.retrofit2:retrofit-converters:$retrofit_version" 48 | implementation "com.squareup.retrofit2:retrofit-adapters:$retrofit_version" 49 | implementation "com.squareup.retrofit2:converter-gson:$retrofit_version" 50 | implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version" 51 | implementation 'com.squareup.retrofit2:converter-scalars:2.5.0' 52 | implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_version" 53 | implementation "com.squareup.okhttp3:okhttp:$okhttp_version" 54 | implementation "com.squareup.okhttp3:okhttp-urlconnection:$okhttp_version" 55 | 56 | //Navigation 57 | implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" 58 | implementation "androidx.navigation:navigation-ui-ktx:$nav_version" 59 | 60 | def lifecycle_version = "2.4.0-alpha02" 61 | def arch_version = "2.1.0" 62 | 63 | // ViewModel 64 | implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" 65 | // LiveData 66 | implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" 67 | // Lifecycles only (without ViewModel or LiveData) 68 | implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" 69 | 70 | // Saved state module for ViewModel 71 | implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" 72 | 73 | // Annotation processor 74 | kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version" 75 | // alternately - if using Java8, use the following instead of lifecycle-compiler 76 | implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" 77 | 78 | // optional - helpers for implementing LifecycleOwner in a Service 79 | implementation "androidx.lifecycle:lifecycle-service:$lifecycle_version" 80 | 81 | // optional - ProcessLifecycleOwner provides a lifecycle for the whole application process 82 | implementation "androidx.lifecycle:lifecycle-process:$lifecycle_version" 83 | 84 | // optional - ReactiveStreams support for LiveData 85 | implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycle_version" 86 | 87 | // optional - Test helpers for LiveData 88 | testImplementation "androidx.arch.core:core-testing:$arch_version" 89 | 90 | // Coroutine Testing 91 | testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutine_version" 92 | testImplementation "org.mockito:mockito-core:3.3.3" 93 | testImplementation 'androidx.arch.core:core-testing:2.1.0' 94 | 95 | //Glide 96 | implementation 'com.github.bumptech.glide:glide:4.11.0' 97 | 98 | } -------------------------------------------------------------------------------- /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 -------------------------------------------------------------------------------- /app/src/androidTest/java/com/employeeinfo/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.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.getInstrumentation().targetContext 22 | assertEquals("com.employeeinfo", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo 2 | 3 | import androidx.appcompat.app.AppCompatActivity 4 | import android.os.Bundle 5 | import android.view.View 6 | import androidx.lifecycle.Observer 7 | import androidx.lifecycle.ViewModelProvider 8 | import androidx.recyclerview.widget.LinearLayoutManager 9 | import com.employeeinfo.adapters.UserListAdapter 10 | import com.employeeinfo.viewmodel.EmployeeViewModel 11 | import com.employeeinfo.viewmodel.EmployeeViewModelFactory 12 | import kotlinx.android.synthetic.main.activity_main.* 13 | 14 | class MainActivity : AppCompatActivity() { 15 | lateinit var employeeViewModel: EmployeeViewModel 16 | private var userListAdapter : UserListAdapter? = null 17 | override fun onCreate(savedInstanceState: Bundle?) { 18 | super.onCreate(savedInstanceState) 19 | setContentView(R.layout.activity_main) 20 | initAdapter() 21 | initViewModel() 22 | observeLoading() 23 | fetchEmployeeList() 24 | observeEmployeeInfo() 25 | } 26 | private fun initAdapter(){ 27 | userListAdapter = UserListAdapter(arrayListOf(),this) 28 | userListRecyclerView.apply { 29 | layoutManager = LinearLayoutManager(context) 30 | adapter = userListAdapter 31 | } 32 | } 33 | private fun initViewModel(){ 34 | var employeeViewModelFactory = EmployeeViewModelFactory() 35 | employeeViewModel = ViewModelProvider(this,employeeViewModelFactory).get(EmployeeViewModel::class.java) 36 | } 37 | 38 | private fun fetchEmployeeList(){ 39 | employeeViewModel.fetchEmployeeList() 40 | } 41 | 42 | private fun observeEmployeeInfo(){ 43 | employeeViewModel.employeeLiveData.observe(this, Observer { response -> 44 | response?.let { employeeModel -> 45 | println ("Received Response ${employeeModel.data}") 46 | employeeModel?.let { 47 | userListAdapter?.refreshAdapter(employeeModel.data) 48 | } 49 | } 50 | }) 51 | } 52 | 53 | private fun observeLoading(){ 54 | employeeViewModel.fetchLoadStatus().observe(this, Observer { 55 | if (!it) { 56 | println(it) 57 | loading_progressBar.visibility = View.GONE 58 | }else{ 59 | loading_progressBar.visibility = View.VISIBLE 60 | } 61 | 62 | }) 63 | } 64 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/adapters/UserAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.adapters 2 | 3 | import android.content.Context 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.recyclerview.widget.RecyclerView 8 | import com.bumptech.glide.Glide 9 | import com.employeeinfo.R 10 | import com.employeeinfo.model.UserModel 11 | import kotlinx.android.synthetic.main.item_user_list.view.* 12 | 13 | class UserListAdapter(var users: ArrayList, var context: Context) : RecyclerView.Adapter() { 14 | 15 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder = 16 | UserViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_user_list,parent,false)) 17 | 18 | override fun getItemCount(): Int = users.size 19 | 20 | override fun onBindViewHolder(holder: UserViewHolder, position: Int) = holder.bind(users[position]) 21 | 22 | fun refreshAdapter( newUsers:List){ 23 | users.clear() 24 | users.addAll(newUsers) 25 | notifyDataSetChanged() 26 | } 27 | 28 | inner class UserViewHolder(view: View) : RecyclerView.ViewHolder(view){ 29 | private val layout = view.item_layout 30 | private val firstName = view.first_name 31 | private val lastName = view.last_name 32 | private val email = view.email 33 | private val image = view.imageView 34 | fun bind(userModel: UserModel.Data){ 35 | firstName.text = userModel.first_name 36 | lastName.text = userModel.last_name 37 | email.text = userModel.email 38 | Glide.with(context).load(userModel.avatar).placeholder(R.drawable.ic_sync).into(image) 39 | 40 | 41 | 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/dependency/DependencyUtils.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.dependency 2 | 3 | import com.employeeinfo.network.EmployeeService 4 | import com.employeeinfo.network.NetworkUtil 5 | import com.employeeinfo.repository.EmployeeRepository 6 | import okhttp3.OkHttpClient 7 | import okhttp3.logging.HttpLoggingInterceptor 8 | import retrofit2.Retrofit 9 | import retrofit2.converter.gson.GsonConverterFactory 10 | import java.util.concurrent.TimeUnit 11 | 12 | object DependencyUtils { 13 | 14 | private fun provideNetworkURL(): String = NetworkUtil.NETWORK_BASE_URL 15 | 16 | private fun provideHttpLogger(): HttpLoggingInterceptor = HttpLoggingInterceptor().setLevel( 17 | HttpLoggingInterceptor.Level.BODY) 18 | 19 | private fun provideOKHttp(logger: HttpLoggingInterceptor): OkHttpClient { 20 | val okHttpClient = OkHttpClient.Builder() 21 | 22 | with(okHttpClient) { 23 | addInterceptor(logger) 24 | callTimeout(NetworkUtil.REQUEST_TIMEOUT, TimeUnit.SECONDS) 25 | readTimeout(NetworkUtil.REQUEST_TIMEOUT, TimeUnit.SECONDS) 26 | writeTimeout(NetworkUtil.REQUEST_TIMEOUT, TimeUnit.SECONDS) 27 | connectTimeout(NetworkUtil.REQUEST_TIMEOUT, TimeUnit.SECONDS) 28 | } 29 | return okHttpClient.build() 30 | } 31 | 32 | 33 | fun provideRetrofitInstance(): Retrofit { 34 | return Retrofit.Builder().baseUrl(provideNetworkURL()).client(provideOKHttp( 35 | provideHttpLogger())).addConverterFactory(GsonConverterFactory.create()).build() 36 | 37 | } 38 | 39 | private fun provideAPIService() :EmployeeService{ 40 | 41 | return provideRetrofitInstance().create(EmployeeService::class.java) 42 | } 43 | 44 | fun provideEmployeeRepository() = EmployeeRepository(provideAPIService()) 45 | 46 | 47 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/model/EmployeeModel.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.model 2 | 3 | data class EmployeeModel( 4 | val data: List, 5 | val status: String // success 6 | ) { 7 | data class Data( 8 | val employee_age: String, // 61 9 | val employee_name: String, // Tiger Nixon 10 | val employee_salary: String, // 320800 11 | val id: String, // 1 12 | val profile_image: String 13 | ) 14 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/model/UserModel.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.model 2 | 3 | data class UserModel( 4 | val `data`: List, 5 | val page: Int, // 1 6 | val per_page: Int, // 6 7 | val support: Support, 8 | val total: Int, // 12 9 | val total_pages: Int // 2 10 | ) { 11 | data class Data( 12 | val avatar: String, // https://reqres.in/img/faces/1-image.jpg 13 | val email: String, // george.bluth@reqres.in 14 | val first_name: String, // George 15 | val id: Int, // 1 16 | val last_name: String // Bluth 17 | ) 18 | 19 | data class Support( 20 | val text: String, // To keep ReqRes free, contributions towards server costs are appreciated! 21 | val url: String // https://reqres.in/#support-heading 22 | ) 23 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/network/EmployeeService.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.network 2 | 3 | import com.employeeinfo.model.EmployeeModel 4 | import com.employeeinfo.model.UserModel 5 | import retrofit2.Response 6 | import retrofit2.http.GET 7 | 8 | interface EmployeeService { 9 | //https://reqres.in/api/users 10 | @GET("/api/users") 11 | suspend fun fetchEmployee(): Response 12 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/network/NetworkUtil.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.network 2 | 3 | class NetworkUtil { 4 | companion object { 5 | const val NETWORK_BASE_URL = "https://reqres.in" 6 | const val REQUEST_TIMEOUT = 60L 7 | 8 | } 9 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/repository/EmployeeRepository.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.repository 2 | 3 | import com.employeeinfo.model.EmployeeModel 4 | import com.employeeinfo.model.UserModel 5 | import com.employeeinfo.network.EmployeeService 6 | import kotlinx.coroutines.Dispatchers 7 | import kotlinx.coroutines.flow.Flow 8 | import kotlinx.coroutines.flow.flow 9 | import kotlinx.coroutines.withContext 10 | import retrofit2.Response 11 | 12 | class EmployeeRepository(private val apiServiceAPI: EmployeeService) { 13 | 14 | suspend fun fetchEmployees() : Flow> { 15 | return flow { 16 | val employeeInfo = apiServiceAPI.fetchEmployee() 17 | emit(employeeInfo) 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/viewmodel/EmployeeViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.viewmodel 2 | 3 | import androidx.lifecycle.* 4 | import com.employeeinfo.model.EmployeeModel 5 | import com.employeeinfo.model.UserModel 6 | import com.employeeinfo.repository.EmployeeRepository 7 | import kotlinx.coroutines.CoroutineDispatcher 8 | import kotlinx.coroutines.flow.collect 9 | import kotlinx.coroutines.launch 10 | 11 | class EmployeeViewModel(private val dispatcher: CoroutineDispatcher, private val employeeRepository: EmployeeRepository) : ViewModel(),LifecycleObserver { 12 | var loading: MutableLiveData = MutableLiveData() 13 | private val _employeeMutableLiveDate= MutableLiveData() 14 | val employeeLiveData: LiveData = _employeeMutableLiveDate 15 | 16 | init { 17 | loading.postValue(true) 18 | } 19 | /** 20 | * Fetch employee list 21 | * 22 | */ 23 | fun fetchEmployeeList(){ 24 | 25 | viewModelScope.launch(dispatcher) { 26 | loading.postValue(true) 27 | try{ 28 | employeeRepository.fetchEmployees().collect { response-> 29 | if(response.isSuccessful){ 30 | loading.postValue(false) 31 | val employeeInfo = response.body() 32 | employeeInfo?.let { model -> 33 | _employeeMutableLiveDate.value = model 34 | } 35 | 36 | 37 | }else{ 38 | loading.postValue(false) 39 | } 40 | 41 | } 42 | 43 | 44 | }catch (e:Exception){ 45 | loading.postValue(false) 46 | e.printStackTrace() 47 | } 48 | } 49 | 50 | } 51 | 52 | /** 53 | * Fetch load status 54 | * 55 | * @return 56 | */ 57 | fun fetchLoadStatus(): LiveData = loading 58 | } -------------------------------------------------------------------------------- /app/src/main/java/com/employeeinfo/viewmodel/EmployeeViewModelFactory.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo.viewmodel 2 | 3 | import androidx.lifecycle.ViewModel 4 | import androidx.lifecycle.ViewModelProvider 5 | import com.employeeinfo.dependency.DependencyUtils 6 | import com.employeeinfo.repository.EmployeeRepository 7 | import kotlinx.coroutines.Dispatchers 8 | 9 | class EmployeeViewModelFactory : ViewModelProvider.Factory { 10 | lateinit var employeeRepository: EmployeeRepository 11 | override fun create(modelClass: Class): T { 12 | employeeRepository = DependencyUtils.provideEmployeeRepository() 13 | if (modelClass.isAssignableFrom(EmployeeViewModel::class.java)) { 14 | return EmployeeViewModel(Dispatchers.Main,employeeRepository) as T 15 | } 16 | throw IllegalArgumentException("Unknown ViewModel class") 17 | } 18 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sync.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 20 | 21 | 32 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_user_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 17 | 18 | 27 | 28 | 37 | 38 | 47 | 48 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | EmployeeInfo 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/test/java/com/employeeinfo/EmployeeViewModelTest.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo 2 | 3 | import androidx.arch.core.executor.testing.InstantTaskExecutorRule 4 | import androidx.lifecycle.LiveData 5 | import androidx.lifecycle.Observer 6 | import com.employeeinfo.model.UserModel 7 | import com.employeeinfo.network.EmployeeService 8 | import com.employeeinfo.repository.EmployeeRepository 9 | import com.employeeinfo.viewmodel.EmployeeViewModel 10 | import kotlinx.coroutines.Dispatchers 11 | import kotlinx.coroutines.ExperimentalCoroutinesApi 12 | import kotlinx.coroutines.channels.Channel 13 | import kotlinx.coroutines.flow.consumeAsFlow 14 | import kotlinx.coroutines.flow.flow 15 | import kotlinx.coroutines.flow.flowOf 16 | import kotlinx.coroutines.launch 17 | import kotlinx.coroutines.runBlocking 18 | import kotlinx.coroutines.test.TestCoroutineDispatcher 19 | import kotlinx.coroutines.test.resetMain 20 | import kotlinx.coroutines.test.runBlockingTest 21 | import kotlinx.coroutines.test.setMain 22 | import org.junit.* 23 | import org.junit.rules.TestRule 24 | import org.junit.runner.RunWith 25 | import org.mockito.Mock 26 | import org.mockito.Mockito 27 | import org.mockito.Mockito.doReturn 28 | import org.mockito.Mockito.verify 29 | import org.mockito.MockitoAnnotations 30 | import org.mockito.junit.MockitoJUnitRunner 31 | import retrofit2.Response 32 | import retrofit2.Retrofit 33 | 34 | @RunWith(MockitoJUnitRunner::class) 35 | @ExperimentalCoroutinesApi 36 | class EmployeeViewModelTest { 37 | @get:Rule 38 | val testInstantTaskExecutorRule: TestRule = InstantTaskExecutorRule() 39 | 40 | @get:Rule 41 | val testCoroutineRule = TestCoroutineRule() 42 | 43 | @Mock 44 | lateinit var retrofit: Retrofit 45 | 46 | @Mock 47 | private lateinit var apiHelper: EmployeeService 48 | 49 | @Mock 50 | private lateinit var employeeRepository: EmployeeRepository 51 | 52 | @Mock 53 | private lateinit var apiUsersObserver: Observer> 54 | 55 | @Before 56 | fun setUp(){ 57 | MockitoAnnotations.initMocks(this) 58 | 59 | } 60 | private val testDispatcher = TestCoroutineDispatcher() 61 | @Test 62 | fun test_fetchEmployeeList() = testDispatcher.runBlockingTest { 63 | var data = UserModel.Data( 64 | "https://s3.amazonaws.com/uifaces/faces/twitter/calebogden/128.jpg", 65 | "george.bluth@reqres.in", 66 | "George", 67 | 1, 68 | "Bluth" 69 | ) 70 | var ad = UserModel.Support("StatusCode Weekly","http://statuscode.org/",) 71 | var list = arrayListOf() 72 | list.add(data) 73 | var retroResponse = UserModel(list,2,6,ad,12,12) 74 | val employeeViewModel = EmployeeViewModel(testDispatcher,employeeRepository) 75 | val response = Response.success(retroResponse) 76 | val channel = Channel>() 77 | val flow = channel.consumeAsFlow() 78 | Mockito.`when`(employeeRepository.fetchEmployees()).thenReturn(flow ) 79 | 80 | launch { 81 | channel.send(response) 82 | } 83 | employeeViewModel.fetchEmployeeList() 84 | Assert.assertEquals(1,employeeViewModel.employeeLiveData.value?.data?.size) 85 | Assert.assertEquals(false, employeeViewModel.fetchLoadStatus()?.value) 86 | } 87 | 88 | 89 | /* 90 | val avatar: String, // https://reqres.in/img/faces/1-image.jpg 91 | val email: String, // george.bluth@reqres.in 92 | val first_name: String, // George 93 | val id: Int, // 1 94 | val last_name: String // Bluth 95 | */ 96 | 97 | } -------------------------------------------------------------------------------- /app/src/test/java/com/employeeinfo/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo 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 | } -------------------------------------------------------------------------------- /app/src/test/java/com/employeeinfo/TestCoroutineRule.kt: -------------------------------------------------------------------------------- 1 | package com.employeeinfo 2 | 3 | import kotlinx.coroutines.Dispatchers 4 | import kotlinx.coroutines.ExperimentalCoroutinesApi 5 | import kotlinx.coroutines.test.* 6 | import org.junit.rules.TestRule 7 | import org.junit.runner.Description 8 | import org.junit.runners.model.Statement 9 | 10 | /* 11 | During the unit-test, it enables the main dispatcher to use TestCoroutineDispatcher. 12 | After the test, it resets and cleasnup. 13 | */ 14 | @ExperimentalCoroutinesApi 15 | class TestCoroutineRule : TestRule { 16 | private val testCoroutineDispatcher = TestCoroutineDispatcher() 17 | 18 | private val testCoroutineScope = TestCoroutineScope(testCoroutineDispatcher) 19 | override fun apply(base: Statement?, description: Description?) = object : Statement() { 20 | @Throws(Throwable::class) 21 | override fun evaluate() { 22 | Dispatchers.setMain(testCoroutineDispatcher) 23 | 24 | base?.evaluate() 25 | 26 | Dispatchers.resetMain() 27 | testCoroutineScope.cleanupTestCoroutines() 28 | } 29 | } 30 | 31 | fun runBlockingTest(block: suspend TestCoroutineScope.() -> Unit) = 32 | testCoroutineScope.runBlockingTest { block() } 33 | } -------------------------------------------------------------------------------- /app/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | ext.kotlin_version = "1.4.21" 4 | ext.viewpager2_version = '1.0.0' 5 | ext.material_version = '1.4.0-alpha02' 6 | ext.lifecycle_version = '2.2.0' 7 | ext.arch_version = '2.1.0' 8 | ext.retrofit_version = '2.6.1' 9 | ext.okhttp_version = '4.7.2' 10 | ext.coroutine_version = '1.3.9' 11 | ext.fragment_version = '1.3.3' 12 | ext.rxJava_version = '2.2.19' 13 | ext.rxAndroid_version = '2.1.1' 14 | ext.glide_version = '4.11.0' 15 | ext.cardview_version = '1.0.0' 16 | ext.appcompat_version = '1.2.0' 17 | ext.ktx_version = '1.3.2' 18 | ext.constraint_layout_version = '2.0.4' 19 | ext.drawer_layout_version = '1.1.1' 20 | ext.google_play_version = '1.10.0' 21 | ext.nav_version = '2.3.1' 22 | ext.recycler_view_version = '1.2.0' 23 | repositories { 24 | google() 25 | jcenter() 26 | } 27 | dependencies { 28 | classpath "com.android.tools.build:gradle:4.0.0" 29 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 30 | 31 | // NOTE: Do not place your application dependencies here; they belong 32 | // in the individual module build.gradle files 33 | } 34 | } 35 | 36 | allprojects { 37 | repositories { 38 | google() 39 | jcenter() 40 | } 41 | } 42 | 43 | task clean(type: Delete) { 44 | delete rootProject.buildDir 45 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m 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 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chandragithub2014/MMVMCoroutineFlows/30e56f0326697120081731f46a6520eca6219353/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Jul 10 15:45:46 CEST 2021 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-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | rootProject.name = "EmployeeInfo" --------------------------------------------------------------------------------