Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0/tercer entregable #50

Open
wants to merge 53 commits into
base: main
Choose a base branch
from

Conversation

Omar-0
Copy link

@Omar-0 Omar-0 commented Mar 2, 2023

Se utilizó lint para arreglar codigo.
Añade inyección de dependencias
Cambia a navigation Component la navegación
Agrega la opción de usar RX para el servicio available order books
Agrega opcional mostrar LazyColumn de Compose en lugar de RecyclerView en la primera pantalla

OMA and others added 30 commits February 2, 2023 14:57
…and db models for exchange order books + poc db room + room dependencies + refactor book to exchange boor order + poc dao
… + update primary key for asks and bids + stores ticker to db + item layout for bids and ask
0MA added 23 commits February 17, 2023 12:57
- add book name on bids and orders
- moved internet checker to activity viewmodel
…fragment + temp cache strategy for available books call request to avoid multiple calls + fixed exposed mutable live data on view model
Copy link

@emm4nuelBar emm4nuelBar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hola Omar,

Te felicito por tu proyecto!! me dio mucho gusto ver tu progreso a lo largo de cada semana. Para este entregable te dejo unos comentarios sobre DI y buenas practicas. Son detalles menores que podrían mejorar tu código, en general es un muy buen trabajo!!

Comment on lines +11 to +58

abstract class HttpConnectionManager<T : Any>(coinApi: CoinApis) {

abstract fun build(): T

private val loggingInterceptor = HttpLoggingInterceptor().apply {
level = if (BuildConfig.DEBUG) {
HttpLoggingInterceptor.Level.BODY
} else {
HttpLoggingInterceptor.Level.NONE
}
}

val httpClient = when (coinApi) {
CoinApis.BITSO -> {
Retrofit.Builder()
.baseUrl(CoinApis.BITSO.hostUrl)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(
OkHttpClient().newBuilder()
.addInterceptor(BitsoInterceptor())
.addInterceptor(loggingInterceptor)
.build(),
).build()
}
CoinApis.RESTFUL_API -> {
Retrofit.Builder()
.baseUrl(CoinApis.RESTFUL_API.hostUrl)
.addConverterFactory(GsonConverterFactory.create())
.client(
OkHttpClient().newBuilder()
.addInterceptor(loggingInterceptor)
// .addInterceptor(BitsoInterceptor())
// .addNetworkInterceptor(GSSCHeadersInterceptorAWSS3())
.build(),
).build()
}

else -> {
Retrofit.Builder()
.baseUrl("")
.addConverterFactory(GsonConverterFactory.create())
.client(OkHttpClient().newBuilder().build())
.build()
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podrías mejorar este código creando un modulo y usando inyección de dependencias para obtener la instancia de retrofit, esta seria una propuesta:

@Module
@InstallIn(SingletonComponent::class)
object NetworkingRxModule {

    private val loggingInterceptor = HttpLoggingInterceptor().apply {
        level = if (BuildConfig.DEBUG) {
            HttpLoggingInterceptor.Level.BODY
        } else {
            HttpLoggingInterceptor.Level.NONE
        }
    }

    @Provides
    @Singleton
    fun provideRetrofitClient(): Retrofit {
        return Retrofit.Builder()
            .baseUrl(CoinApis.BITSO.hostUrl)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .client(
                OkHttpClient().newBuilder()
                    .addInterceptor(BitsoInterceptor())
                    .addInterceptor(loggingInterceptor)
                    .build(),
            ).build()
    }

}

Comment on lines +27 to +30
@Singleton
fun provideBitsoOrderBooksApi(): BitsoOrderBooksApi {
return BitsoOrderBooksApi.Builder().build()
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Al usar DI para obtener tu instancia de retrofit, este metodo podría refactorizarse a


    @Provides
    @Singleton
    fun provideBitsoOrderBooksApi(retrofit: Retrofit): BitsoOrderBooksApi {
        return retrofit.create(BitsoOrderBooksApi::class.java)
    }

private val db: ZeroCoinAppDatabase,
) : LocalOrderBookRepository {

val scope = CoroutineScope(Dispatchers.IO)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como buena practica convierte tus variables en privadas si solo las usas en ese archivo

Comment on lines +25 to +26
val context = LocalContext.current
val listState = rememberLazyListState()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variables que no se usan deben eliminarse

Comment on lines +36 to +38
if (cryptoCoinsKeys.isEmpty()) CryptoCoinUI.crypto.coinKey else cryptoCoinsKeys[0]
val sellerCryptoCoinKey =
if (cryptoCoinsKeys.size == 2) cryptoCoinsKeys[1] else CryptoCoinUI.crypto.coinKey

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evita tener "números mágicos" en código, es mas recomendable pasalos a una constante

Comment on lines +111 to +123
fun ErrorDialogHandler(show: Boolean) {
val context = LocalContext.current
var showCustomDialog by remember {
mutableStateOf(false)
}
showCustomDialog = show
if (showCustomDialog) {
ErrorDialog({
showCustomDialog = !showCustomDialog
}, {
})
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me parece que este componente nunca lo usas en el proy o si?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants