Skip to content

Commit

Permalink
Merge pull request #18 from Aleixo-Dev/improvement/change-ui-style
Browse files Browse the repository at this point in the history
[improvement] improvement ui style
  • Loading branch information
aleixo-dev authored Jun 24, 2023
2 parents eb6a521 + 33f9e88 commit b5747ac
Show file tree
Hide file tree
Showing 56 changed files with 662 additions and 285 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "br.com.nicolas.consultacd"
minSdk 23
targetSdk 32
versionCode 5
versionName "3.0.0"
versionCode 6
versionName "4.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@drawable/ic_launcher_foreground"
android:supportsRtl="true"
tools:targetApi="31">
<activity
Expand All @@ -28,11 +27,12 @@

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/maps_api_key" />
android:value="AIzaSyADV5wOoqRvFuOqsjkhGXzrhcxMuGWFSOw" />

<!-- Este id é para meio de teste -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="@string/google_ad_mob_api_key"/>
android:value="ca-app-pub-3940256099942544~3347511713"/>
</application>

</manifest>
Binary file added app/src/main/ic__new_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package br.com.nicolas.consultacd.data.respository

import br.com.nicolas.consultacd.domain.DirectModel
import br.com.nicolas.consultacd.models.CepRemote
import br.com.nicolas.consultacd.models.DirectRemote
import kotlinx.coroutines.flow.Flow

interface QueryDataSource {

suspend fun getCep(cepCode : String): Flow<CepRemote>
suspend fun getDirect(dddCode : String) : Flow<DirectRemote>
suspend fun getDirect(dddCode : String) : Flow<DirectModel>
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package br.com.nicolas.consultacd.data.respository

import br.com.nicolas.consultacd.data.service.QueryService
import br.com.nicolas.consultacd.domain.DirectModel
import br.com.nicolas.consultacd.models.CepRemote
import br.com.nicolas.consultacd.models.DirectRemote
import br.com.nicolas.consultacd.models.toDirectModel
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
Expand All @@ -18,9 +19,9 @@ class QueryRepository(
emit(response)
}.flowOn(coroutineDispatcher)

override suspend fun getDirect(dddCode: String): Flow<DirectRemote> = flow<DirectRemote> {
override suspend fun getDirect(dddCode: String): Flow<DirectModel> = flow {
val response = service.getDirect(dddCode)
emit(response)
emit(response.toDirectModel())
}.flowOn(coroutineDispatcher)

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package br.com.nicolas.consultacd.domain

data class DirectModel(
val cities : List<String>? = null,
val state : String? = null
)
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package br.com.nicolas.consultacd.models


import br.com.nicolas.consultacd.domain.DirectModel
import com.google.gson.annotations.SerializedName

data class DirectRemote(
@SerializedName("cities")
val cities: List<String>,
@SerializedName("state")
val state: String
)
)

fun DirectRemote.toDirectModel() = DirectModel(
cities, state
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ package br.com.nicolas.consultacd.ui.home.adapter
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import br.com.nicolas.consultacd.databinding.LayoutCepBinding
import br.com.nicolas.consultacd.databinding.LayoutDirectBinding
import br.com.nicolas.consultacd.models.CepRemote
import java.lang.StringBuilder

class HomeAdapter(
private val cities: List<String>
private val cities: List<String>,
private val state: String
) : RecyclerView.Adapter<HomeAdapter.MainViewHolder>() {

class MainViewHolder(private val binding: LayoutDirectBinding) :
inner class MainViewHolder(private val binding: LayoutDirectBinding) :
RecyclerView.ViewHolder(binding.root) {

fun bind(cities: String) {
binding.textViewDirectCity.text = cities
fun bind(city: String) {
binding.textViewDirectCity.text = city
binding.textViewDirectState.text = StringBuilder()
.append("-").append(state)
}
}

Expand All @@ -30,7 +32,8 @@ class HomeAdapter(
}

override fun onBindViewHolder(holder: MainViewHolder, position: Int) {
holder.bind(cities[position])
val sortedByNameList = cities.sortedBy { it }
holder.bind(sortedByNameList[position])
}

override fun getItemCount() = cities.size
Expand Down
Loading

0 comments on commit b5747ac

Please sign in to comment.