Commit e336c400 authored by Daniel Cesanelli's avatar Daniel Cesanelli
Browse files

Agregado mensajes y solucionado limpieza de carrito

parent 57ebf6e1
......@@ -6,6 +6,7 @@ import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
......@@ -67,6 +68,7 @@ public class MainActivity extends AppCompatActivity {
sharedpreferences.edit().putString("JWT", "").apply();
sharedpreferences.edit().putString("UserID", "").apply();
userViewModel.setToken(new Token());
Toast.makeText(getApplicationContext(), "Logout realizado correctamente.", Toast.LENGTH_LONG).show();
return true;
}
});
......
......@@ -10,6 +10,7 @@ import com.cesanelli.lajusta.io.models.CartItem;
import com.cesanelli.lajusta.io.models.Product;
import com.cesanelli.lajusta.io.models.User;
import java.util.ArrayList;
import java.util.List;
public class CartViewModel extends ViewModel {
......@@ -98,9 +99,9 @@ public class CartViewModel extends ViewModel {
public void restart(){
Cart newCart = cart.getValue();
for (CartItem cartItem : newCart.getCartProducts()) {
this.deleteProduct(cartItem.getProduct().getId());
Object[] products = newCart.getCartProducts().toArray();
for (int i = 0; i < products.length; i++) {
this.deleteProduct(((CartItem)products[i]).getProduct().getId());
}
this.setNode(null);
}
......
......@@ -16,7 +16,7 @@
<string name="menu_cart">Carrito de Compras</string>
<string name="menu_purchase">Detalle Compra</string>
<string name="menu_final">Gracias por su compra</string>
<string name="txt_username">Usuario</string>
<string name="txt_username">Email</string>
<string name="password">Password</string>
<string name="retry_password">Reiterar Password</string>
<string name="btn_login">Login</string>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment