mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Fix bug
This commit is contained in:
Binary file not shown.
@@ -12,7 +12,7 @@
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0.0",
|
||||
"versionName": "1.0.0-beta",
|
||||
"outputFile": "app-release.apk"
|
||||
}
|
||||
],
|
||||
|
||||
@@ -98,6 +98,9 @@ public interface FoodApiToken {
|
||||
@PUT("users/{userId}/orders/{orderId}/status")
|
||||
Call<CustomResponse> updateOrderStatus(@Path("userId") int userId, @Path("orderId") int orderId, @Query("status") String status);
|
||||
|
||||
@GET("users/{userId}/orders/{orderId}")
|
||||
Call<Order> getOrderById(@Path("userId") int userId, @Path("orderId") int orderId);
|
||||
|
||||
@PUT("users/{userId}/update/fcm")
|
||||
Call<CustomResponse> updateFCMToken(@Path("userId") int userId, @Body String token);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
private List<Basket> listOrderDetails = new ArrayList<>();
|
||||
private OrderDetailAdapter adapter;
|
||||
private RecyclerView recyclerView;
|
||||
private Order order;
|
||||
private Order order, tempOrder;
|
||||
private Button btn_cancel_order, btn_tracking_location_shipper;
|
||||
private View line_cancel_order, line_tracking_order;
|
||||
|
||||
@@ -86,44 +86,10 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
|
||||
//Get data from previous fragment
|
||||
if(getIntent() != null)
|
||||
order = (Order) getIntent().getSerializableExtra("order");
|
||||
tempOrder = (Order) getIntent().getSerializableExtra("order");
|
||||
|
||||
if(order.getStatus().equals(AWAITING)){
|
||||
btn_cancel_order.setVisibility(View.VISIBLE);
|
||||
line_tracking_order.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
if(order.getStatus().equals(SHIPPING)){
|
||||
btn_tracking_location_shipper.setVisibility(View.VISIBLE);
|
||||
line_cancel_order.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Init data
|
||||
order_tracking_number.setText("Order Id: #" + order.getOrderTrackingNumber());
|
||||
user_name.setText("Họ và tên: " + Common.CURRENT_USER.getFullName());
|
||||
phone.setText("Số điện thoại: " + Common.CURRENT_USER.getPhoneNumber());
|
||||
address.setText("Địa chỉ: " + order.getAddress());
|
||||
orderTime.setText("Thời gian đặt: " + order.getOrderTime());
|
||||
total.setText("Tổng: " + Common.changeCurrencyUnit(order.getTotal()));
|
||||
status.setText("Trạng thái đơn hàng: " + translateStatus(order.getStatus()));
|
||||
|
||||
|
||||
for(OrderDetail tempFood: order.getOrderDetails()){
|
||||
Basket food = new Basket(tempFood.getFood().getId(), tempFood.getFood().getImages().get(0).getImageUrl(),
|
||||
tempFood.getFood().getName(), tempFood.getFood().getCost() ,tempFood.getFood().getShop().getName(), tempFood.getQuantity(),
|
||||
tempFood.getFood().getDiscountPercent(), tempFood.getFood().getShop().getId());
|
||||
listOrderDetails.add(food);
|
||||
}
|
||||
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
adapter.setData(listOrderDetails);
|
||||
recyclerView.setAdapter(adapter);
|
||||
//Get information order
|
||||
getOrder();
|
||||
|
||||
back_image.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@@ -152,6 +118,64 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
//Init data
|
||||
order_tracking_number.setText("Order Id: #" + order.getOrderTrackingNumber());
|
||||
user_name.setText("Họ và tên: " + Common.CURRENT_USER.getFullName());
|
||||
phone.setText("Số điện thoại: " + Common.CURRENT_USER.getPhoneNumber());
|
||||
address.setText("Địa chỉ: " + order.getAddress());
|
||||
orderTime.setText("Thời gian đặt: " + order.getOrderTime());
|
||||
total.setText("Tổng: " + Common.changeCurrencyUnit(order.getTotal()));
|
||||
status.setText("Trạng thái đơn hàng: " + translateStatus(order.getStatus()));
|
||||
|
||||
|
||||
for(OrderDetail tempFood: order.getOrderDetails()){
|
||||
Basket food = new Basket(tempFood.getFood().getId(), tempFood.getFood().getImages().get(0).getImageUrl(),
|
||||
tempFood.getFood().getName(), tempFood.getFood().getCost() ,tempFood.getFood().getShop().getName(), tempFood.getQuantity(),
|
||||
tempFood.getFood().getDiscountPercent(), tempFood.getFood().getShop().getId());
|
||||
listOrderDetails.add(food);
|
||||
}
|
||||
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this, RecyclerView.VERTICAL, false);
|
||||
recyclerView.setLayoutManager(linearLayoutManager);
|
||||
|
||||
adapter.setData(listOrderDetails);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
|
||||
if(order.getStatus().equals(AWAITING)){
|
||||
btn_cancel_order.setVisibility(View.VISIBLE);
|
||||
line_tracking_order.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
if(order.getStatus().equals(SHIPPING)){
|
||||
btn_tracking_location_shipper.setVisibility(View.VISIBLE);
|
||||
line_cancel_order.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void getOrder(){
|
||||
FoodApiToken.apiService.getOrderById(Common.CURRENT_USER.getId(), tempOrder.getId()).enqueue(new Callback<Order>() {
|
||||
@Override
|
||||
public void onResponse(Call<Order> call, Response<Order> response) {
|
||||
if(response.code() == 200){
|
||||
order = response.body();
|
||||
|
||||
initData();
|
||||
} else {
|
||||
Toast.makeText(OrderDetailActivity.this, "Đã có lỗi. Mã lỗi: " + response.code(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Order> call, Throwable t) {
|
||||
Log.e(TAG, t.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showDeleteDialogConfirm(){
|
||||
BasicDialog dialog = new BasicDialog();
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.
|
||||
|
||||
public void setData(List<Basket> listFoodInBasket){
|
||||
this.listFoodInBasket = listFoodInBasket;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Common {
|
||||
public static String FCM_TOKEN = null;
|
||||
public static Location CURRENT_LOCATION = null;
|
||||
public static FirebaseUser FIREBASE_USER = null;
|
||||
public static final String DEFAULT_IMAGE_URL = "https://firebasestorage.googleapis.com/v0/b/foodify-55954.appspot.com/o/Admin%2Fdefault-ava-01.png?alt=media&token=90202711-4b1a-4665-a941-a65bf6c2002e";
|
||||
public static final String DEFAULT_IMAGE_URL = "https://firebasestorage.googleapis.com/v0/b/foodify-55954.appspot.com/o/Admin%2Fdefault%2Fdefault-ava-01.png?alt=media";
|
||||
public static final String MAP_API = "AIzaSyAY14Ic32UP26Hg6GILznOfbBihiY5BUxw";
|
||||
public static final String FORMAT_DATE="yyyy-MM-dd";
|
||||
public static final String VALID_EMAIL_ADDRESS_REGEX = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$";
|
||||
|
||||
Reference in New Issue
Block a user