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
61 changes: 48 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,46 @@ 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"

// Room
implementation "androidx.room:room-runtime:2.2.5"
kapt "androidx.room:room-compiler:2.2.5"

// Kotlin Extensions and Coroutines support for Room
implementation "androidx.room:room-ktx:2.2.5"

}
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
55 changes: 55 additions & 0 deletions app/src/main/java/com/picpay/desafio/adapters/ContactAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.picpay.desafio.adapters

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.AsyncListDiffer
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.picpay.desafio.android.R
import com.picpay.desafio.models.Contact
import kotlinx.android.synthetic.main.list_item_user.view.*

class ContactAdapter : RecyclerView.Adapter<ContactAdapter.ContactViewHolder>() {

inner class ContactViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)

private val differCallback = object : DiffUtil.ItemCallback<Contact>() {

override fun areItemsTheSame(oldItem: Contact, newItem: Contact): Boolean {
return oldItem.id == newItem.id
}

override fun areContentsTheSame(oldItem: Contact, newItem: Contact): Boolean {
return oldItem == newItem
}
}

val differ = AsyncListDiffer(this, differCallback)

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ContactViewHolder {
return ContactViewHolder(
LayoutInflater.from(parent.context).inflate(
R.layout.list_item_user,
parent,
false
)
)
}

override fun onBindViewHolder(holder: ContactViewHolder, position: Int) {
val contact = differ.currentList[position]
holder.itemView.apply {
Glide.with(this).load(contact.img).into(contact_image)
contact_name.text = contact.username
contact_username.text = contact.name
}
}

override fun getItemCount(): Int {
return differ.currentList.size
}


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

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/main/java/com/picpay/desafio/android/PicPayService.kt

This file was deleted.

13 changes: 0 additions & 13 deletions app/src/main/java/com/picpay/desafio/android/User.kt

This file was deleted.

34 changes: 0 additions & 34 deletions app/src/main/java/com/picpay/desafio/android/UserListAdapter.kt

This file was deleted.

This file was deleted.

This file was deleted.

Loading