..
This commit is contained in:
@@ -38,15 +38,14 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
private ImageView imgProfile;
|
private ImageView imgProfile;
|
||||||
private EditText etSearch;
|
private EditText etSearch;
|
||||||
private ChipGroup chipGroupCategories;
|
private ChipGroup chipGroupCategories;
|
||||||
private RecyclerView rvFeatured, rvMainRestaurants;
|
private RecyclerView rvFeatured, rvTopRated, rvPizzas, rvSushi, rvCarnes, rvMassas, rvSobremesas;
|
||||||
private ProgressBar progressBar;
|
private ProgressBar progressBar;
|
||||||
private View layoutFeatured, layoutAllRestaurants;
|
private View layoutFeatured, layoutTopRated, layoutPizzas, layoutSushi, layoutCarnes, layoutMassas, layoutSobremesas;
|
||||||
|
|
||||||
private List<Restaurant> allRestaurants = new ArrayList<>();
|
private List<Restaurant> allRestaurants = new ArrayList<>();
|
||||||
private List<Restaurant> filteredRestaurants = new ArrayList<>();
|
private List<Restaurant> filteredRestaurants = new ArrayList<>();
|
||||||
|
|
||||||
private RestaurantAdapter mainAdapter;
|
private FeaturedRestaurantAdapter featuredAdapter, topRatedAdapter, pizzasAdapter, sushiAdapter, carnesAdapter, massasAdapter, sobremesasAdapter;
|
||||||
private FeaturedRestaurantAdapter featuredAdapter;
|
|
||||||
|
|
||||||
private final String[] CATEGORIES = { "Tudo", "Carnes", "Massas", "Sushi", "Pizzas", "Sobremesas" };
|
private final String[] CATEGORIES = { "Tudo", "Carnes", "Massas", "Sushi", "Pizzas", "Sobremesas" };
|
||||||
private String currentCategoryFilter = "Tudo";
|
private String currentCategoryFilter = "Tudo";
|
||||||
@@ -83,30 +82,53 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
etSearch = findViewById(R.id.etSearch);
|
etSearch = findViewById(R.id.etSearch);
|
||||||
chipGroupCategories = findViewById(R.id.chipGroupCategories);
|
chipGroupCategories = findViewById(R.id.chipGroupCategories);
|
||||||
rvFeatured = findViewById(R.id.rvFeatured);
|
rvFeatured = findViewById(R.id.rvFeatured);
|
||||||
rvMainRestaurants = findViewById(R.id.rvMainRestaurants);
|
rvTopRated = findViewById(R.id.rvTopRated);
|
||||||
|
rvPizzas = findViewById(R.id.rvPizzas);
|
||||||
|
rvSushi = findViewById(R.id.rvSushi);
|
||||||
|
rvCarnes = findViewById(R.id.rvCarnes);
|
||||||
|
rvMassas = findViewById(R.id.rvMassas);
|
||||||
|
rvSobremesas = findViewById(R.id.rvSobremesas);
|
||||||
|
|
||||||
progressBar = findViewById(R.id.progressBar);
|
progressBar = findViewById(R.id.progressBar);
|
||||||
|
|
||||||
layoutFeatured = findViewById(R.id.layoutFeatured);
|
layoutFeatured = findViewById(R.id.layoutFeatured);
|
||||||
layoutAllRestaurants = findViewById(R.id.layoutAllRestaurants);
|
layoutTopRated = findViewById(R.id.layoutTopRated);
|
||||||
|
layoutPizzas = findViewById(R.id.layoutPizzas);
|
||||||
|
layoutSushi = findViewById(R.id.layoutSushi);
|
||||||
|
layoutCarnes = findViewById(R.id.layoutCarnes);
|
||||||
|
layoutMassas = findViewById(R.id.layoutMassas);
|
||||||
|
layoutSobremesas = findViewById(R.id.layoutSobremesas);
|
||||||
|
|
||||||
rvFeatured.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
rvFeatured.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
rvMainRestaurants.setLayoutManager(new LinearLayoutManager(this));
|
rvTopRated.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
rvPizzas.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
rvSushi.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
rvCarnes.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
rvMassas.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
rvSobremesas.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||||
|
|
||||||
// Click listener for restaurants to open booking flow
|
// Click listener for restaurants to open booking flow
|
||||||
RestaurantAdapter.OnRestaurantClickListener clickListener = restaurant -> {
|
RestaurantAdapter.OnRestaurantClickListener clickListener = restaurant -> {
|
||||||
Intent intent = new Intent(this, ExplorarRestaurantesActivity.class);
|
Intent intent = new Intent(this, ExplorarRestaurantesActivity.class);
|
||||||
// Reusing existing activity for details if needed, or pass data to
|
|
||||||
// NovaReservaActivity
|
|
||||||
// We pass the filter so it can maybe open directly or we just pass restaurant
|
|
||||||
// email
|
|
||||||
intent.putExtra("category_filter", restaurant.getCategory());
|
intent.putExtra("category_filter", restaurant.getCategory());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
};
|
};
|
||||||
|
|
||||||
featuredAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
featuredAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
mainAdapter = new RestaurantAdapter(filteredRestaurants, clickListener);
|
topRatedAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
|
pizzasAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
|
sushiAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
|
carnesAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
|
massasAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
|
sobremesasAdapter = new FeaturedRestaurantAdapter(new ArrayList<>(), clickListener);
|
||||||
|
|
||||||
rvFeatured.setAdapter(featuredAdapter);
|
rvFeatured.setAdapter(featuredAdapter);
|
||||||
rvMainRestaurants.setAdapter(mainAdapter);
|
rvTopRated.setAdapter(topRatedAdapter);
|
||||||
|
rvPizzas.setAdapter(pizzasAdapter);
|
||||||
|
rvSushi.setAdapter(sushiAdapter);
|
||||||
|
rvCarnes.setAdapter(carnesAdapter);
|
||||||
|
rvMassas.setAdapter(massasAdapter);
|
||||||
|
rvSobremesas.setAdapter(sobremesasAdapter);
|
||||||
|
|
||||||
// Click listener for profile picture in the header
|
// Click listener for profile picture in the header
|
||||||
findViewById(R.id.cardProfile).setOnClickListener(v -> {
|
findViewById(R.id.cardProfile).setOnClickListener(v -> {
|
||||||
@@ -163,7 +185,12 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
private void fetchRestaurants() {
|
private void fetchRestaurants() {
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
layoutFeatured.setVisibility(View.GONE);
|
layoutFeatured.setVisibility(View.GONE);
|
||||||
layoutAllRestaurants.setVisibility(View.GONE);
|
layoutTopRated.setVisibility(View.GONE);
|
||||||
|
layoutPizzas.setVisibility(View.GONE);
|
||||||
|
layoutSushi.setVisibility(View.GONE);
|
||||||
|
layoutCarnes.setVisibility(View.GONE);
|
||||||
|
layoutMassas.setVisibility(View.GONE);
|
||||||
|
layoutSobremesas.setVisibility(View.GONE);
|
||||||
|
|
||||||
DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("Restaurantes");
|
DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("Restaurantes");
|
||||||
usersRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
usersRef.addListenerForSingleValueEvent(new ValueEventListener() {
|
||||||
@@ -281,24 +308,73 @@ public class ClientDashboardActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mainAdapter.notifyDataSetChanged();
|
// Listas por categorias
|
||||||
|
|
||||||
// Update featured (just the first 3 for demo, or based on a specific logic)
|
|
||||||
List<Restaurant> featuredList = new ArrayList<>();
|
List<Restaurant> featuredList = new ArrayList<>();
|
||||||
for (int i = 0; i < Math.min(3, filteredRestaurants.size()); i++) {
|
List<Restaurant> topRatedList = new ArrayList<>();
|
||||||
featuredList.add(filteredRestaurants.get(i));
|
List<Restaurant> pizzasList = new ArrayList<>();
|
||||||
|
List<Restaurant> sushiList = new ArrayList<>();
|
||||||
|
List<Restaurant> carnesList = new ArrayList<>();
|
||||||
|
List<Restaurant> massasList = new ArrayList<>();
|
||||||
|
List<Restaurant> sobremesasList = new ArrayList<>();
|
||||||
|
|
||||||
|
// Preencher Destaques e Melhores
|
||||||
|
for (int i = 0; i < filteredRestaurants.size(); i++) {
|
||||||
|
Restaurant r = filteredRestaurants.get(i);
|
||||||
|
|
||||||
|
// Destaques (3 primeiros aleatórios/ordem atual)
|
||||||
|
if (featuredList.size() < 3) {
|
||||||
|
featuredList.add(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Melhor Avaliados (>= 3.0 estrelas)
|
||||||
|
if (r.getRatingAvg() != null && r.getRatingAvg() >= 3.0) {
|
||||||
|
topRatedList.add(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Distribuir pelas categorias baseadas na String
|
||||||
|
String cat = r.getCategory() != null ? r.getCategory().toLowerCase() : "";
|
||||||
|
if (cat.contains("pizza")) {
|
||||||
|
pizzasList.add(r);
|
||||||
|
} else if (cat.contains("sushi")) {
|
||||||
|
sushiList.add(r);
|
||||||
|
} else if (cat.contains("carne")) {
|
||||||
|
carnesList.add(r);
|
||||||
|
} else if (cat.contains("massa")) {
|
||||||
|
massasList.add(r);
|
||||||
|
} else if (cat.contains("sobremesa")) {
|
||||||
|
sobremesasList.add(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
featuredAdapter = new FeaturedRestaurantAdapter(featuredList,
|
RestaurantAdapter.OnRestaurantClickListener clickListener = restaurant -> {
|
||||||
mainAdapter instanceof RestaurantAdapter ? restaurant -> {
|
Intent intent = new Intent(this, ExplorarRestaurantesActivity.class);
|
||||||
Intent intent = new Intent(this, ExplorarRestaurantesActivity.class);
|
intent.putExtra("category_filter", restaurant.getCategory());
|
||||||
intent.putExtra("category_filter", restaurant.getCategory());
|
startActivity(intent);
|
||||||
startActivity(intent);
|
};
|
||||||
} : null);
|
|
||||||
|
featuredAdapter = new FeaturedRestaurantAdapter(featuredList, clickListener);
|
||||||
|
topRatedAdapter = new FeaturedRestaurantAdapter(topRatedList, clickListener);
|
||||||
|
pizzasAdapter = new FeaturedRestaurantAdapter(pizzasList, clickListener);
|
||||||
|
sushiAdapter = new FeaturedRestaurantAdapter(sushiList, clickListener);
|
||||||
|
carnesAdapter = new FeaturedRestaurantAdapter(carnesList, clickListener);
|
||||||
|
massasAdapter = new FeaturedRestaurantAdapter(massasList, clickListener);
|
||||||
|
sobremesasAdapter = new FeaturedRestaurantAdapter(sobremesasList, clickListener);
|
||||||
|
|
||||||
rvFeatured.setAdapter(featuredAdapter);
|
rvFeatured.setAdapter(featuredAdapter);
|
||||||
|
rvTopRated.setAdapter(topRatedAdapter);
|
||||||
|
rvPizzas.setAdapter(pizzasAdapter);
|
||||||
|
rvSushi.setAdapter(sushiAdapter);
|
||||||
|
rvCarnes.setAdapter(carnesAdapter);
|
||||||
|
rvMassas.setAdapter(massasAdapter);
|
||||||
|
rvSobremesas.setAdapter(sobremesasAdapter);
|
||||||
|
|
||||||
layoutFeatured.setVisibility(featuredList.isEmpty() ? View.GONE : View.VISIBLE);
|
layoutFeatured.setVisibility(featuredList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
layoutAllRestaurants.setVisibility(filteredRestaurants.isEmpty() ? View.GONE : View.VISIBLE);
|
layoutTopRated.setVisibility(topRatedList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
layoutPizzas.setVisibility(pizzasList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
layoutSushi.setVisibility(sushiList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
layoutCarnes.setVisibility(carnesList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
layoutMassas.setVisibility(massasList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
|
layoutSobremesas.setVisibility(sobremesasList.isEmpty() ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String normalizeString(String str) {
|
private String normalizeString(String str) {
|
||||||
|
|||||||
@@ -118,8 +118,8 @@ public class DetalhesReservasActivity extends AppCompatActivity {
|
|||||||
btnConfirmar.setOnClickListener(v -> {
|
btnConfirmar.setOnClickListener(v -> {
|
||||||
com.example.pap_teste.models.Reserva item = reservas.get(selectedIndex);
|
com.example.pap_teste.models.Reserva item = reservas.get(selectedIndex);
|
||||||
if ("Pendente".equals(item.getEstado())) {
|
if ("Pendente".equals(item.getEstado())) {
|
||||||
atualizarEstadoSelecionado("Confirmada");
|
mostrarMesasDisponiveis();
|
||||||
} else if ("Confirmada".equals(item.getEstado())) {
|
} else if (item.getEstado() != null && item.getEstado().startsWith("Confirmada")) {
|
||||||
atualizarEstadoSelecionado("Concluída");
|
atualizarEstadoSelecionado("Concluída");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -134,6 +134,80 @@ public class DetalhesReservasActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void mostrarMesasDisponiveis() {
|
||||||
|
if (selectedIndex < 0 || selectedIndex >= reservas.size()) {
|
||||||
|
Toast.makeText(this, "Selecione uma reserva.", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
com.example.pap_teste.models.Reserva item = reservas.get(selectedIndex);
|
||||||
|
|
||||||
|
com.google.firebase.database.DatabaseReference mesasRef = com.google.firebase.database.FirebaseDatabase.getInstance().getReference("Mesas");
|
||||||
|
mesasRef.orderByChild("restauranteEmail").equalTo(restaurantEmail).addListenerForSingleValueEvent(new com.google.firebase.database.ValueEventListener() {
|
||||||
|
@Override
|
||||||
|
public void onDataChange(@androidx.annotation.NonNull com.google.firebase.database.DataSnapshot snapshot) {
|
||||||
|
List<com.example.pap_teste.models.Mesa> mesasLivres = new ArrayList<>();
|
||||||
|
for (com.google.firebase.database.DataSnapshot ds : snapshot.getChildren()) {
|
||||||
|
com.example.pap_teste.models.Mesa m = ds.getValue(com.example.pap_teste.models.Mesa.class);
|
||||||
|
if (m != null && m.getEstado() != null && m.getEstado().equalsIgnoreCase("Livre")) {
|
||||||
|
// Verifica se a mesa tem capacidade suficiente para a reserva
|
||||||
|
if (m.getCapacidade() >= item.getPessoas()) {
|
||||||
|
m.setId(ds.getKey());
|
||||||
|
mesasLivres.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesasLivres.isEmpty()) {
|
||||||
|
new androidx.appcompat.app.AlertDialog.Builder(DetalhesReservasActivity.this)
|
||||||
|
.setTitle("Sem mesas disponíveis")
|
||||||
|
.setMessage("Não há mesas livres ou com capacidade suficiente para esta reserva. Deseja confirmar a reserva mesmo assim (sem atribuir mesa)?")
|
||||||
|
.setPositiveButton("Sim, aceitar", (dialog, which) -> atualizarEstadoSelecionado("Confirmada"))
|
||||||
|
.setNegativeButton("Cancelar", null)
|
||||||
|
.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] mesaOptions = new String[mesasLivres.size()];
|
||||||
|
for (int i = 0; i < mesasLivres.size(); i++) {
|
||||||
|
com.example.pap_teste.models.Mesa m = mesasLivres.get(i);
|
||||||
|
mesaOptions[i] = String.format("Mesa %d (%d lugares)", m.getNumero(), m.getCapacidade());
|
||||||
|
}
|
||||||
|
|
||||||
|
new androidx.appcompat.app.AlertDialog.Builder(DetalhesReservasActivity.this)
|
||||||
|
.setTitle("Atribuir Mesa")
|
||||||
|
.setItems(mesaOptions, (dialog, which) -> {
|
||||||
|
com.example.pap_teste.models.Mesa selecionada = mesasLivres.get(which);
|
||||||
|
confirmarReservaComMesa(item, selecionada);
|
||||||
|
})
|
||||||
|
.setNegativeButton("Avançar sem mesa", (dialog, which) -> atualizarEstadoSelecionado("Confirmada"))
|
||||||
|
.setNeutralButton("Cancelar", null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancelled(@androidx.annotation.NonNull com.google.firebase.database.DatabaseError error) {
|
||||||
|
Toast.makeText(DetalhesReservasActivity.this, "Erro ao carregar mesas.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void confirmarReservaComMesa(com.example.pap_teste.models.Reserva reserva, com.example.pap_teste.models.Mesa mesa) {
|
||||||
|
String novoEstado = "Confirmada (Mesa " + mesa.getNumero() + ")";
|
||||||
|
databaseReference.child(reserva.getId()).child("estado").setValue(novoEstado).addOnCompleteListener(task -> {
|
||||||
|
if (task.isSuccessful()) {
|
||||||
|
com.google.firebase.database.FirebaseDatabase.getInstance().getReference("Mesas").child(mesa.getId()).child("estado").setValue("Reservada")
|
||||||
|
.addOnCompleteListener(t2 -> {
|
||||||
|
Toast.makeText(this, "Reserva aceite e mesa atribuída com sucesso.", Toast.LENGTH_SHORT).show();
|
||||||
|
txtMensagem.setText(String.format("Reserva de %s confirmada na Mesa %d.", reserva.getClienteEmail(), mesa.getNumero()));
|
||||||
|
reserva.setEstado(novoEstado);
|
||||||
|
mostrarDetalhe(reserva);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Toast.makeText(this, "Erro ao confirmar reserva.", Toast.LENGTH_SHORT).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void showRecusarDialog() {
|
private void showRecusarDialog() {
|
||||||
if (selectedIndex < 0)
|
if (selectedIndex < 0)
|
||||||
return;
|
return;
|
||||||
@@ -218,29 +292,27 @@ public class DetalhesReservasActivity extends AppCompatActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (item.getEstado()) {
|
if (item.getEstado() == null) return;
|
||||||
case "Pendente":
|
|
||||||
btnConfirmar.setText("Confirmar");
|
if (item.getEstado().equals("Pendente")) {
|
||||||
btnConfirmar.setVisibility(android.view.View.VISIBLE);
|
btnConfirmar.setText("Confirmar");
|
||||||
btnRecusar.setVisibility(android.view.View.VISIBLE);
|
btnConfirmar.setVisibility(android.view.View.VISIBLE);
|
||||||
btnApagar.setVisibility(android.view.View.GONE);
|
btnRecusar.setVisibility(android.view.View.VISIBLE);
|
||||||
break;
|
btnApagar.setVisibility(android.view.View.GONE);
|
||||||
case "Confirmada":
|
} else if (item.getEstado().startsWith("Confirmada")) {
|
||||||
btnConfirmar.setText("Concluir");
|
btnConfirmar.setText("Concluir");
|
||||||
btnConfirmar.setVisibility(android.view.View.VISIBLE);
|
btnConfirmar.setVisibility(android.view.View.VISIBLE);
|
||||||
btnRecusar.setVisibility(android.view.View.VISIBLE); // Still allow refusal
|
btnRecusar.setVisibility(android.view.View.VISIBLE); // Still allow refusal
|
||||||
btnApagar.setVisibility(android.view.View.GONE);
|
btnApagar.setVisibility(android.view.View.GONE);
|
||||||
break;
|
} else if (item.getEstado().equals("Concluída")) {
|
||||||
case "Concluída":
|
btnConfirmar.setVisibility(android.view.View.GONE);
|
||||||
btnConfirmar.setVisibility(android.view.View.GONE);
|
btnRecusar.setVisibility(android.view.View.GONE);
|
||||||
btnRecusar.setVisibility(android.view.View.GONE);
|
btnApagar.setVisibility(android.view.View.VISIBLE);
|
||||||
btnApagar.setVisibility(android.view.View.VISIBLE);
|
} else {
|
||||||
break;
|
// Recusada or Cancelada
|
||||||
default: // Recusada or Cancelada
|
btnConfirmar.setVisibility(android.view.View.GONE);
|
||||||
btnConfirmar.setVisibility(android.view.View.GONE);
|
btnRecusar.setVisibility(android.view.View.GONE);
|
||||||
btnRecusar.setVisibility(android.view.View.GONE);
|
btnApagar.setVisibility(android.view.View.VISIBLE);
|
||||||
btnApagar.setVisibility(android.view.View.VISIBLE); // Allow deleting refused ones as well
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -106,17 +106,20 @@ public class ListaEsperaActivity extends AppCompatActivity {
|
|||||||
for (DataSnapshot ds : snapshot.getChildren()) {
|
for (DataSnapshot ds : snapshot.getChildren()) {
|
||||||
com.example.pap_teste.models.Mesa m = ds.getValue(com.example.pap_teste.models.Mesa.class);
|
com.example.pap_teste.models.Mesa m = ds.getValue(com.example.pap_teste.models.Mesa.class);
|
||||||
if (m != null && m.getEstado() != null && m.getEstado().equalsIgnoreCase("Livre")) {
|
if (m != null && m.getEstado() != null && m.getEstado().equalsIgnoreCase("Livre")) {
|
||||||
m.setId(ds.getKey());
|
// Opcional: Filtra pela capacidade da mesa
|
||||||
mesasLivres.add(m);
|
if (m.getCapacidade() >= item.getPessoas()) {
|
||||||
|
m.setId(ds.getKey());
|
||||||
|
mesasLivres.add(m);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mesasLivres.isEmpty()) {
|
if (mesasLivres.isEmpty()) {
|
||||||
new androidx.appcompat.app.AlertDialog.Builder(ListaEsperaActivity.this)
|
new androidx.appcompat.app.AlertDialog.Builder(ListaEsperaActivity.this)
|
||||||
.setTitle("Sem mesas disponíveis")
|
.setTitle("Sem mesas disponíveis")
|
||||||
.setMessage("Não há mesas livres registadas. Deseja confirmar a reserva mesmo assim (sem lugar reservado)?")
|
.setMessage("Não há mesas livres registadas ou com capacidade suficiente para a reserva. Deseja confirmar a reserva mesmo assim (sem mesa atribuída)?")
|
||||||
.setPositiveButton("Sim", (dialog, which) -> atualizarEstadoSelecionado("Confirmada"))
|
.setPositiveButton("Sim, aceitar", (dialog, which) -> atualizarEstadoSelecionado("Confirmada"))
|
||||||
.setNegativeButton("Não", null)
|
.setNegativeButton("Cancelar", null)
|
||||||
.show();
|
.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -133,7 +136,8 @@ public class ListaEsperaActivity extends AppCompatActivity {
|
|||||||
com.example.pap_teste.models.Mesa selecionada = mesasLivres.get(which);
|
com.example.pap_teste.models.Mesa selecionada = mesasLivres.get(which);
|
||||||
confirmarReservaComMesa(item, selecionada);
|
confirmarReservaComMesa(item, selecionada);
|
||||||
})
|
})
|
||||||
.setNegativeButton("Cancelar", null)
|
.setNegativeButton("Avançar sem mesa", (dialog, which) -> atualizarEstadoSelecionado("Confirmada"))
|
||||||
|
.setNeutralButton("Cancelar", null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
android:background="@color/colorBackground"
|
android:background="@color/colorBackground"
|
||||||
tools:context=".ClientDashboardActivity">
|
tools:context=".ClientDashboardActivity">
|
||||||
|
|
||||||
<ScrollView
|
<androidx.core.widget.NestedScrollView
|
||||||
android:id="@+id/clientScroll"
|
android:id="@+id/clientScroll"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
android:visibility="visible"
|
android:visibility="visible"
|
||||||
android:indeterminateTint="@color/colorPrimary" />
|
android:indeterminateTint="@color/colorPrimary" />
|
||||||
|
|
||||||
<!-- Featured Carousel -->
|
<!-- Featured / Destaques -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layoutFeatured"
|
android:id="@+id/layoutFeatured"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="24dp"
|
android:layout_marginStart="24dp"
|
||||||
android:text="Restaurantes Populares"
|
android:text="Destaques"
|
||||||
android:textColor="@color/colorTextPrimary"
|
android:textColor="@color/colorTextPrimary"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
@@ -188,9 +188,9 @@
|
|||||||
tools:listitem="@layout/item_restaurant_featured" />
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- Main Restaurant Grid/List -->
|
<!-- Melhor Avaliados -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/layoutAllRestaurants"
|
android:id="@+id/layoutTopRated"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
@@ -198,29 +198,191 @@
|
|||||||
android:layout_marginTop="32dp">
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtListTitle"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="24dp"
|
android:layout_marginStart="24dp"
|
||||||
android:text="Todos os Restaurantes"
|
android:text="Melhor Avaliados"
|
||||||
android:textColor="@color/colorTextPrimary"
|
android:textColor="@color/colorTextPrimary"
|
||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:fontFamily="sans-serif" />
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/rvMainRestaurants"
|
android:id="@+id/rvTopRated"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="12dp"
|
android:layout_marginTop="12dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingBottom="16dp"
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
tools:listitem="@layout/item_restaurant" />
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Pizzas -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutPizzas"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:text="Pizzas"
|
||||||
|
android:textColor="@color/colorTextPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvPizzas"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Sushi -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutSushi"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:text="Sushi"
|
||||||
|
android:textColor="@color/colorTextPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvSushi"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Carnes -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutCarnes"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:text="Carnes"
|
||||||
|
android:textColor="@color/colorTextPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvCarnes"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Massas -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutMassas"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:text="Massas"
|
||||||
|
android:textColor="@color/colorTextPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvMassas"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- Sobremesas -->
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/layoutSobremesas"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="24dp"
|
||||||
|
android:text="Sobremesas"
|
||||||
|
android:textColor="@color/colorTextPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:fontFamily="sans-serif" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rvSobremesas"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:paddingStart="24dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
tools:listitem="@layout/item_restaurant_featured" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
<!-- Bottom Navigation Bar -->
|
<!-- Bottom Navigation Bar -->
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
|
|||||||
Reference in New Issue
Block a user