Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 41 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}

android {
compileSdkVersion 29
Expand Down Expand Up @@ -43,12 +42,9 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

implementation "androidx.core:core-ktx:$core_ktx_version"

implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"

implementation "com.google.android.material:material:$material_version"

implementation "org.koin:koin-core:$koin_version"
Expand All @@ -66,9 +62,6 @@ dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version"

implementation "io.reactivex.rxjava2:rxjava:$rxjava_version"
implementation "io.reactivex.rxjava2:rxandroid:$rxandroid_version"

implementation 'com.google.code.gson:gson:2.8.6'

implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
Expand All @@ -89,4 +82,39 @@ dependencies {
androidTestImplementation "androidx.test:runner:$test_runner_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
androidTestImplementation "androidx.test:core-ktx:$core_ktx_test_version"

// Architectural Components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"

// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8'

// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"

// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation "com.squareup.okhttp3:logging-interceptor:4.5.0"

// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
kapt 'com.github.bumptech.glide:compiler:4.11.0'

// KTX
implementation 'androidx.core:core-ktx:1.3.1'

// Lifecycles
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
kapt "android.arch.lifecycle:compiler:1.1.1"

// GSON
implementation "com.google.code.gson:gson:2.8.6"

// Navigation Components
implementation "androidx.navigation:navigation-fragment-ktx:2.3.0"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0"

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@ import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import com.picpay.desafio.ui.UsersActivity
import okhttp3.mockwebserver.Dispatcher
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import okhttp3.mockwebserver.RecordedRequest
import org.junit.Test


class MainActivityTest {
class UsersActivityTest {

private val server = MockWebServer()

private val context = InstrumentationRegistry.getInstrumentation().targetContext

@Test
fun shouldDisplayTitle() {
launchActivity<MainActivity>().apply {
launchActivity<UsersActivity>().apply {
val expectedTitle = context.getString(R.string.title)

moveToState(Lifecycle.State.RESUMED)
Expand All @@ -44,7 +45,7 @@ class MainActivityTest {

server.start(serverPort)

launchActivity<MainActivity>().apply {
launchActivity<UsersActivity>().apply {
// TODO("validate if list displays items returned by server")
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<activity android:name="com.picpay.desafio.ui.UsersActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
75 changes: 0 additions & 75 deletions app/src/main/java/com/picpay/desafio/android/MainActivity.kt

This file was deleted.

11 changes: 11 additions & 0 deletions app/src/main/java/com/picpay/desafio/api/ContactListApi.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.picpay.desafio.api

import com.picpay.desafio.models.ContactListResponse
import retrofit2.Response
import retrofit2.http.GET

interface ContactListApi {

@GET("users")
suspend fun getContactList(): Response<ContactListResponse>
}
29 changes: 29 additions & 0 deletions app/src/main/java/com/picpay/desafio/api/RetrofitInstance.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.picpay.desafio.api

import com.picpay.desafio.util.Constants.Companion.BASE_URL
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class RetrofitInstance {
companion object{

private val retrofit by lazy{
val logging = HttpLoggingInterceptor()
logging.setLevel(HttpLoggingInterceptor.Level.BODY)
val client = OkHttpClient.Builder()
.addInterceptor(logging)
.build()
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.client(client)
.build()
}

val api by lazy {
retrofit.create(ContactListApi::class.java)
}
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/picpay/desafio/models/Contact.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.picpay.desafio.models

data class Contact(
val id: String,
val img: String,
val name: String,
val username: String
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.picpay.desafio.models

class ContactListResponse : ArrayList<Contact>()
7 changes: 7 additions & 0 deletions app/src/main/java/com/picpay/desafio/ui/SavedUserFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.picpay.desafio.ui

import androidx.fragment.app.Fragment
import com.picpay.desafio.android.R

class SavedUserFragment : Fragment(R.layout.fragment_saved_user) {
}
7 changes: 7 additions & 0 deletions app/src/main/java/com/picpay/desafio/ui/UserListFragment.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.picpay.desafio.ui

import androidx.fragment.app.Fragment
import com.picpay.desafio.android.R

class UserListFragment : Fragment(R.layout.fragment_user_list) {
}
35 changes: 35 additions & 0 deletions app/src/main/java/com/picpay/desafio/ui/UsersActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.picpay.desafio.ui

import android.os.Bundle
import android.os.PersistableBundle
import android.view.View
import android.widget.ProgressBar
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.fragment.findNavController
import androidx.navigation.ui.setupWithNavController
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import com.google.gson.GsonBuilder
import com.picpay.desafio.android.PicPayService
import com.picpay.desafio.android.R
import com.picpay.desafio.android.User
import com.picpay.desafio.android.UserListAdapter
import kotlinx.android.synthetic.main.activity_users.*
import okhttp3.OkHttpClient
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

class UsersActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_users)

bottom_navigation_view.setupWithNavController(users_nav_host_fragment.findNavController())
}
}
8 changes: 8 additions & 0 deletions app/src/main/java/com/picpay/desafio/util/Constants.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.picpay.desafio.util

class Constants {

companion object {
const val BASE_URL = "https://609a908e0f5a13001721b74e.mockapi.io/picpay/api/"
}
}
11 changes: 11 additions & 0 deletions app/src/main/res/anim/slide_in_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate
android:duration = "400"
android:fromXDelta = "-100%"
android:fromYDelta = "0%"
android:toXDelta = "0%"
android:toYDelta = "0%"/>

</set>
11 changes: 11 additions & 0 deletions app/src/main/res/anim/slide_in_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate
android:duration = "400"
android:fromXDelta = "100%"
android:fromYDelta = "0%"
android:toXDelta = "0%"
android:toYDelta = "0%"/>

</set>
11 changes: 11 additions & 0 deletions app/src/main/res/anim/slide_out_left.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate
android:duration = "400"
android:fromXDelta = "0%"
android:fromYDelta = "0%"
android:toXDelta = "-100%"
android:toYDelta = "0%"/>

</set>
11 changes: 11 additions & 0 deletions app/src/main/res/anim/slide_out_right.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">

<translate
android:duration = "400"
android:fromXDelta = "0%"
android:fromYDelta = "0%"
android:toXDelta = "100%"
android:toYDelta = "0%"/>

</set>
Loading