Skip to content

Commit

Permalink
Solucion final sprint 1
Browse files Browse the repository at this point in the history
  • Loading branch information
“blantu904” committed Oct 24, 2024
1 parent 411cf5e commit 76d6f2e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public void onBtnGuardarClicked(String litros, String precioTotal) {

try {
// Conversión de litros y precio total
double litrosNum = Double.parseDouble(litros);
double precioTotalNum = Double.parseDouble(precioTotal);
double litrosNum = Double.parseDouble(litros.replace(",","."));
double precioTotalNum = Double.parseDouble(precioTotal.replace(",","."));

// Validar que los valores sean positivos
if (litrosNum <= 0 || precioTotalNum <= 0) {
Expand Down Expand Up @@ -90,13 +90,13 @@ public void onBtnGuardarClicked(String litros, String precioTotal) {
errorPrecioTotal = false;

try{
Double.parseDouble(litros);
Double.parseDouble(litros.replace(",","."));
}catch(NumberFormatException ex) {
errorLitros = true;
}

try{
Double.parseDouble(precioTotal);
Double.parseDouble(precioTotal.replace(",","."));
}catch(NumberFormatException ex) {
errorPrecioTotal = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public String getHorario() {
}

public double getGasoleoA() {
return Double.parseDouble(String.format("%.2f", gasoleoA));
return Double.parseDouble(String.format("%.2f", gasoleoA).replace(",","."));
}

public double getGasolina95E5() {
return Double.parseDouble(String.format("%.2f",gasolina95E5));
return Double.parseDouble(String.format("%.2f",gasolina95E5).replace(",","."));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import es.unican.gasolineras.model.Repostaje;
import lombok.Getter;

@Database(entities = {Repostaje.class}, version = 1)
@Database(entities = {Repostaje.class}, version = 2)
public abstract class AppDatabase extends RoomDatabase {
public abstract RepostajeDAO repostajeDao();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static AppDatabase getDatabase(Context context) {
database = Room.databaseBuilder(context.getApplicationContext(),
AppDatabase.class, "database-name")
.allowMainThreadQueries()
.fallbackToDestructiveMigration()
.build();
}
return database;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
android:textSize="20sp"
app:layout_constraintStart_toStartOf="@+id/tvLitrosNum"
app:layout_constraintTop_toBottomOf="@+id/tvLitrosNum"
tools:text="1,432" />
tools:text="1.432" />

<TextView
android:id="@+id/litrosTexto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
android:textSize="24sp"
app:layout_constraintStart_toStartOf="@+id/tvRepostajesMes"
app:layout_constraintTop_toBottomOf="@+id/tvRepostajesMes"
tools:text="1,534" />
tools:text="1.534" />

<TextView
android:id="@+id/resumenMes"
Expand Down

0 comments on commit 76d6f2e

Please sign in to comment.