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

Segundo entregable #37

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
80 changes: 80 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'androidx.navigation.safeargs.kotlin'
}

android {
namespace 'com.example.myapplication'
compileSdk 33

defaultConfig {
applicationId "com.example.myapplication"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}

viewBinding {
enabled = true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

//view model live data
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.0-alpha02")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.0-alpha02")

//Navigation
implementation("androidx.navigation:navigation-fragment-ktx:2.5.2")
implementation("androidx.navigation:navigation-ui-ktx:2.5.2")

//retrofit
implementation "com.squareup.picasso:picasso:2.8"
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"

implementation "com.fasterxml.jackson.core:jackson-core:2.11.1"
implementation "com.fasterxml.jackson.core:jackson-annotations:2.11.1"

//corrutinas
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'

implementation 'com.github.bumptech.glide:glide:4.14.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
implementation 'com.squareup.picasso:picasso:2.8'

//concat
implementation "androidx.recyclerview:recyclerview:1.2.1"

// Utils
implementation 'com.github.bumptech.glide:glide:4.14.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.myapplication

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.myapplication", appContext.packageName)
}
}
Binary file added app/src/debug/ic_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.
74 changes: 74 additions & 0 deletions app/src/debug/res/drawable/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
android:height="108dp"
android:width="108dp"
android:viewportHeight="108"
android:viewportWidth="108"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
</vector>
32 changes: 32 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<meta-data
android:name="android.app.lib_name"
android:value="" />
</activity>
</application>

</manifest>
15 changes: 15 additions & 0 deletions app/src/main/java/com/example/myapplication/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.myapplication.adapter.BitsoAdapter

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.example.myapplication.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.example.myapplication.R
import com.example.myapplication.core.BaseViewHolder
import com.example.myapplication.data.model.Book
import com.example.myapplication.databinding.ItemBitsoBinding

class BitsoAdapter(private val bitsoList: List<Book>,
private val itemClickListener: OnBitsoClickListener
): RecyclerView.Adapter<BaseViewHolder<*>>() {

interface OnBitsoClickListener{
fun onBitsoClick(book: Book)
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder<*> {
val itemBinding = ItemBitsoBinding.inflate(LayoutInflater.from(parent.context), parent, false)
val holder = BitcoinViewHolder(itemBinding, parent.context)

itemBinding.root.setOnClickListener {
val position = holder.bindingAdapterPosition.takeIf { it != DiffUtil.DiffResult.NO_POSITION }
?: return@setOnClickListener
itemClickListener.onBitsoClick(bitsoList[position])
}
return holder
}

override fun onBindViewHolder(holder: BaseViewHolder<*>, position: Int) {
when(holder){
is BitcoinViewHolder -> holder.bind(bitsoList[position])
}
}

override fun getItemCount(): Int = bitsoList.size

private inner class BitcoinViewHolder(
val binding: ItemBitsoBinding,
val context: Context
): BaseViewHolder<Book>(binding.root){
override fun bind(item: Book){
Glide.with(context).load(R.drawable.ic_info)
.centerCrop().into(binding.ivImageCoin)
binding.tvCoinName.text = item.book
binding.tvMaxPrice.text = item.maximumPrice.toString()
binding.tvMinPrice.text = item.minimumPrice.toString()

when(item.book){
"btc_mxn" -> Glide.with(context).load(R.drawable.loopring).centerCrop().into(binding.ivImageCoin)
"eth_btc" -> Glide.with(context).load(R.drawable.paxgold).centerCrop().into(binding.ivImageCoin)
"eth_mxn" -> Glide.with(context).load(R.drawable.cardano).centerCrop().into(binding.ivImageCoin)
"xrp_btc" -> Glide.with(context).load(R.drawable.balancer).centerCrop().into(binding.ivImageCoin)
"xrp_mxn" -> Glide.with(context).load(R.drawable.paxgold).centerCrop().into(binding.ivImageCoin)
"ltc_btc" -> Glide.with(context).load(R.drawable.axie).centerCrop().into(binding.ivImageCoin)
"ltc_mxn" -> Glide.with(context).load(R.drawable.fantom).centerCrop().into(binding.ivImageCoin)
"bch_btc" -> Glide.with(context).load(R.drawable.gala).centerCrop().into(binding.ivImageCoin)
"bch_mxn" -> Glide.with(context).load(R.drawable.loopring).centerCrop().into(binding.ivImageCoin)
"tusd_btc" -> Glide.with(context).load(R.drawable.cardano).centerCrop().into(binding.ivImageCoin)
"tusd_mxn" -> Glide.with(context).load(R.drawable.loopring).centerCrop().into(binding.ivImageCoin)
"mana_btc" -> Glide.with(context).load(R.drawable.paxgold).centerCrop().into(binding.ivImageCoin)
"mana_mxn" -> Glide.with(context).load(R.drawable.cardano).centerCrop().into(binding.ivImageCoin)
"bat_btc" -> Glide.with(context).load(R.drawable.balancer).centerCrop().into(binding.ivImageCoin)
"bat_mxn" -> Glide.with(context).load(R.drawable.paxgold).centerCrop().into(binding.ivImageCoin)
"btc_ars" -> Glide.with(context).load(R.drawable.axie).centerCrop().into(binding.ivImageCoin)
"btc_dai" -> Glide.with(context).load(R.drawable.fantom).centerCrop().into(binding.ivImageCoin)
"dai_mxn" -> Glide.with(context).load(R.drawable.gala).centerCrop().into(binding.ivImageCoin)
"btc_usd" -> Glide.with(context).load(R.drawable.loopring).centerCrop().into(binding.ivImageCoin)
"xrp_usd" -> Glide.with(context).load(R.drawable.cardano).centerCrop().into(binding.ivImageCoin)

}
}
}

}


Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.example.myapplication.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.myapplication.core.BaseConcatHolder
import com.example.myapplication.databinding.ListBitsoBinding

class BitsoConcatAdapter(private val bitsoAdapter: BitsoAdapter): RecyclerView.Adapter<BaseConcatHolder<*>>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseConcatHolder<*> {
val itemBinding = ListBitsoBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ConcatViewHolder(itemBinding)

}

override fun onBindViewHolder(holder: BaseConcatHolder<*>, position: Int) {
when (holder) {
is ConcatViewHolder -> holder.bind(bitsoAdapter)
else -> throw IllegalArgumentException("No viewholder to show this data, did you forgot to add it to the onBindViewHolder?")
}
}

override fun getItemCount(): Int = 1

private inner class ConcatViewHolder(val binding: ListBitsoBinding): BaseConcatHolder<BitsoAdapter>(binding.root){
override fun bind(adapter: BitsoAdapter) {
binding.rvAvailable.adapter = adapter
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.myapplication.application

object AppConstants {
const val BASE_URL = "https://api.bitso.com/v3/"
const val API_KEY = ""
}
Loading