mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Fix bug
This commit is contained in:
@@ -31,7 +31,7 @@ public interface FoodApi {
|
||||
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
|
||||
|
||||
FoodApi apiService = new Retrofit.Builder()
|
||||
.baseUrl("https://foodify-backend-production.up.railway.app/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(FoodApi.class);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface FoodApiToken {
|
||||
|
||||
FoodApiToken apiService = new Retrofit.Builder()
|
||||
.client(client)
|
||||
.baseUrl("https://foodify-backend-production.up.railway.app/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.build()
|
||||
.create(FoodApiToken.class);
|
||||
|
||||
@@ -99,4 +99,7 @@ public interface FoodApiToken {
|
||||
|
||||
@DELETE("users/{userId}/orders/{orderId}")
|
||||
Call<CustomResponse> deleteOrder(@Path("userId") int userId, @Path("orderId") int orderId);
|
||||
|
||||
@PUT("users/{userId}/orders/{orderId}/status")
|
||||
Call<CustomResponse> updateOrderStatus(@Path("userId") int userId, @Path("orderId") int orderId, @Query("status") String status);
|
||||
}
|
||||
|
||||
@@ -333,7 +333,8 @@ public class FoodDetailActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
Toast.makeText(FoodDetailActivity.this, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
startActivity(new Intent(FoodDetailActivity.this, MainActivity.class));
|
||||
onBackPressed();
|
||||
finish();
|
||||
|
||||
} else {
|
||||
Toast.makeText(FoodDetailActivity.this, "Bạn chưa chọn số lượng đồ ăn cần đặt!", Toast.LENGTH_SHORT).show();
|
||||
|
||||
@@ -362,6 +362,8 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void createOrderFood(String transactionId, String paymentMethod) {
|
||||
|
||||
@@ -127,13 +127,13 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void deleteOrderUser(){
|
||||
FoodApiToken.apiService.deleteOrder(Common.CURRENT_USER.getId(), order.getId()).enqueue(new Callback<CustomResponse>() {
|
||||
FoodApiToken.apiService.updateOrderStatus(Common.CURRENT_USER.getId(), order.getId(), "CANCELED").enqueue(new Callback<CustomResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) {
|
||||
if(response.code() == 200){
|
||||
new AestheticDialog.Builder(OrderDetailActivity.this, DialogStyle.RAINBOW, DialogType.SUCCESS)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Đã xoá đơn thành công!")
|
||||
.setMessage("Đã huỷ đơn thành công!")
|
||||
.setCancelable(false)
|
||||
.setOnClickListener(new OnDialogClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -225,6 +225,7 @@ public class SignInActivity extends AppCompatActivity {
|
||||
progressLayout.setVisibility(View.GONE);
|
||||
|
||||
startActivity(new Intent(SignInActivity.this, MainActivity.class));
|
||||
finish();
|
||||
} else {
|
||||
Toast.makeText(SignInActivity.this, "Tài khoản không hợp lệ! Vui lòng kiểm tra lại!", Toast.LENGTH_SHORT).show();
|
||||
FirebaseAuth.getInstance().signOut();
|
||||
|
||||
@@ -61,6 +61,17 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
|
||||
holder.name.setText(foodName);
|
||||
}
|
||||
|
||||
String shopName = food.getShop().getName();
|
||||
|
||||
if(shopName.length() >= 18){
|
||||
StringBuilder stringBuilder = new StringBuilder(food.getShop().getName());
|
||||
stringBuilder.replace(18, food.getShop().getName().length(), "..." );
|
||||
holder.shopName.setText(stringBuilder);
|
||||
} else {
|
||||
holder.shopName.setText(shopName);
|
||||
}
|
||||
|
||||
|
||||
//When food does not have image
|
||||
if(food.getImages().size() == 0){
|
||||
holder.image.setImageResource(R.drawable.default_image_food);
|
||||
@@ -143,7 +154,7 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
|
||||
public static class FoodViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
private final ImageView image, basket_icon;
|
||||
private final TextView price, name, discount;
|
||||
private final TextView price, name, discount, shopName;
|
||||
|
||||
public FoodViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@@ -153,6 +164,7 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
|
||||
price = itemView.findViewById(R.id.price_text_view);
|
||||
discount = itemView.findViewById(R.id.discount);
|
||||
basket_icon = itemView.findViewById(R.id.basket_icon);
|
||||
shopName = itemView.findViewById(R.id.shop_name_text_view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,10 +43,30 @@ public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.
|
||||
return;
|
||||
|
||||
Picasso.get().load(food.getImg()).into(holder.image_view);
|
||||
holder.food_name.setText(food.getName());
|
||||
holder.shop_name.setText(food.getShopName());
|
||||
holder.quantity.setText("Số lượng: " + food.getQuantity());
|
||||
|
||||
String foodName = food.getName();
|
||||
if(foodName.length() >= 35){
|
||||
StringBuilder stringBuilder = new StringBuilder(food.getName());
|
||||
stringBuilder.replace(35, food.getName().length(), "..." );
|
||||
holder.food_name.setText(stringBuilder);
|
||||
} else {
|
||||
holder.food_name.setText(foodName);
|
||||
}
|
||||
|
||||
String shopName = food.getShopName();
|
||||
|
||||
if(shopName.length() >= 18){
|
||||
StringBuilder stringBuilder = new StringBuilder(food.getShopName());
|
||||
stringBuilder.replace(18, food.getShopName().length(), "..." );
|
||||
holder.shop_name.setText(stringBuilder);
|
||||
} else {
|
||||
holder.shop_name.setText(shopName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Check value discountPercent
|
||||
float cost = 0;
|
||||
if(food.getDiscountPercent() > 0){
|
||||
|
||||
Reference in New Issue
Block a user